Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 2a4d8dc4e0c75834d14a8a53f342a63b86318c04 Mon Sep 17 00:00:00 2001
- From: Nishanth Menon <[email protected]>
- Date: Fri, 15 Mar 2013 12:03:30 -0500
- Subject: [PATCH] ARM: OMAP3+: use cpu0-cpufreq driver in device tree
- supported boot
- With OMAP3+ and AM33xx supported SoC having defined CPU device tree
- entries with operating-points defined, we can now use the SoC
- generic cpufreq-cpu0 driver by registering appropriate device.
- OMAP clock nodes are not represented by device tree nodes yet.
- Once the OMAP device tree conversion is complete, we should
- have been able to do:
- clocks = <&dpll_mpu_ck>; or the SoC specific equivalent.
- However, since we are unable to do the same, use "cpufreq_ck"
- as an generic clock alias to point at the representative
- clock required for controlling CPU clock.
- As part of this change modify AM33xx clock data file to
- have cpufreq_ck clock to be generic. This way both omap-cpufreq
- and cpufreq-cpu0 drivers (based on device tree enabled boot support)
- will use the same clock alias.
- For platforms which get clock nodes converted into DT, they may provide
- appropriate clock nodes.
- Once complete DT conversion is complete, Corresponding alias-check code
- can be deleted.
- Inspired by patch: https://patchwork.kernel.org/patch/2067841/
- now made generic.
- Nyet-signed-off-by: Nishanth Menon <[email protected]>
- ---
- arch/arm/mach-omap2/board-generic.c | 74 +++++++++++++++++++++++++++++++++
- arch/arm/mach-omap2/cclock33xx_data.c | 2 +-
- 2 files changed, 75 insertions(+), 1 deletion(-)
- diff --git a/arch/arm/mach-omap2/board-generic.c b/arch/arm/mach-omap2/board-generic.c
- index afa509a..3e37326 100644
- --- a/arch/arm/mach-omap2/board-generic.c
- +++ b/arch/arm/mach-omap2/board-generic.c
- @@ -11,6 +11,7 @@
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
- +#include <linux/clk.h>
- #include <linux/io.h>
- #include <linux/of_irq.h>
- #include <linux/of_platform.h>
- @@ -35,6 +36,77 @@ static struct of_device_id omap_dt_match_table[] __initdata = {
- { }
- };
- +static void omap_generic_cpufreq_init(void)
- +{
- + struct platform_device *pdev;
- + struct platform_device_info devinfo = { .name = "cpufreq-cpu0", };
- + char cpufreq_ck_name[] = "cpufreq_ck";
- + struct device_node *np;
- + struct device *dev;
- + int r;
- + struct clk *clk;
- +
- + if (!IS_ENABLED(CONFIG_GENERIC_CPUFREQ_CPU0))
- + return;
- +
- + pdev = platform_device_register_full(&devinfo);
- + if (IS_ERR(pdev)) {
- + pr_err("%s: failed to register %s device\n", __func__,
- + devinfo.name);
- + return;
- + }
- +
- + /*
- + * XXX: FIXME:
- + * OMAP clock nodes are still based off data files. When they get
- + * converted to DT entries, cpu node should have a clock node associated
- + * with it.
- + * We expect cpufreq to continue to work seamlessly when that takes
- + * place. When that takes place, remove the following code:
- + */
- +
- + /*
- + * Search for the cpu node where we expect clock node
- + * WARNING: this is duplication of logic present in cpufreq-cpu0 driver,
- + * but shrug, no other sensible way of being sure.
- + */
- + for_each_child_of_node(of_find_node_by_path("/cpus"), np) {
- + if (of_get_property(np, "operating-points", NULL))
- + break;
- + }
- +
- + if (!np) {
- + dev_err(&pdev->dev, "%s: operating-point cpu0 node missing\n",
- + __func__);
- + platform_device_unregister(pdev);
- + return;
- + }
- +
- + dev = &pdev->dev;
- + dev->of_node = np;
- + /*
- + * if we are able to get a clk, assume we have a DT node entry and we
- + * dont need to add an clock alias - just return the clock
- + */
- + clk = clk_get(dev, NULL);
- + if (!IS_ERR(clk)) {
- + clk_put (clk);
- + return;
- + }
- +
- + /*
- + * OK, we are now in a platform where clock nodes are not DT converted
- + * Add an clock alias
- + */
- + r = clk_add_alias(NULL, dev_name(&pdev->dev), cpufreq_ck_name,
- + &pdev->dev);
- + if (r) {
- + dev_err(&pdev->dev, "%s: clk add alias '%s' failed(%d)\n",
- + __func__, cpufreq_ck_name, r);
- + platform_device_unregister(pdev);
- + }
- +}
- +
- static void __init omap_generic_init(void)
- {
- omap_sdrc_init(NULL, NULL);
- @@ -49,6 +121,8 @@ static void __init omap_generic_init(void)
- omap4_panda_display_init_of();
- else if (of_machine_is_compatible("ti,omap4-sdp"))
- omap_4430sdp_display_init_of();
- +
- + omap_generic_cpufreq_init();
- }
- #ifdef CONFIG_SOC_OMAP2420
- diff --git a/arch/arm/mach-omap2/cclock33xx_data.c b/arch/arm/mach-omap2/cclock33xx_data.c
- index 476b820..262cee3 100644
- --- a/arch/arm/mach-omap2/cclock33xx_data.c
- +++ b/arch/arm/mach-omap2/cclock33xx_data.c
- @@ -852,7 +852,7 @@ static struct omap_clk am33xx_clks[] = {
- CLK(NULL, "dpll_core_m5_ck", &dpll_core_m5_ck, CK_AM33XX),
- CLK(NULL, "dpll_core_m6_ck", &dpll_core_m6_ck, CK_AM33XX),
- CLK(NULL, "dpll_mpu_ck", &dpll_mpu_ck, CK_AM33XX),
- - CLK("cpu0", NULL, &dpll_mpu_ck, CK_AM33XX),
- + CLK(NULL, "cpufreq_ck", &dpll_mpu_ck, CK_AM33XX),
- CLK(NULL, "dpll_mpu_m2_ck", &dpll_mpu_m2_ck, CK_AM33XX),
- CLK(NULL, "dpll_ddr_ck", &dpll_ddr_ck, CK_AM33XX),
- CLK(NULL, "dpll_ddr_m2_ck", &dpll_ddr_m2_ck, CK_AM33XX),
- --
- 1.7.9.5
Advertisement
Add Comment
Please, Sign In to add comment