Thread (16 messages) 16 messages, 5 authors, 2013-10-23
STALE4658d
Revisions (23)
  1. v1 [diff vs current]
  2. v1 [diff vs current]
  3. v1 [diff vs current]
  4. v1 [diff vs current]
  5. v1 [diff vs current]
  6. v1 [diff vs current]
  7. v1 [diff vs current]
  8. v1 current
  9. v1 [diff vs current]
  10. v1 [diff vs current]
  11. v4 [diff vs current]
  12. v4 [diff vs current]
  13. v4 [diff vs current]
  14. v4 [diff vs current]
  15. v4 [diff vs current]
  16. v4 [diff vs current]
  17. v4 [diff vs current]
  18. v4 [diff vs current]
  19. v5 [diff vs current]
  20. v4 [diff vs current]
  21. v5 [diff vs current]
  22. v5 [diff vs current]
  23. v5 [diff vs current]

[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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help