linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] ARC: get frequency via clock driver instead of reading device tree
@ 2017-03-03 11:29 Vlad Zakharov
  2017-03-03 11:30 ` [PATCH 1/3] ARC: [dts] add input clocks for cpu nodes Vlad Zakharov
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Vlad Zakharov @ 2017-03-03 11:29 UTC (permalink / raw)
  To: linux-snps-arc
  Cc: devicetree, linux-kernel, Vineet Gupta, Rob Herring, Vlad Zakharov

This patch series replaces reading device tree with getting CPU
clock frequency via clock driver in show_cpuinfo function.

In order to achieve this we also add cpu nodes to device tree which
describes SMP system and add "clocks" properties to all ARC cpu nodes. 

Vlad Zakharov (3):
  ARC: [dts] add input clocks for cpu nodes
  ARC: [dts] add cpu nodes to ARCHS SMP device tree
  arc: get rate from clk driver instead of reading device tree

 arch/arc/boot/dts/skeleton.dtsi        |  1 +
 arch/arc/boot/dts/skeleton_hs.dtsi     |  1 +
 arch/arc/boot/dts/skeleton_hs_idu.dtsi | 21 ++++++++++++++++++++-
 arch/arc/kernel/setup.c                | 17 +++++++++++++----
 4 files changed, 35 insertions(+), 5 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] ARC: [dts] add input clocks for cpu nodes
  2017-03-03 11:29 [PATCH 0/3] ARC: get frequency via clock driver instead of reading device tree Vlad Zakharov
@ 2017-03-03 11:30 ` Vlad Zakharov
  2017-03-03 11:30 ` [PATCH 2/3] ARC: [dts] add cpu nodes to ARCHS SMP device tree Vlad Zakharov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Vlad Zakharov @ 2017-03-03 11:30 UTC (permalink / raw)
  To: linux-snps-arc
  Cc: devicetree, linux-kernel, Vineet Gupta, Rob Herring, Vlad Zakharov

ARC CPU cores are driven by core_clk so we add corresponding "clocks"
property to ARC cpu nodes.

Signed-off-by: Vlad Zakharov <vzakhar@synopsys.com>
---
 arch/arc/boot/dts/skeleton.dtsi        | 1 +
 arch/arc/boot/dts/skeleton_hs.dtsi     | 1 +
 arch/arc/boot/dts/skeleton_hs_idu.dtsi | 1 +
 3 files changed, 3 insertions(+)

diff --git a/arch/arc/boot/dts/skeleton.dtsi b/arch/arc/boot/dts/skeleton.dtsi
index 65808fe..2891cb2 100644
--- a/arch/arc/boot/dts/skeleton.dtsi
+++ b/arch/arc/boot/dts/skeleton.dtsi
@@ -26,6 +26,7 @@
 			device_type = "cpu";
 			compatible = "snps,arc770d";
 			reg = <0>;
+			clocks = <&core_clk>;
 		};
 	};
 
diff --git a/arch/arc/boot/dts/skeleton_hs.dtsi b/arch/arc/boot/dts/skeleton_hs.dtsi
index 2dfe803..5e944d3 100644
--- a/arch/arc/boot/dts/skeleton_hs.dtsi
+++ b/arch/arc/boot/dts/skeleton_hs.dtsi
@@ -21,6 +21,7 @@
 			device_type = "cpu";
 			compatible = "snps,archs38";
 			reg = <0>;
+			clocks = <&core_clk>;
 		};
 	};
 
diff --git a/arch/arc/boot/dts/skeleton_hs_idu.dtsi b/arch/arc/boot/dts/skeleton_hs_idu.dtsi
index 4c11079..662c5e0 100644
--- a/arch/arc/boot/dts/skeleton_hs_idu.dtsi
+++ b/arch/arc/boot/dts/skeleton_hs_idu.dtsi
@@ -21,6 +21,7 @@
 			device_type = "cpu";
 			compatible = "snps,archs38xN";
 			reg = <0>;
+			clocks = <&core_clk>;
 		};
 	};
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] ARC: [dts] add cpu nodes to ARCHS SMP device tree
  2017-03-03 11:29 [PATCH 0/3] ARC: get frequency via clock driver instead of reading device tree Vlad Zakharov
  2017-03-03 11:30 ` [PATCH 1/3] ARC: [dts] add input clocks for cpu nodes Vlad Zakharov
@ 2017-03-03 11:30 ` Vlad Zakharov
  2017-03-03 11:30 ` [PATCH 3/3] arc: get rate from clk driver instead of reading " Vlad Zakharov
  2017-03-05  0:07 ` [PATCH 0/3] ARC: get frequency via clock " Vineet Gupta
  3 siblings, 0 replies; 5+ messages in thread
From: Vlad Zakharov @ 2017-03-03 11:30 UTC (permalink / raw)
  To: linux-snps-arc
  Cc: devicetree, linux-kernel, Vineet Gupta, Rob Herring, Vlad Zakharov

Trying to get clock for CPU cores on SMP systems I found that I was only
able to get clock for core[0]. That was because only one cpu@0 node was
represented in ARC HS device tree and it was impossible to get clock for
"non-existing" cores.

So as ARC HS may have up to 4 cores we update device tree to match
maximum possible cores quantity.

Signed-off-by: Vlad Zakharov <vzakhar@synopsys.com>
---
 arch/arc/boot/dts/skeleton_hs_idu.dtsi | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/arch/arc/boot/dts/skeleton_hs_idu.dtsi b/arch/arc/boot/dts/skeleton_hs_idu.dtsi
index 662c5e0..54b277d 100644
--- a/arch/arc/boot/dts/skeleton_hs_idu.dtsi
+++ b/arch/arc/boot/dts/skeleton_hs_idu.dtsi
@@ -19,10 +19,28 @@
 
 		cpu@0 {
 			device_type = "cpu";
-			compatible = "snps,archs38xN";
+			compatible = "snps,archs38";
 			reg = <0>;
 			clocks = <&core_clk>;
 		};
+		cpu@1 {
+			device_type = "cpu";
+			compatible = "snps,archs38";
+			reg = <1>;
+			clocks = <&core_clk>;
+		};
+		cpu@2 {
+			device_type = "cpu";
+			compatible = "snps,archs38";
+			reg = <2>;
+			clocks = <&core_clk>;
+		};
+		cpu@3 {
+			device_type = "cpu";
+			compatible = "snps,archs38";
+			reg = <3>;
+			clocks = <&core_clk>;
+		};
 	};
 
 	/* TIMER0 with interrupt for clockevent */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] arc: get rate from clk driver instead of reading device tree
  2017-03-03 11:29 [PATCH 0/3] ARC: get frequency via clock driver instead of reading device tree Vlad Zakharov
  2017-03-03 11:30 ` [PATCH 1/3] ARC: [dts] add input clocks for cpu nodes Vlad Zakharov
  2017-03-03 11:30 ` [PATCH 2/3] ARC: [dts] add cpu nodes to ARCHS SMP device tree Vlad Zakharov
@ 2017-03-03 11:30 ` Vlad Zakharov
  2017-03-05  0:07 ` [PATCH 0/3] ARC: get frequency via clock " Vineet Gupta
  3 siblings, 0 replies; 5+ messages in thread
From: Vlad Zakharov @ 2017-03-03 11:30 UTC (permalink / raw)
  To: linux-snps-arc
  Cc: devicetree, linux-kernel, Vineet Gupta, Rob Herring, Vlad Zakharov

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 | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c
index 3093fa8..fa62404 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,8 +489,9 @@ 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");
-	u32 freq = 0;
+	struct device *cpu_dev = get_cpu_device(cpu_id);
+	struct clk *cpu_clk;
+	unsigned long freq = 0;
 
 	if (!cpu_online(cpu_id)) {
 		seq_printf(m, "processor [%d]\t: Offline\n", cpu_id);
@@ -502,9 +504,15 @@ 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);
+	cpu_clk = clk_get(cpu_dev, NULL);
+	if (IS_ERR(cpu_clk)) {
+		seq_printf(m, "CPU speed \t: Cannot get clock for processor [%d]\n",
+			   cpu_id);
+	} else {
+		freq = clk_get_rate(cpu_clk);
+	}
 	if (freq)
-		seq_printf(m, "CPU speed\t: %u.%02u Mhz\n",
+		seq_printf(m, "CPU speed\t: %lu.%02lu Mhz\n",
 			   freq / 1000000, (freq / 10000) % 100);
 
 	seq_printf(m, "Bogo MIPS\t: %lu.%02lu\n",
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] ARC: get frequency via clock driver instead of reading device tree
  2017-03-03 11:29 [PATCH 0/3] ARC: get frequency via clock driver instead of reading device tree Vlad Zakharov
                   ` (2 preceding siblings ...)
  2017-03-03 11:30 ` [PATCH 3/3] arc: get rate from clk driver instead of reading " Vlad Zakharov
@ 2017-03-05  0:07 ` Vineet Gupta
  3 siblings, 0 replies; 5+ messages in thread
From: Vineet Gupta @ 2017-03-05  0:07 UTC (permalink / raw)
  To: Vlad Zakharov, linux-snps-arc
  Cc: devicetree, Vineet Gupta, linux-kernel, Rob Herring

On 03/03/2017 03:29 AM, Vlad Zakharov wrote:
> This patch series replaces reading device tree with getting CPU
> clock frequency via clock driver in show_cpuinfo function.
> 
> In order to achieve this we also add cpu nodes to device tree which
> describes SMP system and add "clocks" properties to all ARC cpu nodes. 

Series seems sane to me - will give it a spin next week before adding for 4.11

Thx,
-Vieet


> Vlad Zakharov (3):
>   ARC: [dts] add input clocks for cpu nodes
>   ARC: [dts] add cpu nodes to ARCHS SMP device tree
>   arc: get rate from clk driver instead of reading device tree
> 
>  arch/arc/boot/dts/skeleton.dtsi        |  1 +
>  arch/arc/boot/dts/skeleton_hs.dtsi     |  1 +
>  arch/arc/boot/dts/skeleton_hs_idu.dtsi | 21 ++++++++++++++++++++-
>  arch/arc/kernel/setup.c                | 17 +++++++++++++----
>  4 files changed, 35 insertions(+), 5 deletions(-)
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-03-05  0:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-03 11:29 [PATCH 0/3] ARC: get frequency via clock driver instead of reading device tree Vlad Zakharov
2017-03-03 11:30 ` [PATCH 1/3] ARC: [dts] add input clocks for cpu nodes Vlad Zakharov
2017-03-03 11:30 ` [PATCH 2/3] ARC: [dts] add cpu nodes to ARCHS SMP device tree Vlad Zakharov
2017-03-03 11:30 ` [PATCH 3/3] arc: get rate from clk driver instead of reading " Vlad Zakharov
2017-03-05  0:07 ` [PATCH 0/3] ARC: get frequency via clock " Vineet Gupta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).