2017-07-16 20:11:02

by Vesa Jääskeläinen

[permalink] [raw]
Subject: [RFC PATCH 0/2] device tree support for board revision

Privously without using device trees system revision was carried over ATAGs.
Now with device tree system revision information is not carried at all. This
RFC proposes a method for this.

With ARM arch system revision information (as 4 digit hex string) has been
available in /proc/cpuinfo.

Respective change is needed to boot loader to provide board revision. U-boot
provides board_rev environment variable that holds string version of board
revision information.

With BeagleBone Black I was able to get following /proc/cpuinfo output:

processor : 0
model name : ARMv7 Processor rev 2 (v7l)
BogoMIPS : 996.14
Features : half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpd32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x3
CPU part : 0xc08
CPU revision : 2

Hardware : Generic AM33XX (Flattened Device Tree)
Revision : 000B
Serial : 1614BBBK1211

Note: I set board_serial to serial# in u-boot to get serial number.

Reason why I deviced to go RFC approach was that there is kinda definition
problem here and possibilty that it might be a good idea to define more
than one field to device tree. Also there seems to be multiple ways that
people try to workaround the issues so it would be a good idea to
standardize the interfaces a bit.

One problem here is that what does actually those fields mean in
/proc/cpuinfo?

What does "Revision" mean? Does it mean board revision, device revision or
system revision?

Same goes for "Serial". Does it mean board serial, device serial or system
serial?

I see that "board" here would mean PCB or SoM module whose manufacturer
defines model name, serial number and revision.

Then we have "device" scope which I would see that it means PCB and chasis
of the device, and in chasis you might have label with information like
device model, serial number and revision. One device can consist of one or
more boards.

Then we have "system" scope which I would see that it means collection of
devices. System might have model and serial number (haven't seen one with
revision thou). It might be that "system" level is out-of-scope for device
tree interface level.

It may be that /proc/cpuinfo is wrong place to display this information but
as a result of this discussion I would like to see the standard way to pass
this information as it might be that bootloader can only access the
information (in case of multipurpose pin in chip). And the standard way for
user space to access this information.

Thanks,
Vesa Jääskeläinen

Vesa Jääskeläinen (2):
Documentation: devicetree: root node board-revision property
documentation
arm: setup: Show the board revision from devicetree in cpuinfo

Documentation/devicetree/booting-without-of.txt | 1 +
arch/arm/kernel/setup.c | 12 +++++++++++-
2 files changed, 12 insertions(+), 1 deletion(-)

--
2.1.4


2017-07-16 20:10:56

by Vesa Jääskeläinen

[permalink] [raw]
Subject: [RFC PATCH 2/2] arm: setup: Show the board revision from devicetree in cpuinfo

Get board revision information from devicetree's /board-revision property.

When using devicetree's board-revision property board revision will be
free form string as defined by device/SoM manufacturer.

In case it is not available fallback to using ATAGs and format it as 4
digit hex string as previously.

Signed-off-by: Vesa Jääskeläinen <[email protected]>
---
arch/arm/kernel/setup.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 4e80bf7..325604e 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -97,6 +97,8 @@ unsigned int __atags_pointer __initdata;
unsigned int system_rev;
EXPORT_SYMBOL(system_rev);

+static const char *board_revision;
+
const char *system_serial;
EXPORT_SYMBOL(system_serial);

@@ -940,6 +942,11 @@ static int __init init_machine_late(void)
&system_serial);
if (ret)
system_serial = NULL;
+
+ ret = of_property_read_string(root, "board-revision",
+ &board_revision);
+ if (ret)
+ board_revision = NULL;
}

if (!system_serial)
@@ -947,6 +954,9 @@ static int __init init_machine_late(void)
system_serial_high,
system_serial_low);

+ if (!board_revision)
+ board_revision = kasprintf(GFP_KERNEL, "%04x", system_rev);
+
return 0;
}
late_initcall(init_machine_late);
@@ -1271,7 +1281,7 @@ static int c_show(struct seq_file *m, void *v)
}

seq_printf(m, "Hardware\t: %s\n", machine_name);
- seq_printf(m, "Revision\t: %04x\n", system_rev);
+ seq_printf(m, "Revision\t: %s\n", board_revision);
seq_printf(m, "Serial\t\t: %s\n", system_serial);

return 0;
--
2.1.4

2017-07-16 20:11:10

by Vesa Jääskeläinen

[permalink] [raw]
Subject: [RFC PATCH 1/2] Documentation: devicetree: root node board-revision property documentation

Board revision is hardware revision for board. Meaning of hardware
revision is defined by device/SoM manufacturer and because of that it is
defined as a string.

Board revision information can be stored in hardware identifier resistors,
eFuses, EEPROM or some other device specific non-volatile storage. It is
expected that bootloader will analyse board revision information and pass
it in device tree to kernel.

Signed-off-by: Vesa Jääskeläinen <[email protected]>
---
Documentation/devicetree/booting-without-of.txt | 1 +
1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/booting-without-of.txt b/Documentation/devicetree/booting-without-of.txt
index fb74044..ae8f5ec 100644
--- a/Documentation/devicetree/booting-without-of.txt
+++ b/Documentation/devicetree/booting-without-of.txt
@@ -872,6 +872,7 @@ address which can extend beyond that limit.
Additional properties for the root node:

- serial-number : a string representing the device's serial number
+ - board-revision : a string representing the board's revision

b) The /cpus node

--
2.1.4