/Ethereal-msm8939-beta9/arch/metag/kernel/clock.c

https://bitbucket.org/MilosStamenkovic95/etherealos · C · 53 lines · 20 code · 7 blank · 26 comment · 2 complexity · eaeba3c33d5b54e188981590abe0d409 MD5 · raw file

  1. /*
  2. * arch/metag/kernel/clock.c
  3. *
  4. * Copyright (C) 2012 Imagination Technologies Ltd.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/delay.h>
  11. #include <linux/io.h>
  12. #include <asm/param.h>
  13. #include <asm/clock.h>
  14. struct meta_clock_desc _meta_clock;
  15. /* Default machine get_core_freq callback. */
  16. static unsigned long get_core_freq_default(void)
  17. {
  18. #ifdef CONFIG_METAG_META21
  19. /*
  20. * Meta 2 cores divide down the core clock for the Meta timers, so we
  21. * can estimate the core clock from the divider.
  22. */
  23. return (metag_in32(EXPAND_TIMER_DIV) + 1) * 1000000;
  24. #else
  25. /*
  26. * On Meta 1 we don't know the core clock, but assuming the Meta timer
  27. * is correct it can be estimated based on loops_per_jiffy.
  28. */
  29. return (loops_per_jiffy * HZ * 5) >> 1;
  30. #endif
  31. }
  32. /**
  33. * setup_meta_clocks() - Set up the Meta clock.
  34. * @desc: Clock descriptor usually provided by machine description
  35. *
  36. * Ensures all callbacks are valid.
  37. */
  38. void __init setup_meta_clocks(struct meta_clock_desc *desc)
  39. {
  40. /* copy callbacks */
  41. if (desc)
  42. _meta_clock = *desc;
  43. /* set fallback functions */
  44. if (!_meta_clock.get_core_freq)
  45. _meta_clock.get_core_freq = get_core_freq_default;
  46. }