[PATCH 1/4] cpufreq: Add a cpufreq driver for Marvell Dove
From: Sudeep KarkadaNagesha <hidden>
Date: 2013-10-22 10:19:51
Also in:
linux-pm
On 19/10/13 13:37, Andrew Lunn wrote:
The Marvell Dove SoC can run the CPU at two frequencies. The high frequencey is from a PLL, while the lower is the same as the DDR clock. Add a cpufreq driver to swap between these frequences. Signed-off-by: Andrew Lunn <andrew@lunn.ch> --- drivers/cpufreq/Kconfig.arm | 7 ++ drivers/cpufreq/Makefile | 1 + drivers/cpufreq/dove-cpufreq.c | 276 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 284 insertions(+) create mode 100644 drivers/cpufreq/dove-cpufreq.c
[snip]
+static int dove_cpufreq_probe(struct platform_device *pdev)
+{
+ struct device_node *np;
+ struct resource *res;
+ int err;
+ int irq;
+
+ priv.dev = &pdev->dev;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ priv.dfs = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(priv.dfs))
+ return PTR_ERR(priv.dfs);
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+ priv.pmu_cr = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(priv.pmu_cr))
+ return PTR_ERR(priv.pmu_cr);
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+ priv.pmu_clk_div = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(priv.pmu_clk_div))
+ return PTR_ERR(priv.pmu_clk_div);
+
+ np = of_find_node_by_path("/cpus/cpu at 0");
+ if (!np)
+ return -ENODEV;
+You need not search for cpu nodes. When the cpu are registered, their of_node gets initialised. So you can just use: np = of_cpu_device_node_get(0); However I think its better to just get: cpu_dev = get_cpu_device(0); as clk APIs can use cpu_dev
+ priv.cpu_clk = of_clk_get_by_name(np, "cpu_clk");
Now this can be priv.cpu_clk = devm_clk_get(cpu_dev, "cpu_clk");
+ if (IS_ERR(priv.cpu_clk)) {
+ dev_err(priv.dev, "Unable to get cpuclk");
+ return PTR_ERR(priv.cpu_clk);
+ }
+
+ clk_prepare_enable(priv.cpu_clk);
+ dove_freq_table[0].frequency = clk_get_rate(priv.cpu_clk) / 1000;
+
+ priv.ddr_clk = of_clk_get_by_name(np, "ddrclk");Similarly priv.ddr_clk = devm_clk_get(cpu_dev, "ddrclk");
+ if (IS_ERR(priv.ddr_clk)) {
+ dev_err(priv.dev, "Unable to get ddrclk");
+ err = PTR_ERR(priv.ddr_clk);
+ goto out_cpu;
+ }
+
+ clk_prepare_enable(priv.ddr_clk);
+ dove_freq_table[1].frequency = clk_get_rate(priv.ddr_clk) / 1000;
+
+ irq = irq_of_parse_and_map(np, 0);Here you can use cpu_dev->of_node Regards, Sudeep