From 42bffa7eee6eb2f96ee6c25c4aedd8c6de967cdf Mon Sep 17 00:00:00 2001 From: Matthias Alleman Date: Mon, 8 Jul 2024 13:24:44 +0200 Subject: [PATCH] drivers: ethernet: nxp_enet: Fused MAC address fixes Add required initialisation of OCOTP. The IMXRT10XX variants don't support fuseWords to be greater than 1. MAC0 fuse map address is 0x22 instead of 0x620. Fill in mac_addr buffer correctly. Signed-off-by: Matthias Alleman (cherry picked from commit 931628a78a52ac1d10b562761896cd0aa4bfda8b) --- drivers/ethernet/nxp_enet/eth_nxp_enet.c | 25 ++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/ethernet/nxp_enet/eth_nxp_enet.c b/drivers/ethernet/nxp_enet/eth_nxp_enet.c index b1c592dea4d5b9..fa6e04d3db3754 100644 --- a/drivers/ethernet/nxp_enet/eth_nxp_enet.c +++ b/drivers/ethernet/nxp_enet/eth_nxp_enet.c @@ -634,20 +634,25 @@ static inline void nxp_enet_fused_mac(uint8_t *mac_addr) #ifdef CONFIG_SOC_FAMILY_NXP_IMXRT uint32_t mac_addr_fuse[2] = {0}; - OCOTP_ReadFuseShadowRegisterExt((OCOTP_Type *)OCOTP_BASE, #if defined(CONFIG_SOC_SERIES_IMXRT10XX) - 0x620, + OCOTP_Init((OCOTP_Type *)OCOTP_BASE, CLOCK_GetIpgFreq()); + /* OTP bank 4, word 2: MAC0 */ + OCOTP_ReadFuseShadowRegisterExt((OCOTP_Type *)OCOTP_BASE, + 0x22, &mac_addr_fuse[0], 1); + /* OTP bank 4, word 3: MAC1*/ + OCOTP_ReadFuseShadowRegisterExt((OCOTP_Type *)OCOTP_BASE, + 0x23, &mac_addr_fuse[1], 1); #elif defined(CONFIG_SOC_SERIES_IMXRT11XX) - 0xA90, + OCOTP_Init((OCOTP_Type *)OCOTP_BASE, 0); + OCOTP_ReadFuseShadowRegisterExt((OCOTP_Type *)OCOTP_BASE, + 0x28, &mac_addr_fuse[0], 2); #endif - mac_addr_fuse, 2); - mac_addr[0] = mac_addr_fuse[0] & 0x000000FF; - mac_addr[1] = mac_addr_fuse[0] & 0x0000FF00; - mac_addr[2] = mac_addr_fuse[0] & 0x00FF0000; - mac_addr[3] = mac_addr_fuse[0] & 0xFF000000; - mac_addr[4] = mac_addr_fuse[1] & 0x00FF; - mac_addr[5] = mac_addr_fuse[1] & 0xFF00; + mac_addr[1] = (mac_addr_fuse[0] & 0x0000FF00) >> 8; + mac_addr[2] = (mac_addr_fuse[0] & 0x00FF0000) >> 16; + mac_addr[3] = (mac_addr_fuse[0] & 0xFF000000) >> 24; + mac_addr[4] = (mac_addr_fuse[1] & 0x00FF); + mac_addr[5] = (mac_addr_fuse[1] & 0xFF00) >> 8; #else ARG_UNUSED(mac_addr); #endif