clock-cpg.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #define CLKDEV_CON_ID(_id, _clk) { .con_id = _id, .clk = _clk }
  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("tmu_fck", NULL, "peripheral_clk", NULL);
  51. clk_add_alias("mtu2_fck", NULL, "peripheral_clk", NULL);
  52. clk_add_alias("cmt_fck", NULL, "peripheral_clk", NULL);
  53. clk_add_alias("sci_ick", NULL, "peripheral_clk", NULL);
  54. return ret;
  55. }
  56. /*
  57. * Placeholder for compatibility, until the lazy CPUs do this
  58. * on their own.
  59. */
  60. int __init __weak arch_clk_init(void)
  61. {
  62. return cpg_clk_init();
  63. }