From: Jonas Richardsen <jonasrichardsen@emlix.com>
To: barebox@lists.infradead.org
Cc: Jonas Richardsen <jonasrichardsen@emlix.com>
Subject: [PATCH 1/3] raspi: add fixup method for specific properties
Date: Mon, 22 Apr 2024 10:16:47 +0000 [thread overview]
Message-ID: <20240422102232.551842-2-jonasrichardsen@emlix.com> (raw)
In-Reply-To: <20240422102232.551842-1-jonasrichardsen@emlix.com>
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
next prev parent reply other threads:[~2024-04-22 10:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-22 10:16 [PATCH 0/3] raspi: cleanup of vc fixups Jonas Richardsen
2024-04-22 10:16 ` Jonas Richardsen [this message]
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 ` [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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240422102232.551842-2-jonasrichardsen@emlix.com \
--to=jonasrichardsen@emlix.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox