[PATCH v3 5/7] ARM: boards: skov-imx6: fixup different DTS variants
Oleksij Rempel
o.rempel at pengutronix.de
Mon Sep 20 04:15:26 PDT 2021
Signed-off-by: Oleksij Rempel <o.rempel at 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 4044bacb28..44c776f9cf 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -401,13 +401,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 at 3/ports/ports at 0", "eth0");
- eth2_of_fixup_node_individually(root,
- "/mdio-gpio/ksz8873 at 3/ports/ports at 1", "eth0",
- "state.ethaddr.eth2", "/state/ethaddr/eth2");
+ const char *old = "/mdio-gpio/ksz8873 at 3/ports/ports@";
+ const char *new = "/mdio/switch at 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
More information about the barebox
mailing list