linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] ARM: Expose Raspberry Pi revision code in /proc/cpuinfo
@ 2024-07-07 23:08 Jonathan Neuschäfer
  2024-07-07 23:08 ` [PATCH 1/2] dt-bindings: arm: bcm2835: Specify /system/linux,revision property Jonathan Neuschäfer
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Jonathan Neuschäfer @ 2024-07-07 23:08 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Florian Fainelli,
	Broadcom internal kernel review list, Ray Jui, Scott Branden,
	Eric Anholt, Stefan Wahren, Russell King
  Cc: devicetree, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	Jonathan Neuschäfer

Raspberry Pi boards have a "revision code", documented here:

  https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#new-style-revision-codes

This patch copies what the downstream kernel does and reads it from the
devicetree property /system/linux,revision. This enables some software
to work as intended on mainline kernels:

  https://github.com/hzeller/rpi-rgb-led-matrix/blob/a3eea997a9254b83ab2de97ae80d83588f696387/lib/gpio.cc#L247

Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
---
Jonathan Neuschäfer (2):
      dt-bindings: arm: bcm2835: Specify /system/linux,revision property
      ARM: bcm2835: Detect system revision

 Documentation/devicetree/bindings/arm/bcm/bcm2835.yaml | 12 ++++++++++++
 arch/arm/mach-bcm/board_bcm2835.c                      | 11 +++++++++++
 2 files changed, 23 insertions(+)
---
base-commit: 22a40d14b572deb80c0648557f4bd502d7e83826
change-id: 20240707-raspi-revision-84dffdfaebce

Best regards,
--
Jonathan Neuschäfer <j.neuschaefer@gmx.net>



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] dt-bindings: arm: bcm2835: Specify /system/linux,revision property
  2024-07-07 23:08 [PATCH 0/2] ARM: Expose Raspberry Pi revision code in /proc/cpuinfo Jonathan Neuschäfer
@ 2024-07-07 23:08 ` Jonathan Neuschäfer
  2024-07-08 14:13   ` Krzysztof Kozlowski
  2024-07-07 23:08 ` [PATCH 2/2] ARM: bcm2835: Detect system revision Jonathan Neuschäfer
  2024-07-08 16:14 ` [PATCH 0/2] ARM: Expose Raspberry Pi revision code in /proc/cpuinfo Stefan Wahren
  2 siblings, 1 reply; 8+ messages in thread
From: Jonathan Neuschäfer @ 2024-07-07 23:08 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Florian Fainelli,
	Broadcom internal kernel review list, Ray Jui, Scott Branden,
	Eric Anholt, Stefan Wahren, Russell King
  Cc: devicetree, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	Jonathan Neuschäfer

The Raspberry Pi bootloader provides a revision code[0] in the
devicetree, at /system/linux,revision. This patch adds
/system/linux,revision to the schema to allow it to be used in
mainline Linux.

[0]: https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#new-style-revision-codes
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
---
 Documentation/devicetree/bindings/arm/bcm/bcm2835.yaml | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/bcm/bcm2835.yaml b/Documentation/devicetree/bindings/arm/bcm/bcm2835.yaml
index 162a39dab21823..c6abf818b5ea57 100644
--- a/Documentation/devicetree/bindings/arm/bcm/bcm2835.yaml
+++ b/Documentation/devicetree/bindings/arm/bcm/bcm2835.yaml
@@ -54,6 +54,18 @@ properties:
               - raspberrypi,model-zero-2-w
           - const: brcm,bcm2837

+  system:
+    type: object
+    additionalProperties: true
+    properties:
+
+      linux,revision:
+        $ref: /schemas/types.yaml#/definitions/string-array
+        description:
+          The "system revision" number, as determined by the bootloader.
+          https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#new-style-revision-codes
+
+
 additionalProperties: true

 ...

--
2.43.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] ARM: bcm2835: Detect system revision
  2024-07-07 23:08 [PATCH 0/2] ARM: Expose Raspberry Pi revision code in /proc/cpuinfo Jonathan Neuschäfer
  2024-07-07 23:08 ` [PATCH 1/2] dt-bindings: arm: bcm2835: Specify /system/linux,revision property Jonathan Neuschäfer
@ 2024-07-07 23:08 ` Jonathan Neuschäfer
  2024-07-08 16:14 ` [PATCH 0/2] ARM: Expose Raspberry Pi revision code in /proc/cpuinfo Stefan Wahren
  2 siblings, 0 replies; 8+ messages in thread
From: Jonathan Neuschäfer @ 2024-07-07 23:08 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Florian Fainelli,
	Broadcom internal kernel review list, Ray Jui, Scott Branden,
	Eric Anholt, Stefan Wahren, Russell King
  Cc: devicetree, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	Jonathan Neuschäfer

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@gmx.net>
---
 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



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] dt-bindings: arm: bcm2835: Specify /system/linux,revision property
  2024-07-07 23:08 ` [PATCH 1/2] dt-bindings: arm: bcm2835: Specify /system/linux,revision property Jonathan Neuschäfer
@ 2024-07-08 14:13   ` Krzysztof Kozlowski
  2024-07-09 19:52     ` J. Neuschäfer
  0 siblings, 1 reply; 8+ messages in thread
From: Krzysztof Kozlowski @ 2024-07-08 14:13 UTC (permalink / raw)
  To: Jonathan Neuschäfer, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Florian Fainelli,
	Broadcom internal kernel review list, Ray Jui, Scott Branden,
	Eric Anholt, Stefan Wahren, Russell King
  Cc: devicetree, linux-rpi-kernel, linux-arm-kernel, linux-kernel

On 08/07/2024 01:08, Jonathan Neuschäfer wrote:
> The Raspberry Pi bootloader provides a revision code[0] in the
> devicetree, at /system/linux,revision. This patch adds
> /system/linux,revision to the schema to allow it to be used in
> mainline Linux.

Sorry, no, we do not document stuff for various out of tree things.
Otherwise we would have to accept hundreds of ridiculous, vendor properties.

Fix your bootloader or make it upstream.

Best regards,
Krzysztof



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] ARM: Expose Raspberry Pi revision code in /proc/cpuinfo
  2024-07-07 23:08 [PATCH 0/2] ARM: Expose Raspberry Pi revision code in /proc/cpuinfo Jonathan Neuschäfer
  2024-07-07 23:08 ` [PATCH 1/2] dt-bindings: arm: bcm2835: Specify /system/linux,revision property Jonathan Neuschäfer
  2024-07-07 23:08 ` [PATCH 2/2] ARM: bcm2835: Detect system revision Jonathan Neuschäfer
@ 2024-07-08 16:14 ` Stefan Wahren
  2024-07-09 19:56   ` J. Neuschäfer
  2 siblings, 1 reply; 8+ messages in thread
From: Stefan Wahren @ 2024-07-08 16:14 UTC (permalink / raw)
  To: Jonathan Neuschäfer, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Florian Fainelli,
	Broadcom internal kernel review list, Ray Jui, Scott Branden,
	Eric Anholt, Russell King
  Cc: devicetree, linux-rpi-kernel, linux-arm-kernel, linux-kernel

Hi Jonathan,

Am 08.07.24 um 01:08 schrieb Jonathan Neuschäfer:
> Raspberry Pi boards have a "revision code", documented here:
>
>    https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#new-style-revision-codes
AFAIK these revision codes mostly refer to the board and not to the CPU.
The abuse of /proc/cpuinfo has been rejected in the past and from my
understanding this applies also in this case.
> This patch copies what the downstream kernel does and reads it from the
> devicetree property /system/linux,revision. This enables some software
> to work as intended on mainline kernels:
>
>    https://github.com/hzeller/rpi-rgb-led-matrix/blob/a3eea997a9254b83ab2de97ae80d83588f696387/lib/gpio.cc#L247
This is a bad example because the application doesn't really care about
the kernel and directly access the hardware registers via /dev/mem. A
proper application would use the dedicated userspace API (GPIO Character
Device or PWM). I would bet that the application does not work with the
Raspberry Pi 5.

Regards
>
> Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
> ---
> Jonathan Neuschäfer (2):
>        dt-bindings: arm: bcm2835: Specify /system/linux,revision property
>        ARM: bcm2835: Detect system revision
>
>   Documentation/devicetree/bindings/arm/bcm/bcm2835.yaml | 12 ++++++++++++
>   arch/arm/mach-bcm/board_bcm2835.c                      | 11 +++++++++++
>   2 files changed, 23 insertions(+)
> ---
> base-commit: 22a40d14b572deb80c0648557f4bd502d7e83826
> change-id: 20240707-raspi-revision-84dffdfaebce
>
> Best regards,
> --
> Jonathan Neuschäfer <j.neuschaefer@gmx.net>
>



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] dt-bindings: arm: bcm2835: Specify /system/linux,revision property
  2024-07-08 14:13   ` Krzysztof Kozlowski
@ 2024-07-09 19:52     ` J. Neuschäfer
  2024-10-10 22:51       ` Florian Fainelli
  0 siblings, 1 reply; 8+ messages in thread
From: J. Neuschäfer @ 2024-07-09 19:52 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Jonathan Neuschäfer, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Florian Fainelli,
	Broadcom internal kernel review list, Ray Jui, Scott Branden,
	Eric Anholt, Stefan Wahren, Russell King, devicetree,
	linux-rpi-kernel, linux-arm-kernel, linux-kernel

On Mon, Jul 08, 2024 at 04:13:10PM +0200, Krzysztof Kozlowski wrote:
> On 08/07/2024 01:08, Jonathan Neuschäfer wrote:
> > The Raspberry Pi bootloader provides a revision code[0] in the
> > devicetree, at /system/linux,revision. This patch adds
> > /system/linux,revision to the schema to allow it to be used in
> > mainline Linux.
>
> Sorry, no, we do not document stuff for various out of tree things.
> Otherwise we would have to accept hundreds of ridiculous, vendor properties.

Fair enough.

> Fix your bootloader or make it upstream.

There is no open source upstream for this bootloader. It is (sadly)
Broadcom's own proprietary code.

Not sure what fixing it would entail.


Jonathan


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] ARM: Expose Raspberry Pi revision code in /proc/cpuinfo
  2024-07-08 16:14 ` [PATCH 0/2] ARM: Expose Raspberry Pi revision code in /proc/cpuinfo Stefan Wahren
@ 2024-07-09 19:56   ` J. Neuschäfer
  0 siblings, 0 replies; 8+ messages in thread
From: J. Neuschäfer @ 2024-07-09 19:56 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Jonathan Neuschäfer, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Florian Fainelli,
	Broadcom internal kernel review list, Ray Jui, Scott Branden,
	Eric Anholt, Russell King, devicetree, linux-rpi-kernel,
	linux-arm-kernel, linux-kernel

On Mon, Jul 08, 2024 at 06:14:01PM +0200, Stefan Wahren wrote:
> Hi Jonathan,
>
> Am 08.07.24 um 01:08 schrieb Jonathan Neuschäfer:
> > Raspberry Pi boards have a "revision code", documented here:
> >
> >    https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#new-style-revision-codes
> AFAIK these revision codes mostly refer to the board and not to the CPU.

True.

> The abuse of /proc/cpuinfo has been rejected in the past and from my
> understanding this applies also in this case.

Alright

> > This patch copies what the downstream kernel does and reads it from the
> > devicetree property /system/linux,revision. This enables some software
> > to work as intended on mainline kernels:
> >
> >    https://github.com/hzeller/rpi-rgb-led-matrix/blob/a3eea997a9254b83ab2de97ae80d83588f696387/lib/gpio.cc#L247
> This is a bad example because the application doesn't really care about
> the kernel and directly access the hardware registers via /dev/mem. A
> proper application would use the dedicated userspace API (GPIO Character
> Device or PWM).

Right

> I would bet that the application does not work with the Raspberry Pi 5.

Probably, yeah.


Jonathan


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] dt-bindings: arm: bcm2835: Specify /system/linux,revision property
  2024-07-09 19:52     ` J. Neuschäfer
@ 2024-10-10 22:51       ` Florian Fainelli
  0 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2024-10-10 22:51 UTC (permalink / raw)
  To: J. Neuschäfer, Krzysztof Kozlowski
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Broadcom internal kernel review list, Ray Jui, Scott Branden,
	Eric Anholt, Stefan Wahren, Russell King, devicetree,
	linux-rpi-kernel, linux-arm-kernel, linux-kernel

On 7/9/24 12:52, J. Neuschäfer wrote:
> On Mon, Jul 08, 2024 at 04:13:10PM +0200, Krzysztof Kozlowski wrote:
>> On 08/07/2024 01:08, Jonathan Neuschäfer wrote:
>>> The Raspberry Pi bootloader provides a revision code[0] in the
>>> devicetree, at /system/linux,revision. This patch adds
>>> /system/linux,revision to the schema to allow it to be used in
>>> mainline Linux.
>>
>> Sorry, no, we do not document stuff for various out of tree things.
>> Otherwise we would have to accept hundreds of ridiculous, vendor properties.
> 
> Fair enough.
> 
>> Fix your bootloader or make it upstream.
> 
> There is no open source upstream for this bootloader. It is (sadly)
> Broadcom's own proprietary code.

We have plenty of proprietary code all over the place, but that one is 
not ours, it's Raspberry Pi's own, FWIW.
-- 
Florian


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-10-10 22:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-07 23:08 [PATCH 0/2] ARM: Expose Raspberry Pi revision code in /proc/cpuinfo Jonathan Neuschäfer
2024-07-07 23:08 ` [PATCH 1/2] dt-bindings: arm: bcm2835: Specify /system/linux,revision property Jonathan Neuschäfer
2024-07-08 14:13   ` Krzysztof Kozlowski
2024-07-09 19:52     ` J. Neuschäfer
2024-10-10 22:51       ` Florian Fainelli
2024-07-07 23:08 ` [PATCH 2/2] ARM: bcm2835: Detect system revision Jonathan Neuschäfer
2024-07-08 16:14 ` [PATCH 0/2] ARM: Expose Raspberry Pi revision code in /proc/cpuinfo Stefan Wahren
2024-07-09 19:56   ` J. Neuschäfer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).