clockdomain.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * OMAP clockdomain support
  3. *
  4. * Copyright (C) 2013 Texas Instruments, Inc.
  5. *
  6. * Tero Kristo <t-kristo@ti.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  13. * kind, whether express or implied; without even the implied warranty
  14. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. */
  17. #include <linux/clk-provider.h>
  18. #include <linux/slab.h>
  19. #include <linux/of.h>
  20. #include <linux/of_address.h>
  21. #include <linux/clk/ti.h>
  22. #undef pr_fmt
  23. #define pr_fmt(fmt) "%s: " fmt, __func__
  24. static void __init of_ti_clockdomain_setup(struct device_node *node)
  25. {
  26. struct clk *clk;
  27. struct clk_hw *clk_hw;
  28. const char *clkdm_name = node->name;
  29. int i;
  30. int num_clks;
  31. num_clks = of_count_phandle_with_args(node, "clocks", "#clock-cells");
  32. for (i = 0; i < num_clks; i++) {
  33. clk = of_clk_get(node, i);
  34. if (__clk_get_flags(clk) & CLK_IS_BASIC) {
  35. pr_warn("can't setup clkdm for basic clk %s\n",
  36. __clk_get_name(clk));
  37. continue;
  38. }
  39. clk_hw = __clk_get_hw(clk);
  40. to_clk_hw_omap(clk_hw)->clkdm_name = clkdm_name;
  41. omap2_init_clk_clkdm(clk_hw);
  42. }
  43. }
  44. static struct of_device_id ti_clkdm_match_table[] __initdata = {
  45. { .compatible = "ti,clockdomain" },
  46. { }
  47. };
  48. /**
  49. * ti_dt_clockdomains_setup - setup device tree clockdomains
  50. *
  51. * Initializes clockdomain nodes for a SoC. This parses through all the
  52. * nodes with compatible = "ti,clockdomain", and add the clockdomain
  53. * info for all the clocks listed under these. This function shall be
  54. * called after rest of the DT clock init has completed and all
  55. * clock nodes have been registered.
  56. */
  57. void __init ti_dt_clockdomains_setup(void)
  58. {
  59. struct device_node *np;
  60. for_each_matching_node(np, ti_clkdm_match_table) {
  61. of_ti_clockdomain_setup(np);
  62. }
  63. }