clk-814x.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * This program is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU General Public License as
  4. * published by the Free Software Foundation version 2.
  5. */
  6. #include <linux/kernel.h>
  7. #include <linux/clk.h>
  8. #include <linux/clk-provider.h>
  9. #include <linux/clk/ti.h>
  10. #include <linux/of_platform.h>
  11. #include "clock.h"
  12. static struct ti_dt_clk dm814_clks[] = {
  13. DT_CLK(NULL, "devosc_ck", "devosc_ck"),
  14. DT_CLK(NULL, "mpu_ck", "mpu_ck"),
  15. DT_CLK(NULL, "sysclk4_ck", "sysclk4_ck"),
  16. DT_CLK(NULL, "sysclk5_ck", "sysclk5_ck"),
  17. DT_CLK(NULL, "sysclk6_ck", "sysclk6_ck"),
  18. DT_CLK(NULL, "sysclk8_ck", "sysclk8_ck"),
  19. DT_CLK(NULL, "sysclk10_ck", "sysclk10_ck"),
  20. DT_CLK(NULL, "sysclk18_ck", "sysclk18_ck"),
  21. DT_CLK(NULL, "timer_sys_ck", "devosc_ck"),
  22. DT_CLK(NULL, "timer1_fck", "timer1_fck"),
  23. DT_CLK(NULL, "timer2_fck", "timer2_fck"),
  24. DT_CLK(NULL, "cpsw_125mhz_gclk", "cpsw_125mhz_gclk"),
  25. DT_CLK(NULL, "cpsw_cpts_rft_clk", "cpsw_cpts_rft_clk"),
  26. { .node_name = NULL },
  27. };
  28. static bool timer_clocks_initialized;
  29. static int __init dm814x_adpll_early_init(void)
  30. {
  31. struct device_node *np;
  32. if (!timer_clocks_initialized)
  33. return -ENODEV;
  34. np = of_find_node_by_name(NULL, "pllss");
  35. if (!np) {
  36. pr_err("Could not find node for plls\n");
  37. return -ENODEV;
  38. }
  39. of_platform_populate(np, NULL, NULL, NULL);
  40. return 0;
  41. }
  42. core_initcall(dm814x_adpll_early_init);
  43. static const char * const init_clocks[] = {
  44. "pll040clkout", /* MPU 481c5040.adpll.clkout */
  45. "pll290clkout", /* DDR 481c5290.adpll.clkout */
  46. };
  47. static int __init dm814x_adpll_enable_init_clocks(void)
  48. {
  49. int i, err;
  50. if (!timer_clocks_initialized)
  51. return -ENODEV;
  52. for (i = 0; i < ARRAY_SIZE(init_clocks); i++) {
  53. struct clk *clock;
  54. clock = clk_get(NULL, init_clocks[i]);
  55. if (WARN(IS_ERR(clock), "could not find init clock %s\n",
  56. init_clocks[i]))
  57. continue;
  58. err = clk_prepare_enable(clock);
  59. if (WARN(err, "could not enable init clock %s\n",
  60. init_clocks[i]))
  61. continue;
  62. }
  63. return 0;
  64. }
  65. postcore_initcall(dm814x_adpll_enable_init_clocks);
  66. int __init dm814x_dt_clk_init(void)
  67. {
  68. ti_dt_clocks_register(dm814_clks);
  69. omap2_clk_disable_autoidle_all();
  70. omap2_clk_enable_init_clocks(NULL, 0);
  71. timer_clocks_initialized = true;
  72. return 0;
  73. }