clock-sh7710.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * arch/sh/kernel/cpu/sh3/clock-sh7710.c
  3. *
  4. * SH7710 support for the clock framework
  5. *
  6. * Copyright (C) 2005 Paul Mundt
  7. *
  8. * FRQCR parsing hacked out of arch/sh/kernel/time.c
  9. *
  10. * Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka
  11. * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org>
  12. * Copyright (C) 2002, 2003, 2004 Paul Mundt
  13. * Copyright (C) 2002 M. R. Brown <mrbrown@linux-sh.org>
  14. *
  15. * This file is subject to the terms and conditions of the GNU General Public
  16. * License. See the file "COPYING" in the main directory of this archive
  17. * for more details.
  18. */
  19. #include <linux/init.h>
  20. #include <linux/kernel.h>
  21. #include <asm/clock.h>
  22. #include <asm/freq.h>
  23. #include <asm/io.h>
  24. static int md_table[] = { 1, 2, 3, 4, 6, 8, 12 };
  25. static void master_clk_init(struct clk *clk)
  26. {
  27. clk->rate *= md_table[__raw_readw(FRQCR) & 0x0007];
  28. }
  29. static struct sh_clk_ops sh7710_master_clk_ops = {
  30. .init = master_clk_init,
  31. };
  32. static unsigned long module_clk_recalc(struct clk *clk)
  33. {
  34. int idx = (__raw_readw(FRQCR) & 0x0007);
  35. return clk->parent->rate / md_table[idx];
  36. }
  37. static struct sh_clk_ops sh7710_module_clk_ops = {
  38. .recalc = module_clk_recalc,
  39. };
  40. static unsigned long bus_clk_recalc(struct clk *clk)
  41. {
  42. int idx = (__raw_readw(FRQCR) & 0x0700) >> 8;
  43. return clk->parent->rate / md_table[idx];
  44. }
  45. static struct sh_clk_ops sh7710_bus_clk_ops = {
  46. .recalc = bus_clk_recalc,
  47. };
  48. static unsigned long cpu_clk_recalc(struct clk *clk)
  49. {
  50. int idx = (__raw_readw(FRQCR) & 0x0070) >> 4;
  51. return clk->parent->rate / md_table[idx];
  52. }
  53. static struct sh_clk_ops sh7710_cpu_clk_ops = {
  54. .recalc = cpu_clk_recalc,
  55. };
  56. static struct sh_clk_ops *sh7710_clk_ops[] = {
  57. &sh7710_master_clk_ops,
  58. &sh7710_module_clk_ops,
  59. &sh7710_bus_clk_ops,
  60. &sh7710_cpu_clk_ops,
  61. };
  62. void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
  63. {
  64. if (idx < ARRAY_SIZE(sh7710_clk_ops))
  65. *ops = sh7710_clk_ops[idx];
  66. }