mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-12-20 00:41:29 +01:00
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>
This commit is contained in:
parent
f37f0dc8e9
commit
96b66742a9
@ -119,6 +119,29 @@ static bool dh_stm32_mac_is_in_ks8851(void)
|
|||||||
return false;
|
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)
|
static int dh_stm32_setup_ethaddr(struct eeprom_id_page *eip)
|
||||||
{
|
{
|
||||||
unsigned char enetaddr[6];
|
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"))
|
if (dh_get_mac_is_enabled("ethernet0"))
|
||||||
return 0;
|
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))
|
if (!dh_get_value_from_eeprom_buffer(DH_MAC0, enetaddr, sizeof(enetaddr), eip))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@ -154,6 +180,9 @@ static int dh_stm32_setup_eth1addr(struct eeprom_id_page *eip)
|
|||||||
if (dh_stm32_mac_is_in_ks8851())
|
if (dh_stm32_mac_is_in_ks8851())
|
||||||
return 0;
|
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))
|
if (!dh_get_value_from_eeprom_buffer(DH_MAC1, enetaddr, sizeof(enetaddr), eip))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user