mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Denis Osterland-Heim <denis.osterland@gmail.com>
To: barebox@lists.infradead.org
Cc: Denis OSTERLAND-HEIM <denis.osterland@diehl.com>,
	Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH v2 2/2] raspi: fixup additional vc created nodes
Date: Mon, 25 Sep 2023 13:10:05 +0200	[thread overview]
Message-ID: <6496b2cabc1ec6cec520ea27145d3cecdc19927c.camel@gmail.com> (raw)
In-Reply-To: <20230925110716.5370-1-denis.osterland@gmail.com>

From: Denis OSTERLAND-HEIM <denis.osterland@diehl.com>

The video core creates some additional nodes.
This code takes over this values.
The /hat node is only there if an raspi hat with EEPROM is detected.

Signed-off-by: Denis OSTERLAND-HEIM <denis.osterland@diehl.com>
Acked-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/boards/raspberry-pi/rpi-common.c | 39 +++++++++++++++++------
 1 file changed, 30 insertions(+), 9 deletions(-)

diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c
b/arch/arm/boards/raspberry-pi/rpi-common.c
index ceafd55a56..713fad78c9 100644
--- a/arch/arm/boards/raspberry-pi/rpi-common.c
+++ b/arch/arm/boards/raspberry-pi/rpi-common.c
@@ -264,19 +264,37 @@ static enum reset_src_type
rpi_decode_pm_rsts(struct device_node *chosen,
 
 static int rpi_vc_fdt_fixup(struct device_node *root, void *data)
 {
-       const struct device_node *vc_chosen = data;
-       struct device_node *chosen;
+       const struct device_node *vc_node = data;
+       struct device_node *node;
+       struct property *pp;
 
-       chosen = of_create_node(root, "/chosen");
-       if (!chosen)
+       node = of_create_node(root, vc_node->full_name);
+       if (!node)
                return -ENOMEM;
 
-       of_copy_property(vc_chosen, "overlay_prefix", chosen);
-       of_copy_property(vc_chosen, "os_prefix", chosen);
+       for_each_property_of_node(vc_node, pp)
+               of_copy_property(vc_node, pp->name, node);
 
        return 0;
 }
 
+static struct device_node *register_vc_fixup(struct device_node *root,
+                                            const char *path)
+{
+       struct device_node *ret, *tmp;
+
+       ret = of_find_node_by_path_from(root, path);
+       if (ret) {
+               tmp = of_dup(ret);
+               tmp->full_name = xstrdup(ret->full_name);
+               of_register_fixup(rpi_vc_fdt_fixup, tmp);
+       } else {
+               pr_info("no '%s' node found in vc fdtn", path);
+       }
+
+       return ret;
+}
+
 static u32 rpi_boot_mode, rpi_boot_part;
 /* Extract useful information from the VideoCore FDT we got.
  * Some parameters are defined here:
@@ -300,14 +318,17 @@ static void rpi_vc_fdt_parse(struct device_node
*root)
                free(str);
        }
 
-       chosen = of_find_node_by_path_from(root, "/chosen");
+       register_vc_fixup(root, "/system");
+       register_vc_fixup(root, "/axi");
+       register_vc_fixup(root, "/reserved-memory");
+       register_vc_fixup(root, "/hat");
+       register_vc_fixup(root, "/chosen/bootloader");
+       chosen = register_vc_fixup(root, "/chosen");
        if (!chosen) {
                pr_err("no '/chosen' node found in vc fdtn");
                goto out;
        }
 
-       of_register_fixup(rpi_vc_fdt_fixup, of_dup(chosen));
-
        bootloader = of_find_node_by_name(chosen, "bootloader");
 
        str = of_read_vc_string(chosen, "bootargs");
-- 
2.39.2



  parent reply	other threads:[~2023-09-25 11:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230925110716.5370-1-denis.osterland@gmail.com>
2023-09-25 11:09 ` [PATCH v2 1/2] raspi: support to read vc values via dt-2nd boot Denis Osterland-Heim
2023-09-25 11:10 ` Denis Osterland-Heim [this message]
2024-02-19 19:14   ` [PATCH v2 2/2] raspi: fixup additional vc created nodes Roland Hieber
2024-02-19 21:42     ` Ahmad Fatoum

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=6496b2cabc1ec6cec520ea27145d3cecdc19927c.camel@gmail.com \
    --to=denis.osterland@gmail.com \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=denis.osterland@diehl.com \
    /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