Guest User

rev2

a guest
Apr 3rd, 2013
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.05 KB | None | 0 0
  1. From 2a4d8dc4e0c75834d14a8a53f342a63b86318c04 Mon Sep 17 00:00:00 2001
  2. From: Nishanth Menon <[email protected]>
  3. Date: Fri, 15 Mar 2013 12:03:30 -0500
  4. Subject: [PATCH] ARM: OMAP3+: use cpu0-cpufreq driver in device tree
  5. supported boot
  6.  
  7. With OMAP3+ and AM33xx supported SoC having defined CPU device tree
  8. entries with operating-points defined, we can now use the SoC
  9. generic cpufreq-cpu0 driver by registering appropriate device.
  10.  
  11. OMAP clock nodes are not represented by device tree nodes yet.
  12. Once the OMAP device tree conversion is complete, we should
  13. have been able to do:
  14. clocks = <&dpll_mpu_ck>; or the SoC specific equivalent.
  15.  
  16. However, since we are unable to do the same, use "cpufreq_ck"
  17. as an generic clock alias to point at the representative
  18. clock required for controlling CPU clock.
  19.  
  20. As part of this change modify AM33xx clock data file to
  21. have cpufreq_ck clock to be generic. This way both omap-cpufreq
  22. and cpufreq-cpu0 drivers (based on device tree enabled boot support)
  23. will use the same clock alias.
  24.  
  25. For platforms which get clock nodes converted into DT, they may provide
  26. appropriate clock nodes.
  27. Once complete DT conversion is complete, Corresponding alias-check code
  28. can be deleted.
  29.  
  30. Inspired by patch: https://patchwork.kernel.org/patch/2067841/
  31. now made generic.
  32.  
  33. Nyet-signed-off-by: Nishanth Menon <[email protected]>
  34. ---
  35. arch/arm/mach-omap2/board-generic.c | 74 +++++++++++++++++++++++++++++++++
  36. arch/arm/mach-omap2/cclock33xx_data.c | 2 +-
  37. 2 files changed, 75 insertions(+), 1 deletion(-)
  38.  
  39. diff --git a/arch/arm/mach-omap2/board-generic.c b/arch/arm/mach-omap2/board-generic.c
  40. index afa509a..3e37326 100644
  41. --- a/arch/arm/mach-omap2/board-generic.c
  42. +++ b/arch/arm/mach-omap2/board-generic.c
  43. @@ -11,6 +11,7 @@
  44. * it under the terms of the GNU General Public License version 2 as
  45. * published by the Free Software Foundation.
  46. */
  47. +#include <linux/clk.h>
  48. #include <linux/io.h>
  49. #include <linux/of_irq.h>
  50. #include <linux/of_platform.h>
  51. @@ -35,6 +36,77 @@ static struct of_device_id omap_dt_match_table[] __initdata = {
  52. { }
  53. };
  54.  
  55. +static void omap_generic_cpufreq_init(void)
  56. +{
  57. + struct platform_device *pdev;
  58. + struct platform_device_info devinfo = { .name = "cpufreq-cpu0", };
  59. + char cpufreq_ck_name[] = "cpufreq_ck";
  60. + struct device_node *np;
  61. + struct device *dev;
  62. + int r;
  63. + struct clk *clk;
  64. +
  65. + if (!IS_ENABLED(CONFIG_GENERIC_CPUFREQ_CPU0))
  66. + return;
  67. +
  68. + pdev = platform_device_register_full(&devinfo);
  69. + if (IS_ERR(pdev)) {
  70. + pr_err("%s: failed to register %s device\n", __func__,
  71. + devinfo.name);
  72. + return;
  73. + }
  74. +
  75. + /*
  76. + * XXX: FIXME:
  77. + * OMAP clock nodes are still based off data files. When they get
  78. + * converted to DT entries, cpu node should have a clock node associated
  79. + * with it.
  80. + * We expect cpufreq to continue to work seamlessly when that takes
  81. + * place. When that takes place, remove the following code:
  82. + */
  83. +
  84. + /*
  85. + * Search for the cpu node where we expect clock node
  86. + * WARNING: this is duplication of logic present in cpufreq-cpu0 driver,
  87. + * but shrug, no other sensible way of being sure.
  88. + */
  89. + for_each_child_of_node(of_find_node_by_path("/cpus"), np) {
  90. + if (of_get_property(np, "operating-points", NULL))
  91. + break;
  92. + }
  93. +
  94. + if (!np) {
  95. + dev_err(&pdev->dev, "%s: operating-point cpu0 node missing\n",
  96. + __func__);
  97. + platform_device_unregister(pdev);
  98. + return;
  99. + }
  100. +
  101. + dev = &pdev->dev;
  102. + dev->of_node = np;
  103. + /*
  104. + * if we are able to get a clk, assume we have a DT node entry and we
  105. + * dont need to add an clock alias - just return the clock
  106. + */
  107. + clk = clk_get(dev, NULL);
  108. + if (!IS_ERR(clk)) {
  109. + clk_put (clk);
  110. + return;
  111. + }
  112. +
  113. + /*
  114. + * OK, we are now in a platform where clock nodes are not DT converted
  115. + * Add an clock alias
  116. + */
  117. + r = clk_add_alias(NULL, dev_name(&pdev->dev), cpufreq_ck_name,
  118. + &pdev->dev);
  119. + if (r) {
  120. + dev_err(&pdev->dev, "%s: clk add alias '%s' failed(%d)\n",
  121. + __func__, cpufreq_ck_name, r);
  122. + platform_device_unregister(pdev);
  123. + }
  124. +}
  125. +
  126. static void __init omap_generic_init(void)
  127. {
  128. omap_sdrc_init(NULL, NULL);
  129. @@ -49,6 +121,8 @@ static void __init omap_generic_init(void)
  130. omap4_panda_display_init_of();
  131. else if (of_machine_is_compatible("ti,omap4-sdp"))
  132. omap_4430sdp_display_init_of();
  133. +
  134. + omap_generic_cpufreq_init();
  135. }
  136.  
  137. #ifdef CONFIG_SOC_OMAP2420
  138. diff --git a/arch/arm/mach-omap2/cclock33xx_data.c b/arch/arm/mach-omap2/cclock33xx_data.c
  139. index 476b820..262cee3 100644
  140. --- a/arch/arm/mach-omap2/cclock33xx_data.c
  141. +++ b/arch/arm/mach-omap2/cclock33xx_data.c
  142. @@ -852,7 +852,7 @@ static struct omap_clk am33xx_clks[] = {
  143. CLK(NULL, "dpll_core_m5_ck", &dpll_core_m5_ck, CK_AM33XX),
  144. CLK(NULL, "dpll_core_m6_ck", &dpll_core_m6_ck, CK_AM33XX),
  145. CLK(NULL, "dpll_mpu_ck", &dpll_mpu_ck, CK_AM33XX),
  146. - CLK("cpu0", NULL, &dpll_mpu_ck, CK_AM33XX),
  147. + CLK(NULL, "cpufreq_ck", &dpll_mpu_ck, CK_AM33XX),
  148. CLK(NULL, "dpll_mpu_m2_ck", &dpll_mpu_m2_ck, CK_AM33XX),
  149. CLK(NULL, "dpll_ddr_ck", &dpll_ddr_ck, CK_AM33XX),
  150. CLK(NULL, "dpll_ddr_m2_ck", &dpll_ddr_m2_ck, CK_AM33XX),
  151. --
  152. 1.7.9.5
Advertisement
Add Comment
Please, Sign In to add comment