Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1586056

[PATCH] arc: get rate from clk driver instead of reading device tree

From Vlad Zakharov <Vladislav.Zakharov@synopsys.com>
Newsgroups linux.kernel
Subject [PATCH] arc: get rate from clk driver instead of reading device tree
Date 2017-02-22 11:40 +0100
Message-ID <tdCv0-eA-25@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


We were reading clock rate directly from device tree "clock-frequency"
property of corresponding clock node in show_cpuinfo function.

Such approach is correct only in case cpu is always clocked by
"fixed-clock". If we use clock driver that allows rate to be changed
this won't work as rate may change during the time or even
"clock-frequency" property may not be presented at all.

So this commit replaces reading device tree with getting rate from clock
driver. This approach is much more flexible and will work for both fixed
and mutable clocks.

Signed-off-by: Vlad Zakharov <vzakhar@synopsys.com>
---
 arch/arc/kernel/setup.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c
index 3093fa8..49b0804 100644
--- a/arch/arc/kernel/setup.c
+++ b/arch/arc/kernel/setup.c
@@ -10,6 +10,7 @@
 #include <linux/fs.h>
 #include <linux/delay.h>
 #include <linux/root_dev.h>
+#include <linux/clk.h>
 #include <linux/clk-provider.h>
 #include <linux/clocksource.h>
 #include <linux/console.h>
@@ -488,7 +489,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 {
 	char *str;
 	int cpu_id = ptr_to_cpu(v);
-	struct device_node *core_clk = of_find_node_by_name(NULL, "core_clk");
+	struct device *cpu_dev = get_cpu_device(cpu_id);
+	struct clk *cpu_clk = clk_get(cpu_dev, "core_clk");
 	u32 freq = 0;
 
 	if (!cpu_online(cpu_id)) {
@@ -502,7 +504,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 
 	seq_printf(m, arc_cpu_mumbojumbo(cpu_id, str, PAGE_SIZE));
 
-	of_property_read_u32(core_clk, "clock-frequency", &freq);
+	freq = clk_get_rate(cpu_clk);
 	if (freq)
 		seq_printf(m, "CPU speed\t: %u.%02u Mhz\n",
 			   freq / 1000000, (freq / 10000) % 100);
-- 
2.7.4

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] arc: get rate from clk driver instead of reading device tree Vlad Zakharov <Vladislav.Zakharov@synopsys.com> - 2017-02-22 11:40 +0100
  Re: [PATCH] arc: get rate from clk driver instead of reading device  tree Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2017-02-22 19:40 +0100
    Re: [PATCH] arc: get rate from clk driver instead of reading device  tree Alexey Brodkin <Alexey.Brodkin@synopsys.com> - 2017-02-28 17:00 +0100
  Re: [PATCH] arc: get rate from clk driver instead of reading device  tree Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2017-02-22 20:00 +0100

csiph-web