Skip to contentSkip to conversation

board: dhelectronics: imx: Use second Ethernet MAC also from fuse

PATCH Superseded Christoph Niedermaier 2 participants 3 messages Apr 2 – Apr 15

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Christoph Niedermaier

author maintainer
#0 lore raw

PATCH v2 1/1 board: dhelectronics: imx: Use second Ethernet MAC also from fuse

Currently, the board specific code evaluates only the first Ethernet MAC address fuse, regardless of whether the first or second MAC address is requested. When the function for determine the second Ethernet MAC address is looking for the fused MAC address, it only reads the first MAC address fuse and increment it by one to set the second Ethernet MAC address. That is not the expected behavior when two MAC addresses are fused, because this causes the second fused MAC address to be ignored. Change this so that the second fused MAC address will be used.

In addition, the handling of the MAC address for early prototypes will be removed, as such SoMs were not used by customers.

---
Cc: Marek Vasut <[email protected]>
Cc: Patrice Chotard <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Sam Protsenko <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
---
V2: - Change the commit message to be more precise
- Move index to the end of parameters to be consistent to the STM32MP plattform
- Remove fallback where the first MAC address fuse incremented by one is used
- Remove MAC Adress treatmeant for early prototypes

---
 board/dhelectronics/common/dh_imx.c             |  4 ++--
 board/dhelectronics/common/dh_imx.h             |  3 ++-
 board/dhelectronics/dh_imx6/dh_imx6.c           |  2 +-
 .../dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c | 17 +++--------------
 4 files changed, 8 insertions(+), 18 deletions(-)
board/dhelectronics/common/dh_imx.c +2 -2
index 3d6487dd0d8..50404a66f9d 100644
@@ -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(unsigned char *enetaddr, int index)
 {
 	/*
 	 * 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(index, enetaddr);
 	if (!is_valid_ethaddr(enetaddr))
 		return -EINVAL;
 
board/dhelectronics/common/dh_imx.h +2 -1
index 284f8637fb8..be2ff5e076c 100644
@@ -7,6 +7,7 @@
  * dh_imx_get_mac_from_fuse - Get MAC address from fuse and write it to env
  *
  * @enetaddr: buffer where address is to be stored
+ * @index: index of MAC address in fuse (starts with 0)
  * 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(unsigned char *enetaddr, int index);
board/dhelectronics/dh_imx6/dh_imx6.c +1 -1
index 234824b38c2..c9e8107685a 100644
@@ -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(enetaddr, 0))
 		goto out;
 
 	if (!dh_get_mac_from_eeprom(enetaddr, "eeprom0"))
board/dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c +3 -14
index 5c35a5bf447..a9153418314 100644
@@ -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(enetaddr, 0))
 		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(enetaddr, 1))
+		goto out;
 
 	if (!dh_get_value_from_eeprom_buffer(DH_MAC1, enetaddr, sizeof(enetaddr), eip))
 		goto out;
@@ -84,19 +84,8 @@ static int dh_imx8_setup_eth1addr(struct eeprom_id_page *eip)
 	if (!dh_get_mac_from_eeprom(enetaddr, "eeprom1"))
 		goto out;
 
-	/*
-	 * Populate second ethernet MAC from first ethernet EEPROM with MAC
-	 * address LSByte incremented by 1. This is only used on SoMs without
-	 * second ethernet EEPROM, i.e. early prototypes.
-	 */
-	if (!dh_get_mac_from_eeprom(enetaddr, "eeprom0"))
-		goto increment_out;
-
 	return -ENXIO;
 
-increment_out:
-	enetaddr[5]++;
-
 out:
 	return eth_env_set_enetaddr("eth1addr", enetaddr);
 }
Signature · 1 line
2.30.2
maintainer
#1 lore raw
Quoted 10 lines · Christoph Niedermaier

Currently, the board specific code evaluates only the first Ethernet MAC address fuse, regardless of whether the first or second MAC address is requested. When the function for determine the second Ethernet MAC address is looking for the fused MAC address, it only reads the first MAC address fuse and increment it by one to set the second Ethernet MAC address. That is not the expected behavior when two MAC addresses are fused, because this causes the second fused MAC address to be ignored. Change this so that the second fused MAC address will be used.

Quoted 2 lines

In addition, the handling of the MAC address for early prototypes will be removed, as such SoMs were not used by customers.

This ^ should be kept.

Quoted 2 lines

RB goes above SoB line

[...]

Quoted 10 lines
board/dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c +0 -6
@@ -84,19 +84,8 @@ static int dh_imx8_setup_eth1addr(struct eeprom_id_page *eip)
  	if (!dh_get_mac_from_eeprom(enetaddr, "eeprom1"))
  		goto out;
 
-	/*
-	 * Populate second ethernet MAC from first ethernet EEPROM with MAC
-	 * address LSByte incremented by 1. This is only used on SoMs without
-	 * second ethernet EEPROM, i.e. early prototypes.
-	 */
-	if (!dh_get_mac_from_eeprom(enetaddr, "eeprom0"))

board/dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c static int dh_imx8_setup_eth1addr(struct eeprom_id_page *eip) · line 91

Quoted 10 lines
board/dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c +0 -5
-		goto increment_out;
-
  	return -ENXIO;
 
-increment_out:
-	enetaddr[5]++;
-
  out:
  	return eth_env_set_enetaddr("eth1addr", enetaddr);
  }

Please keep this ^ hunk, the rest is fine, thank you.

author maintainer
#2 lore raw

From: Marek Vasut <[email protected]>
Sent: Friday, April 3, 2026 6:43 AM

Quoted 11 lines · Christoph Niedermaier
Quoted 10 lines

Currently, the board specific code evaluates only the first Ethernet MAC address fuse, regardless of whether the first or second MAC address is requested. When the function for determine the second Ethernet MAC address is looking for the fused MAC address, it only reads the first MAC address fuse and increment it by one to set the second Ethernet MAC address. That is not the expected behavior when two MAC addresses are fused, because this causes the second fused MAC address to be ignored. Change this so that the second fused MAC address will be used.

Quoted 4 lines
Quoted 2 lines

In addition, the handling of the MAC address for early prototypes will be removed, as such SoMs were not used by customers.

This ^ should be kept.

Will change this in V3.

Quoted 4 lines
Quoted 2 lines

RB goes above SoB line

Will fix it in V3.

Quoted 16 lines

[...]

Quoted 14 lines
board/dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c +0 -8
@@ -84,19 +84,8 @@ static int dh_imx8_setup_eth1addr(struct eeprom_id_page *eip)
      if (!dh_get_mac_from_eeprom(enetaddr, "eeprom1"))
              goto out;
 
-     /*
-      * Populate second ethernet MAC from first ethernet EEPROM with MAC
-      * address LSByte incremented by 1. This is only used on SoMs without
-      * second ethernet EEPROM, i.e. early prototypes.
-      */
-     if (!dh_get_mac_from_eeprom(enetaddr, "eeprom0"))
-             goto increment_out;
-
      return -ENXIO;
 
Quoted 8 lines

board/dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c static int dh_imx8_setup_eth1addr(struct eeprom_id_page *eip) · line 91

Quoted 6 lines
board/dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c +0 -3
-increment_out:
-     enetaddr[5]++;
-
  out:
      return eth_env_set_enetaddr("eth1addr", enetaddr);
  }

Please keep this ^ hunk, the rest is fine, thank you.

Will revert it in V3.

Regards
Christoph