summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Vasut <marek.vasut@mailbox.org>2025-10-23 23:48:26 +0200
committerTom Rini <trini@konsulko.com>2025-11-17 10:45:11 -0600
commit96b66742a99ac22f812536ff89efda90f7f09d8c (patch)
tree066d58db5d53d62909bf3556c95fd203d8a6a5c0
parentf37f0dc8e9b56c1566d654eed3ab169e3d7ab955 (diff)
ARM: stm32: Add MAC address readout from fuses on DH STM32MP1 DHSOM
Add support for reading out the MAC address from SoC fuses on DH STM32MP1 DHSOM. The DH STM32MP1 DHSOM may contain external ethernet MACs, which benefit from the MAC address stored in SoC fuses as well, handle those consistently. This however means the architecture setup_mac_address() cannot be used and instead a simpler local fuse read out is implemented in the board file. Signed-off-by: Marek Vasut <marek.vasut@mailbox.org> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
-rw-r--r--board/dhelectronics/dh_stm32mp1/board.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c
index 065d2f338c2..c18f1911fe4 100644
--- a/board/dhelectronics/dh_stm32mp1/board.c
+++ b/board/dhelectronics/dh_stm32mp1/board.c
@@ -119,6 +119,29 @@ static bool dh_stm32_mac_is_in_ks8851(void)
return false;
}
+static int dh_stm32_get_mac_from_fuse(unsigned char *enetaddr, int index)
+{
+ struct udevice *dev;
+ u8 otp[12];
+ int ret;
+
+ ret = uclass_get_device_by_driver(UCLASS_MISC,
+ DM_DRIVER_GET(stm32mp_bsec),
+ &dev);
+ if (ret)
+ return ret;
+
+ ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_MAC), otp, sizeof(otp));
+ if (ret < 0)
+ return ret;
+
+ memcpy(enetaddr, otp + ARP_HLEN * index, ARP_HLEN);
+ if (!is_valid_ethaddr(enetaddr))
+ return -EINVAL;
+
+ return 0;
+}
+
static int dh_stm32_setup_ethaddr(struct eeprom_id_page *eip)
{
unsigned char enetaddr[6];
@@ -129,6 +152,9 @@ static int dh_stm32_setup_ethaddr(struct eeprom_id_page *eip)
if (dh_get_mac_is_enabled("ethernet0"))
return 0;
+ if (!dh_stm32_get_mac_from_fuse(enetaddr, 0))
+ goto out;
+
if (!dh_get_value_from_eeprom_buffer(DH_MAC0, enetaddr, sizeof(enetaddr), eip))
goto out;
@@ -154,6 +180,9 @@ static int dh_stm32_setup_eth1addr(struct eeprom_id_page *eip)
if (dh_stm32_mac_is_in_ks8851())
return 0;
+ if (!dh_stm32_get_mac_from_fuse(enetaddr, 1))
+ goto out;
+
if (!dh_get_value_from_eeprom_buffer(DH_MAC1, enetaddr, sizeof(enetaddr), eip))
goto out;