clock-sh7770.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * arch/sh/kernel/cpu/sh4a/clock-sh7770.c
  3. *
  4. * SH7770 support for the clock framework
  5. *
  6. * Copyright (C) 2005 Paul Mundt
  7. *
  8. * This file is subject to the terms and conditions of the GNU General Public
  9. * License. See the file "COPYING" in the main directory of this archive
  10. * for more details.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/kernel.h>
  14. #include <asm/clock.h>
  15. #include <asm/freq.h>
  16. #include <asm/io.h>
  17. static int ifc_divisors[] = { 1, 1, 1, 1, 1, 1, 1, 1 };
  18. static int bfc_divisors[] = { 1, 1, 1, 1, 1, 8,12, 1 };
  19. static int pfc_divisors[] = { 1, 8, 1,10,12,16, 1, 1 };
  20. static void master_clk_init(struct clk *clk)
  21. {
  22. clk->rate *= pfc_divisors[(__raw_readl(FRQCR) >> 28) & 0x000f];
  23. }
  24. static struct sh_clk_ops sh7770_master_clk_ops = {
  25. .init = master_clk_init,
  26. };
  27. static unsigned long module_clk_recalc(struct clk *clk)
  28. {
  29. int idx = ((__raw_readl(FRQCR) >> 28) & 0x000f);
  30. return clk->parent->rate / pfc_divisors[idx];
  31. }
  32. static struct sh_clk_ops sh7770_module_clk_ops = {
  33. .recalc = module_clk_recalc,
  34. };
  35. static unsigned long bus_clk_recalc(struct clk *clk)
  36. {
  37. int idx = (__raw_readl(FRQCR) & 0x000f);
  38. return clk->parent->rate / bfc_divisors[idx];
  39. }
  40. static struct sh_clk_ops sh7770_bus_clk_ops = {
  41. .recalc = bus_clk_recalc,
  42. };
  43. static unsigned long cpu_clk_recalc(struct clk *clk)
  44. {
  45. int idx = ((__raw_readl(FRQCR) >> 24) & 0x000f);
  46. return clk->parent->rate / ifc_divisors[idx];
  47. }
  48. static struct sh_clk_ops sh7770_cpu_clk_ops = {
  49. .recalc = cpu_clk_recalc,
  50. };
  51. static struct sh_clk_ops *sh7770_clk_ops[] = {
  52. &sh7770_master_clk_ops,
  53. &sh7770_module_clk_ops,
  54. &sh7770_bus_clk_ops,
  55. &sh7770_cpu_clk_ops,
  56. };
  57. void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
  58. {
  59. if (idx < ARRAY_SIZE(sh7770_clk_ops))
  60. *ops = sh7770_clk_ops[idx];
  61. }