b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | From 6ce4c2034f11fe1ba270637ebd5ba459c69e2b27 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 | @@ -128,6 +129,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 | @@ -179,6 +184,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 | |