clock-cpg.c 1.8 KB

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