From 416f78df05ac7f5ac0e7fa30e3ee757399866b27 Mon Sep 17 00:00:00 2001 From: Mohamad Noor Alim Hussin Date: Thu, 11 Aug 2022 11:34:46 +0800 Subject: [PATCH] riscv/cpu: add more information to show on cpuinfo Signed-off-by: Mohamad Noor Alim Hussin --- arch/riscv/kernel/cpu.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c index 6d59e6906..2cc501657 100644 --- a/arch/riscv/kernel/cpu.c +++ b/arch/riscv/kernel/cpu.c @@ -102,14 +102,39 @@ static void c_stop(struct seq_file *m, void *v) { } +static unsigned int to_mhz(unsigned int num) +{ + return num/(1000*1000); +} + +static unsigned int to_kb(unsigned int num) +{ + return num/1024; +} + static int c_show(struct seq_file *m, void *v) { unsigned long cpu_id = (unsigned long)v - 1; struct device_node *node = of_get_cpu_node(cpu_id, NULL); const char *compat, *isa, *mmu; + const char *board, *cpu_name; + unsigned int icache, dcache, l2_cache; + unsigned int freq; + if (!of_property_read_string(node, "board", &board)) + seq_printf(m, "board name\t: %s\n", board); + if (!of_property_read_string(node, "cpu-name", &cpu_name)) + seq_printf(m, "cpu name\t: %s\n", cpu_name); seq_printf(m, "processor\t: %lu\n", cpu_id); seq_printf(m, "hart\t\t: %lu\n", cpuid_to_hartid_map(cpu_id)); + if (!of_property_read_u32(node, "clock-frequency", &freq)) + seq_printf(m, "cpu MHz\t\t: %u\n", to_mhz(freq)); + if (!of_property_read_u32(node, "i-cache-size", &icache)) + seq_printf(m, "i-cache-size\t: %u KB\n", to_kb(icache)); + if (!of_property_read_u32(node, "d-cache-size", &dcache)) + seq_printf(m, "d-cache-size \t: %u KB\n", to_kb(dcache)); + if (!of_property_read_u32(node, "l2-cache-size", &l2_cache)) + seq_printf(m, "l2-cache-size \t: %u KB\n", to_kb(l2_cache)); if (!of_property_read_string(node, "riscv,isa", &isa)) print_isa(m, isa); if (!of_property_read_string(node, "mmu-type", &mmu))