summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Richardsen <jonasrichardsen@emlix.com>2024-04-22 10:16:47 +0000
committerSascha Hauer <s.hauer@pengutronix.de>2024-04-23 10:34:02 +0200
commitdcb947764491bb5691774cac1f1ab908b60148b2 (patch)
tree89cfb1517439e59d6e04b706feeafd9d6a781d4b
parent8028c9f2d56444a7aa0344ca50acda2ad3a8e387 (diff)
downloadbarebox-dcb947764491.tar.gz
barebox-dcb947764491.tar.xz
raspi: add fixup method for specific properties
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> Link: https://lore.barebox.org/20240422102232.551842-2-jonasrichardsen@emlix.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--arch/arm/boards/raspberry-pi/rpi-common.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c
index 924d4425bd..c56383bb6c 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];
@@ -302,6 +307,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: