public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] board: dhelectronics: imx: Use second Ethernet MAC also from fuse
@ 2026-03-20 10:29 Christoph Niedermaier
  2026-03-20 13:41 ` Peng Fan (OSS)
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Christoph Niedermaier @ 2026-03-20 10:29 UTC (permalink / raw)
  To: u-boot
  Cc: Christoph Niedermaier, Marek Vasut, Patrice Chotard, Peng Fan,
	Sam Protsenko, Tom Rini, u-boot

When two Ethernet MAC addresses are fused, the first MAC address
is incremented by one and used for the second MAC address. This
causes the second fused MAC address to be ignored. Change this
so that the second fused MAC address will be used.
Keep the old behavior if there isn't any second Ethernet MAC
defined and only the first MAC address is fused but not the
second. In this case use the fused MAC address incremented by
one, for the second MAC address.

Signed-off-by: Christoph Niedermaier <cniedermaier@dh-electronics.com>
---
Cc: Marek Vasut <marex@nabladev.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Sam Protsenko <semen.protsenko@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: u-boot@dh-electronics.com
---
 board/dhelectronics/common/dh_imx.c               |  4 ++--
 board/dhelectronics/common/dh_imx.h               |  3 ++-
 board/dhelectronics/dh_imx6/dh_imx6.c             |  2 +-
 board/dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c | 13 ++++++++++---
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/board/dhelectronics/common/dh_imx.c b/board/dhelectronics/common/dh_imx.c
index 3d6487dd0d8..308cdb5b002 100644
--- a/board/dhelectronics/common/dh_imx.c
+++ b/board/dhelectronics/common/dh_imx.c
@@ -10,13 +10,13 @@
 #include <net.h>
 #include "dh_imx.h"
 
-int dh_imx_get_mac_from_fuse(unsigned char *enetaddr)
+int dh_imx_get_mac_from_fuse(int dev_id, unsigned char *enetaddr)
 {
 	/*
 	 * If IIM fuses contain valid MAC address, use it.
 	 * The IIM MAC address fuses are NOT programmed by default.
 	 */
-	imx_get_mac_from_fuse(0, enetaddr);
+	imx_get_mac_from_fuse(dev_id, enetaddr);
 	if (!is_valid_ethaddr(enetaddr))
 		return -EINVAL;
 
diff --git a/board/dhelectronics/common/dh_imx.h b/board/dhelectronics/common/dh_imx.h
index 284f8637fb8..cb51a2f6eb2 100644
--- a/board/dhelectronics/common/dh_imx.h
+++ b/board/dhelectronics/common/dh_imx.h
@@ -6,7 +6,8 @@
 /*
  * dh_imx_get_mac_from_fuse - Get MAC address from fuse and write it to env
  *
+ * @dev_id: index of MAC address in fuse (starts with 0)
  * @enetaddr: buffer where address is to be stored
  * Return: 0 if OK, other value on error
  */
-int dh_imx_get_mac_from_fuse(unsigned char *enetaddr);
+int dh_imx_get_mac_from_fuse(int dev_id, unsigned char *enetaddr);
diff --git a/board/dhelectronics/dh_imx6/dh_imx6.c b/board/dhelectronics/dh_imx6/dh_imx6.c
index 234824b38c2..5806a03ed17 100644
--- a/board/dhelectronics/dh_imx6/dh_imx6.c
+++ b/board/dhelectronics/dh_imx6/dh_imx6.c
@@ -94,7 +94,7 @@ int dh_setup_mac_address(struct eeprom_id_page *eip)
 	if (dh_get_mac_is_enabled("ethernet0"))
 		return 0;
 
-	if (!dh_imx_get_mac_from_fuse(enetaddr))
+	if (!dh_imx_get_mac_from_fuse(0, enetaddr))
 		goto out;
 
 	if (!dh_get_mac_from_eeprom(enetaddr, "eeprom0"))
diff --git a/board/dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c b/board/dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c
index 5c35a5bf447..60d1e05b77f 100644
--- a/board/dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c
+++ b/board/dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c
@@ -50,7 +50,7 @@ static int dh_imx8_setup_ethaddr(struct eeprom_id_page *eip)
 	if (dh_get_mac_is_enabled("ethernet0"))
 		return 0;
 
-	if (!dh_imx_get_mac_from_fuse(enetaddr))
+	if (!dh_imx_get_mac_from_fuse(0, enetaddr))
 		goto out;
 
 	if (!dh_get_value_from_eeprom_buffer(DH_MAC0, enetaddr, sizeof(enetaddr), eip))
@@ -75,8 +75,8 @@ static int dh_imx8_setup_eth1addr(struct eeprom_id_page *eip)
 	if (dh_get_mac_is_enabled("ethernet1"))
 		return 0;
 
-	if (!dh_imx_get_mac_from_fuse(enetaddr))
-		goto increment_out;
+	if (!dh_imx_get_mac_from_fuse(1, enetaddr))
+		goto out;
 
 	if (!dh_get_value_from_eeprom_buffer(DH_MAC1, enetaddr, sizeof(enetaddr), eip))
 		goto out;
@@ -92,6 +92,13 @@ static int dh_imx8_setup_eth1addr(struct eeprom_id_page *eip)
 	if (!dh_get_mac_from_eeprom(enetaddr, "eeprom0"))
 		goto increment_out;
 
+	/*
+	 * If only the first MAC address is fused but not the second, use the
+	 * fused MAC address incremented by one, for the second MAC address.
+	 */
+	if (!dh_imx_get_mac_from_fuse(0, enetaddr))
+		goto increment_out;
+
 	return -ENXIO;
 
 increment_out:
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2026-03-31  9:19 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-20 10:29 [PATCH] board: dhelectronics: imx: Use second Ethernet MAC also from fuse Christoph Niedermaier
2026-03-20 13:41 ` Peng Fan (OSS)
2026-03-20 14:41   ` Christoph Niedermaier
2026-03-20 15:00 ` Peng Fan
2026-03-20 18:22 ` Marek Vasut
2026-03-21 20:55   ` Christoph Niedermaier
2026-03-21 23:40     ` Marek Vasut
2026-03-23 10:07       ` Christoph Niedermaier
2026-03-23 14:58         ` Marek Vasut
2026-03-23 16:49           ` Christoph Niedermaier
2026-03-23 17:20             ` Marek Vasut
2026-03-27 22:02               ` Christoph Niedermaier
2026-03-27 23:11                 ` Marek Vasut
2026-03-31  9:19                   ` Christoph Niedermaier
2026-03-23 17:34 ` Marek Vasut
2026-03-26 13:34   ` Christoph Niedermaier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox