clock-cpg.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #include <linux/clk.h>
  2. #include <linux/compiler.h>
  3. #include <linux/slab.h>
  4. #include <linux/io.h>
  5. #include <linux/clkdev.h>
  6. #include <asm/clock.h>
  7. static struct clk master_clk = {
  8. .flags = CLK_ENABLE_ON_INIT,
  9. .rate = CONFIG_SH_PCLK_FREQ,
  10. };
  11. static struct clk peripheral_clk = {
  12. .parent = &master_clk,
  13. .flags = CLK_ENABLE_ON_INIT,
  14. };
  15. static struct clk bus_clk = {
  16. .parent = &master_clk,
  17. .flags = CLK_ENABLE_ON_INIT,
  18. };
  19. static struct clk cpu_clk = {
  20. .parent = &master_clk,
  21. .flags = CLK_ENABLE_ON_INIT,
  22. };
  23. /*
  24. * The ordering of these clocks matters, do not change it.
  25. */
  26. static struct clk *onchip_clocks[] = {
  27. &master_clk,
  28. &peripheral_clk,
  29. &bus_clk,
  30. &cpu_clk,
  31. };
  32. static struct clk_lookup lookups[] = {
  33. /* main clocks */
  34. CLKDEV_CON_ID("master_clk", &master_clk),
  35. CLKDEV_CON_ID("peripheral_clk", &peripheral_clk),
  36. CLKDEV_CON_ID("bus_clk", &bus_clk),
  37. CLKDEV_CON_ID("cpu_clk", &cpu_clk),
  38. };
  39. int __init __deprecated cpg_clk_init(void)
  40. {
  41. int i, ret = 0;
  42. for (i = 0; i < ARRAY_SIZE(onchip_clocks); i++) {
  43. struct clk *clk = onchip_clocks[i];
  44. arch_init_clk_ops(&clk->ops, i);
  45. if (clk->ops)
  46. ret |= clk_register(clk);
  47. }
  48. clkdev_add_table(lookups, ARRAY_SIZE(lookups));
  49. clk_add_alias("fck", "sh-tmu-sh3.0", "peripheral_clk", NULL);
  50. clk_add_alias("fck", "sh-tmu.0", "peripheral_clk", NULL);
  51. clk_add_alias("fck", "sh-tmu.1", "peripheral_clk", NULL);
  52. clk_add_alias("fck", "sh-tmu.2", "peripheral_clk", NULL);
  53. clk_add_alias("fck", "sh-mtu2", "peripheral_clk", NULL);
  54. clk_add_alias("fck", "sh-cmt-16.0", "peripheral_clk", NULL);
  55. clk_add_alias("fck", "sh-cmt-32.0", "peripheral_clk", NULL);
  56. clk_add_alias("sci_ick", NULL, "peripheral_clk", NULL);
  57. return ret;
  58. }
  59. /*
  60. * Placeholder for compatibility, until the lazy CPUs do this
  61. * on their own.
  62. */
  63. int __init __weak arch_clk_init(void)
  64. {
  65. return cpg_clk_init();
  66. }