[PATCH 1/3] raspi: add fixup method for specific properties

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux