* [PATCH 1/3] raspi: add fixup method for specific properties
2024-04-22 10:16 [PATCH 0/3] raspi: cleanup of vc fixups Jonas Richardsen
@ 2024-04-22 10:16 ` Jonas Richardsen
2024-04-22 10:16 ` [PATCH 2/3] raspi: override properties in /reserved-memory node of device tree Jonas Richardsen
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Jonas Richardsen @ 2024-04-22 10:16 UTC (permalink / raw)
To: barebox; +Cc: Jonas Richardsen
Add `rpi_vc_property_fixup` method to allow for fixups of specific
properties, i.e., copy a property of some node from the video core
device tree. Notably, this does override the property if it already
existed (as opposed to `rpi_vc_fixup`, which copies an entire node, but
does not override existing properties).
Signed-off-by: Jonas Richardsen <jonasrichardsen@emlix.com>
---
arch/arm/boards/raspberry-pi/rpi-common.c | 46 +++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c
index 7c82c740e2..2245c36cbe 100644
--- a/arch/arm/boards/raspberry-pi/rpi-common.c
+++ b/arch/arm/boards/raspberry-pi/rpi-common.c
@@ -60,6 +60,11 @@ struct rpi_priv {
const char *name;
};
+struct rpi_property_fixup_data {
+ const struct device_node* vc_node;
+ const char *propname;
+};
+
static void rpi_set_usbethaddr(void)
{
u8 mac[ETH_ALEN];
@@ -301,6 +306,47 @@ static struct device_node *register_vc_fixup(struct device_node *root,
return ret;
}
+static int rpi_vc_fdt_fixup_property(struct device_node *root, void *data)
+{
+ const struct rpi_property_fixup_data *fixup = data;
+ struct device_node *node;
+ struct property *prop;
+
+ node = of_create_node(root, fixup->vc_node->full_name);
+ if (!node)
+ return -ENOMEM;
+
+ prop = of_find_property(fixup->vc_node, fixup->propname, NULL);
+ if (!prop)
+ return -ENOENT;
+
+ return of_set_property(node, prop->name,
+ of_property_get_value(prop), prop->length, 1);
+}
+
+static int register_vc_property_fixup(struct device_node *root,
+ const char *path, const char *propname)
+{
+ struct device_node *node, *tmp;
+ struct rpi_property_fixup_data* fixup_data;
+
+ node = of_find_node_by_path_from(root, path);
+ if (node) {
+ tmp = of_dup(node);
+ tmp->full_name = xstrdup(node->full_name);
+ fixup_data = xzalloc(sizeof(*fixup_data));
+ fixup_data->vc_node = tmp;
+ fixup_data->propname = xstrdup(propname);
+
+ of_register_fixup(rpi_vc_fdt_fixup_property, fixup_data);
+ } else {
+ pr_info("no '%s' node found in vc fdt\n", path);
+ return -ENOENT;
+ }
+
+ return 0;
+}
+
static u32 rpi_boot_mode, rpi_boot_part;
/* Extract useful information from the VideoCore FDT we got.
* Some parameters are defined here:
--
2.42.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/3] raspi: override properties in /reserved-memory node of device tree
2024-04-22 10:16 [PATCH 0/3] raspi: cleanup of vc fixups Jonas Richardsen
2024-04-22 10:16 ` [PATCH 1/3] raspi: add fixup method for specific properties Jonas Richardsen
@ 2024-04-22 10:16 ` Jonas Richardsen
2024-04-22 10:16 ` [PATCH 3/3] raspi: add a fixup for the `dma-ranges` property of the `/emmc2bus` dt node Jonas Richardsen
2024-04-23 8:34 ` [PATCH 0/3] raspi: cleanup of vc fixups Sascha Hauer
3 siblings, 0 replies; 5+ messages in thread
From: Jonas Richardsen @ 2024-04-22 10:16 UTC (permalink / raw)
To: barebox; +Cc: Jonas Richardsen
Previously, the fixups in rpi-common.c only tries to copy the
`/reserved-memory` node from the video core. As explained in
`bcm2711-rpi.dtsi`, line 58, the video core does only update the
placement information of the `/reserved-memory/nvram@0` subnode:
> /*
> * RPi4's co-processor will copy the board's bootloader configuration
> * into memory for the OS to consume. It'll also update this node with
> * its placement information.
> */
This behaviour is not achieved by the previous fixup, as this fixup
operates on the wrong node and, even if applied to
"/reserved-memory/nvram@0" would not override the already existing
properties of this node. Instead, we can use the previously added
`register_vc_property_fixup` method to achieve the desired behaviour.
Signed-off-by: Jonas Richardsen <jonasrichardsen@emlix.com>
---
arch/arm/boards/raspberry-pi/rpi-common.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c
index 2245c36cbe..3c685852d3 100644
--- a/arch/arm/boards/raspberry-pi/rpi-common.c
+++ b/arch/arm/boards/raspberry-pi/rpi-common.c
@@ -372,7 +372,8 @@ static void rpi_vc_fdt_parse(struct device_node *root)
register_vc_fixup(root, "/system");
register_vc_fixup(root, "/axi");
- register_vc_fixup(root, "/reserved-memory");
+ register_vc_property_fixup(root, "/reserved-memory/nvram@0", "reg");
+ register_vc_property_fixup(root, "/reserved-memory/nvram@0", "status");
register_vc_fixup(root, "/hat");
register_vc_fixup(root, "/chosen/bootloader");
chosen = register_vc_fixup(root, "/chosen");
--
2.42.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/3] raspi: add a fixup for the `dma-ranges` property of the `/emmc2bus` dt node
2024-04-22 10:16 [PATCH 0/3] raspi: cleanup of vc fixups Jonas Richardsen
2024-04-22 10:16 ` [PATCH 1/3] raspi: add fixup method for specific properties Jonas Richardsen
2024-04-22 10:16 ` [PATCH 2/3] raspi: override properties in /reserved-memory node of device tree Jonas Richardsen
@ 2024-04-22 10:16 ` Jonas Richardsen
2024-04-23 8:34 ` [PATCH 0/3] raspi: cleanup of vc fixups Sascha Hauer
3 siblings, 0 replies; 5+ messages in thread
From: Jonas Richardsen @ 2024-04-22 10:16 UTC (permalink / raw)
To: barebox; +Cc: Jonas Richardsen
As mentioned in `bcm2711.dtsi`, line 412, the `dma-ranges` property
of the `/emmc2bus` node is overridden by the video core firmware:
> /*
> * emmc2 has different DMA constraints based on SoC revisions. It was
> * moved into its own bus, so as for RPi4's firmware to update them.
> * The firmware will find whether the emmc2bus alias is defined, and if
> * so, it'll edit the dma-ranges property below accordingly.
> */
This change adds a fixup that copies the correct value of this property
from the video core device tree.
Signed-off-by: Jonas Richardsen <jonasrichardsen@emlix.com>
---
arch/arm/boards/raspberry-pi/rpi-common.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c
index 3c685852d3..04e1a899f1 100644
--- a/arch/arm/boards/raspberry-pi/rpi-common.c
+++ b/arch/arm/boards/raspberry-pi/rpi-common.c
@@ -375,6 +375,7 @@ static void rpi_vc_fdt_parse(struct device_node *root)
register_vc_property_fixup(root, "/reserved-memory/nvram@0", "reg");
register_vc_property_fixup(root, "/reserved-memory/nvram@0", "status");
register_vc_fixup(root, "/hat");
+ register_vc_property_fixup(root, "/emmc2bus", "dma-ranges");
register_vc_fixup(root, "/chosen/bootloader");
chosen = register_vc_fixup(root, "/chosen");
if (!chosen) {
--
2.42.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] raspi: cleanup of vc fixups
2024-04-22 10:16 [PATCH 0/3] raspi: cleanup of vc fixups Jonas Richardsen
` (2 preceding siblings ...)
2024-04-22 10:16 ` [PATCH 3/3] raspi: add a fixup for the `dma-ranges` property of the `/emmc2bus` dt node Jonas Richardsen
@ 2024-04-23 8:34 ` Sascha Hauer
3 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2024-04-23 8:34 UTC (permalink / raw)
To: barebox, Jonas Richardsen; +Cc: denis.osterland
On Mon, 22 Apr 2024 10:16:46 +0000, Jonas Richardsen wrote:
> This patch series contains a few changes to the video core fixups where
> the desired behaviour is obvious from raspberry device trees. These were
> tested on a Raspberry Pi 4B. There's a few more differences between the
> video core device tree and the one provided by barebox for which a
> discussion is welcome:
>
> - After a [recent change][link1] the `/chosen` node of the device tree
> is now fully copied from the video core device tree. This could
> possibly be restricted to only copy relevant properties.
> - The properties `memreserve` and `serial-number` of the root node are
> added by the video core and could also be copied.
> - The property `model` of the root node is updated with the specific
> hardware revision of the pi.
> - The video core adds the two aliases `i2c_arm` and `i2c_vc` (as
> properties to the `/aliases` node). As the [raspberrypi
> documentation][link2] suggests to use the former for writing overlays,
> it should maybe also be copied as a fixup.
>
> [...]
Applied, thanks!
[1/3] raspi: add fixup method for specific properties
https://git.pengutronix.de/cgit/barebox/commit/?id=dcb947764491 (link may not be stable)
[2/3] raspi: override properties in /reserved-memory node of device tree
https://git.pengutronix.de/cgit/barebox/commit/?id=3cf4417d0045 (link may not be stable)
[3/3] raspi: add a fixup for the `dma-ranges` property of the `/emmc2bus` dt node
https://git.pengutronix.de/cgit/barebox/commit/?id=3f9788433919 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 5+ messages in thread