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 1/2] raspi: support to read vc values via dt-2nd boot
Date: Mon, 25 Sep 2023 13:09:52 +0200	[thread overview]
Message-ID: <c5c2a899c801a86d67d8a5139eed8424143cd0ca.camel@gmail.com> (raw)
In-Reply-To: <20230925110716.5370-1-denis.osterland@gmail.com>

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

In case of boot via dt-2nd pbl does not copy dtb, because it is not
executed. With this patch the values were read and registered as
fix-ups. It also adds a inif function that only fix-ups the ethernet
MAC address.

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 | 30 ++++++++++++++---------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c
b/arch/arm/boards/raspberry-pi/rpi-common.c
index 56e7eebd61..ceafd55a56 100644
--- a/arch/arm/boards/raspberry-pi/rpi-common.c
+++ b/arch/arm/boards/raspberry-pi/rpi-common.c
@@ -110,6 +110,12 @@ static void rpi_add_led(void)
                led_set_trigger(LED_TRIGGER_HEARTBEAT, &l->led);
 }
 
+static int rpi_eth_init(struct rpi_priv *priv)
+{
+       rpi_set_usbethaddr();
+       return 0;
+}
+
 static int rpi_b_init(struct rpi_priv *priv)
 {
        rpi_leds[0].gpio = 16;
@@ -276,16 +282,12 @@ static u32 rpi_boot_mode, rpi_boot_part;
  * Some parameters are defined here:
  *
https://www.raspberrypi.com/documentation/computers/configuration.html#part4
  */
-static void rpi_vc_fdt_parse(void *fdt)
+static void rpi_vc_fdt_parse(struct device_node *root)
 {
        int ret;
-       struct device_node *root, *chosen, *bootloader, *memory;
+       struct device_node *chosen, *bootloader, *memory;
        char *str;
 
-       root = of_unflatten_dtb(fdt, INT_MAX);
-       if (IS_ERR(root))
-               return;
-
        str = of_read_vc_string(root, "serial-number");
        if (str) {
                barebox_set_serial_number(str);
@@ -363,7 +365,7 @@ static void rpi_vc_fdt_parse(void *fdt)
        return;
 }
 
-static void rpi_vc_fdt(void)
+static struct device_node *rpi_vc_fdt(void)
 {
        void *saved_vc_fdt;
        struct fdt_header *oftree;
@@ -379,17 +381,17 @@ static void rpi_vc_fdt(void)
                if (oftree->totalsize)
                        pr_err("there was an error copying fdt in pbl:
%dn",
                                        be32_to_cpu(oftree-
>totalsize));
-               return;
+               return ERR_PTR(-EINVAL);
        }
 
        if (magic != FDT_MAGIC)
-               return;
+               return ERR_PTR(-EINVAL);
 
        size = be32_to_cpu(oftree->totalsize);
        if (write_file("/vc.dtb", saved_vc_fdt, size))
                pr_err("failed to save videocore fdt to a filen");
 
-       rpi_vc_fdt_parse(saved_vc_fdt);
+       return of_unflatten_dtb(saved_vc_fdt, INT_MAX);
 }
 
 static void rpi_set_kernel_name(void) {
@@ -452,6 +454,7 @@ static int rpi_devices_probe(struct device *dev)
        const struct rpi_machine_data *dcfg;
        struct regulator *reg;
        struct rpi_priv *priv;
+       struct device_node *root;
        const char *name, *ptr;
        char *hostname;
        int ret;
@@ -480,7 +483,8 @@ static int rpi_devices_probe(struct device *dev)
        bcm2835_register_fb();
        armlinux_set_architecture(MACH_TYPE_BCM2708);
        rpi_env_init();
-       rpi_vc_fdt();
+       root = rpi_vc_fdt();
+       rpi_vc_fdt_parse(IS_ERR(root) ? priv->dev->device_node : root);
        rpi_set_kernel_name();
 
        if (dcfg && dcfg->init)
@@ -599,6 +603,7 @@ static const struct rpi_machine_data rpi_3_ids[] =
{
                .init = rpi_b_plus_init,
        }, {
                .hw_id = BCM2837_BOARD_REV_CM3,
+               .init = rpi_eth_init,
        }, {
                .hw_id = BCM2837B0_BOARD_REV_CM3_PLUS,
        }, {
@@ -611,10 +616,13 @@ static const struct rpi_machine_data rpi_3_ids[]
= {
 static const struct rpi_machine_data rpi_4_ids[] = {
        {
                .hw_id = BCM2711_BOARD_REV_4_B,
+               .init = rpi_eth_init,
        }, {
                .hw_id = BCM2711_BOARD_REV_400,
+               .init = rpi_eth_init,
        }, {
                .hw_id = BCM2711_BOARD_REV_CM4,
+               .init = rpi_eth_init,
        }, {
                .hw_id = U8_MAX
        },
-- 
2.39.2



       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 ` Denis Osterland-Heim [this message]
2023-09-25 11:10 ` [PATCH v2 2/2] raspi: fixup additional vc created nodes Denis Osterland-Heim
2024-02-19 19:14   ` 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=c5c2a899c801a86d67d8a5139eed8424143cd0ca.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