From: Oleksij Rempel <o.rempel@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Subject: [PATCH v4 5/8] ARM: boards: skov-imx6: fixup different DTS variants
Date: Wed, 6 Oct 2021 10:43:20 +0200 [thread overview]
Message-ID: <20211006084323.14051-6-o.rempel@pengutronix.de> (raw)
In-Reply-To: <20211006084323.14051-1-o.rempel@pengutronix.de>
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
arch/arm/boards/skov-imx6/board.c | 48 +++++++++++++++++++++++++++----
1 file changed, 43 insertions(+), 5 deletions(-)
diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
index f42a0cad00..c09a2cd898 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -390,13 +390,51 @@ static void skov_imx6_no_switch(struct device_node *root)
}
}
+static int skov_imx6_switch_port(struct device_node *root, const char *path)
+{
+ size_t size;
+ char *buf;
+ int ret;
+
+ /* size is, string + '\0' + port number */
+ size = strlen(path) + 2;
+ buf = xzalloc(size);
+ if (!buf)
+ return -ENOMEM;
+
+ ret = snprintf(buf, size, "%s0", path);
+ if (ret < 0)
+ return ret;
+
+ ret = eth_of_fixup_node_from_eth_device(root, buf, "eth0");
+ if (ret)
+ return ret;
+
+ ret = snprintf(buf, size, "%s1", path);
+ if (ret < 0)
+ return ret;
+
+ ret = eth2_of_fixup_node_individually(root, buf, "eth0",
+ "state.ethaddr.eth2",
+ "/state/ethaddr/eth2");
+ return ret;
+}
+
static void skov_imx6_switch(struct device_node *root)
{
- eth_of_fixup_node_from_eth_device(root,
- "/mdio-gpio/ksz8873@3/ports/ports@0", "eth0");
- eth2_of_fixup_node_individually(root,
- "/mdio-gpio/ksz8873@3/ports/ports@1", "eth0",
- "state.ethaddr.eth2", "/state/ethaddr/eth2");
+ const char *old = "/mdio-gpio/ksz8873@3/ports/ports@";
+ const char *new = "/mdio/switch@0/ports/ports@";
+ int ret;
+
+ /* Old DTS variants (pre kernel mainline) use different path. Try first
+ * the new variant, then fall back to the old one.
+ */
+ ret = skov_imx6_switch_port(root, new);
+ if (ret) {
+ ret = skov_imx6_switch_port(root, old);
+ if (ret)
+ pr_err("Filed to set mac address\n");
+ }
}
static int skov_imx6_fixup(struct device_node *root, void *unused)
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2021-10-06 8:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-06 8:43 [PATCH v4 0/8] add noswitch support for skov boards Oleksij Rempel
2021-10-06 8:43 ` [PATCH v4 1/8] ARM: dts: skov-imx6: add USB nodes Oleksij Rempel
2021-10-06 8:43 ` [PATCH v4 2/8] ARM: boards: skov-imx6: fixup_machine_compatible() add optional root node Oleksij Rempel
2021-10-06 8:43 ` [PATCH v4 3/8] ARM: boards: skov-imx6: add switch detection Oleksij Rempel
2021-10-06 8:43 ` [PATCH v4 4/8] ARM: boards: skov-imx6: disable eth0 for barebox if no switch is detected Oleksij Rempel
2021-10-06 8:43 ` Oleksij Rempel [this message]
2021-10-06 8:43 ` [PATCH v4 6/8] ARM: boards: skov-imx6: start using deep-probe Oleksij Rempel
2021-10-06 8:43 ` [PATCH v4 7/8] ARM: boards: skov-imx6: add defaultenv with eth1-discover script Oleksij Rempel
2021-10-06 8:43 ` [PATCH v4 8/8] ARM: boards: skov-imx6: use separate DTS for the iMX6 Solo variant Oleksij Rempel
2021-10-11 9:36 ` [PATCH v4 0/8] add noswitch support for skov boards 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=20211006084323.14051-6-o.rempel@pengutronix.de \
--to=o.rempel@pengutronix.de \
--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