[SRU,Bionic/raspi2] arch/arm64: Add Revision, Serial, Model to cpuinfo
diff mbox series

Message ID 20191119111133.10601-1-juergh@canonical.com
State New
Headers show
Series
  • [SRU,Bionic/raspi2] arch/arm64: Add Revision, Serial, Model to cpuinfo
Related show

Commit Message

Juerg Haefliger Nov. 19, 2019, 11:11 a.m. UTC
From: Phil Elwell <phil@raspberrypi.org>

BugLink: https://bugs.launchpad.net/bugs/1823151

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
(cherry picked from commit 935eb6f9a31971ef5537ac5d1b62148f8bcbad2f rpi-4.19.y)
Signed-off-by: Juerg Haefliger <juergh@canonical.com>
---
 arch/arm64/kernel/cpuinfo.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

Comments

Paolo Pisati Nov. 20, 2019, 10:55 a.m. UTC | #1
On Tue, Nov 19, 2019 at 12:11:33PM +0100, Juerg Haefliger wrote:
> From: Phil Elwell <phil@raspberrypi.org>
> 
> BugLink: https://bugs.launchpad.net/bugs/1823151

Clean cherry pick.

Acked-by: Paolo Pisati <paolo.pisati@canonical.com>
You-Sheng Yang Nov. 20, 2019, 2:14 p.m. UTC | #2
Acked-By: You-Sheng Yang <vicamo.yang@canonical.com>

On 2019-11-19 19:11, Juerg Haefliger wrote:
> From: Phil Elwell <phil@raspberrypi.org>
> 
> BugLink: https://bugs.launchpad.net/bugs/1823151
> 
> Signed-off-by: Phil Elwell <phil@raspberrypi.org>
> (cherry picked from commit 935eb6f9a31971ef5537ac5d1b62148f8bcbad2f rpi-4.19.y)
> Signed-off-by: Juerg Haefliger <juergh@canonical.com>
> ---
>  arch/arm64/kernel/cpuinfo.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c
> index 1e2554543506..fe810a2e4738 100644
> --- a/arch/arm64/kernel/cpuinfo.c
> +++ b/arch/arm64/kernel/cpuinfo.c
> @@ -27,6 +27,7 @@
>  #include <linux/elf.h>
>  #include <linux/init.h>
>  #include <linux/kernel.h>
> +#include <linux/of_platform.h>
>  #include <linux/personality.h>
>  #include <linux/preempt.h>
>  #include <linux/printk.h>
> @@ -120,6 +121,10 @@ static int c_show(struct seq_file *m, void *v)
>  {
>  	int i, j;
>  	bool compat = personality(current->personality) == PER_LINUX32;
> +	struct device_node *np;
> +	const char *model;
> +	const char *serial;
> +	u32 revision;
>  
>  	for_each_online_cpu(i) {
>  		struct cpuinfo_arm64 *cpuinfo = &per_cpu(cpu_data, i);
> @@ -171,6 +176,26 @@ static int c_show(struct seq_file *m, void *v)
>  		seq_printf(m, "CPU revision\t: %d\n\n", MIDR_REVISION(midr));
>  	}
>  
> +	seq_printf(m, "Hardware\t: BCM2835\n");
> +
> +	np = of_find_node_by_path("/system");
> +	if (np) {
> +		if (!of_property_read_u32(np, "linux,revision", &revision))
> +			seq_printf(m, "Revision\t: %04x\n", revision);
> +		of_node_put(np);
> +	}
> +
> +	np = of_find_node_by_path("/");
> +	if (np) {
> +		if (!of_property_read_string(np, "serial-number",
> +					     &serial))
> +			seq_printf(m, "Serial\t\t: %s\n", serial);
> +		if (!of_property_read_string(np, "model",
> +					     &model))
> +			seq_printf(m, "Model\t\t: %s\n", model);
> +		of_node_put(np);
> +	}
> +
>  	return 0;
>  }
>  
>
Khalid Elmously Nov. 22, 2019, 1:59 a.m. UTC | #3
On 2019-11-19 12:11:33 , Juerg Haefliger wrote:
> From: Phil Elwell <phil@raspberrypi.org>
> 
> BugLink: https://bugs.launchpad.net/bugs/1823151
> 
> Signed-off-by: Phil Elwell <phil@raspberrypi.org>
> (cherry picked from commit 935eb6f9a31971ef5537ac5d1b62148f8bcbad2f rpi-4.19.y)
> Signed-off-by: Juerg Haefliger <juergh@canonical.com>
> ---
>  arch/arm64/kernel/cpuinfo.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c
> index 1e2554543506..fe810a2e4738 100644
> --- a/arch/arm64/kernel/cpuinfo.c
> +++ b/arch/arm64/kernel/cpuinfo.c
> @@ -27,6 +27,7 @@
>  #include <linux/elf.h>
>  #include <linux/init.h>
>  #include <linux/kernel.h>
> +#include <linux/of_platform.h>
>  #include <linux/personality.h>
>  #include <linux/preempt.h>
>  #include <linux/printk.h>
> @@ -120,6 +121,10 @@ static int c_show(struct seq_file *m, void *v)
>  {
>  	int i, j;
>  	bool compat = personality(current->personality) == PER_LINUX32;
> +	struct device_node *np;
> +	const char *model;
> +	const char *serial;
> +	u32 revision;
>  
>  	for_each_online_cpu(i) {
>  		struct cpuinfo_arm64 *cpuinfo = &per_cpu(cpu_data, i);
> @@ -171,6 +176,26 @@ static int c_show(struct seq_file *m, void *v)
>  		seq_printf(m, "CPU revision\t: %d\n\n", MIDR_REVISION(midr));
>  	}
>  
> +	seq_printf(m, "Hardware\t: BCM2835\n");
> +
> +	np = of_find_node_by_path("/system");
> +	if (np) {
> +		if (!of_property_read_u32(np, "linux,revision", &revision))
> +			seq_printf(m, "Revision\t: %04x\n", revision);
> +		of_node_put(np);
> +	}
> +
> +	np = of_find_node_by_path("/");
> +	if (np) {
> +		if (!of_property_read_string(np, "serial-number",
> +					     &serial))
> +			seq_printf(m, "Serial\t\t: %s\n", serial);
> +		if (!of_property_read_string(np, "model",
> +					     &model))
> +			seq_printf(m, "Model\t\t: %s\n", model);
> +		of_node_put(np);
> +	}
> +
>  	return 0;
>  }
>  
> -- 
> 2.20.1
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team

Patch
diff mbox series

diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c
index 1e2554543506..fe810a2e4738 100644
--- a/arch/arm64/kernel/cpuinfo.c
+++ b/arch/arm64/kernel/cpuinfo.c
@@ -27,6 +27,7 @@ 
 #include <linux/elf.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/of_platform.h>
 #include <linux/personality.h>
 #include <linux/preempt.h>
 #include <linux/printk.h>
@@ -120,6 +121,10 @@  static int c_show(struct seq_file *m, void *v)
 {
 	int i, j;
 	bool compat = personality(current->personality) == PER_LINUX32;
+	struct device_node *np;
+	const char *model;
+	const char *serial;
+	u32 revision;
 
 	for_each_online_cpu(i) {
 		struct cpuinfo_arm64 *cpuinfo = &per_cpu(cpu_data, i);
@@ -171,6 +176,26 @@  static int c_show(struct seq_file *m, void *v)
 		seq_printf(m, "CPU revision\t: %d\n\n", MIDR_REVISION(midr));
 	}
 
+	seq_printf(m, "Hardware\t: BCM2835\n");
+
+	np = of_find_node_by_path("/system");
+	if (np) {
+		if (!of_property_read_u32(np, "linux,revision", &revision))
+			seq_printf(m, "Revision\t: %04x\n", revision);
+		of_node_put(np);
+	}
+
+	np = of_find_node_by_path("/");
+	if (np) {
+		if (!of_property_read_string(np, "serial-number",
+					     &serial))
+			seq_printf(m, "Serial\t\t: %s\n", serial);
+		if (!of_property_read_string(np, "model",
+					     &model))
+			seq_printf(m, "Model\t\t: %s\n", model);
+		of_node_put(np);
+	}
+
 	return 0;
 }