bcm27xx: add support for linux v5.15
[openwrt/staging/chunkeey.git] / target / linux / bcm27xx / patches-5.15 / 950-0169-arch-arm64-Add-Revision-Serial-Model-to-cpuinfo.patch
1 From c1c1dc795330dc5f53396612c0e91a106d91ef99 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Tue, 3 Sep 2019 18:17:25 +0100
4 Subject: [PATCH] arch/arm64: Add Revision, Serial, Model to cpuinfo
5
6 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
7 ---
8 arch/arm64/kernel/cpuinfo.c | 25 +++++++++++++++++++++++++
9 1 file changed, 25 insertions(+)
10
11 --- a/arch/arm64/kernel/cpuinfo.c
12 +++ b/arch/arm64/kernel/cpuinfo.c
13 @@ -17,6 +17,7 @@
14 #include <linux/elf.h>
15 #include <linux/init.h>
16 #include <linux/kernel.h>
17 +#include <linux/of_platform.h>
18 #include <linux/personality.h>
19 #include <linux/preempt.h>
20 #include <linux/printk.h>
21 @@ -140,6 +141,10 @@ static int c_show(struct seq_file *m, vo
22 {
23 int i, j;
24 bool compat = personality(current->personality) == PER_LINUX32;
25 + struct device_node *np;
26 + const char *model;
27 + const char *serial;
28 + u32 revision;
29
30 for_each_online_cpu(i) {
31 struct cpuinfo_arm64 *cpuinfo = &per_cpu(cpu_data, i);
32 @@ -200,6 +205,26 @@ static int c_show(struct seq_file *m, vo
33 seq_printf(m, "CPU revision\t: %d\n\n", MIDR_REVISION(midr));
34 }
35
36 + seq_printf(m, "Hardware\t: BCM2835\n");
37 +
38 + np = of_find_node_by_path("/system");
39 + if (np) {
40 + if (!of_property_read_u32(np, "linux,revision", &revision))
41 + seq_printf(m, "Revision\t: %04x\n", revision);
42 + of_node_put(np);
43 + }
44 +
45 + np = of_find_node_by_path("/");
46 + if (np) {
47 + if (!of_property_read_string(np, "serial-number",
48 + &serial))
49 + seq_printf(m, "Serial\t\t: %s\n", serial);
50 + if (!of_property_read_string(np, "model",
51 + &model))
52 + seq_printf(m, "Model\t\t: %s\n", model);
53 + of_node_put(np);
54 + }
55 +
56 return 0;
57 }
58