The Raspberry Pi bootloader provides a revision code[0] in the devicetree, at /system/linux,revision. The downstream kernel then uses this DT property to fill the system_rev variable, which is exposed to userspace via the "Revision" field in /proc/cpuinfo. Some software[1] relies on this in order to determine the Raspberry Pi model. This patch ports the revision detection from the downstream Raspberry Pi kernel. [0]: https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#new-style-revision-codes [1]: https://github.com/hzeller/rpi-rgb-led-matrix/blob/a3eea997a9254b83ab2de97ae80d83588f696387/lib/gpio.cc#L247 Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@xxxxxxx> --- arch/arm/mach-bcm/board_bcm2835.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/arm/mach-bcm/board_bcm2835.c b/arch/arm/mach-bcm/board_bcm2835.c index bfc556f7672039..2a7b7ba3cd6c73 100644 --- a/arch/arm/mach-bcm/board_bcm2835.c +++ b/arch/arm/mach-bcm/board_bcm2835.c @@ -9,6 +9,7 @@ #include <asm/mach/arch.h> #include <asm/mach/map.h> +#include <asm/system_info.h> #include "platsmp.h" @@ -23,7 +24,17 @@ static const char * const bcm2835_compat[] = { NULL }; +static void __init bcm2835_init(void) +{ + struct device_node *np = of_find_node_by_path("/system"); + u32 val; + + if (!of_property_read_u32(np, "linux,revision", &val)) + system_rev = val; +} + DT_MACHINE_START(BCM2835, "BCM2835") .dt_compat = bcm2835_compat, .smp = smp_ops(bcm2836_smp_ops), + .init_machine = bcm2835_init, MACHINE_END -- 2.43.0