Skip to content

Commit

Permalink
drivers: ethernet: nxp_enet: Fused MAC address fixes
Browse files Browse the repository at this point in the history
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 <matthias.alleman@basalte.be>
(cherry picked from commit 931628a)
  • Loading branch information
allemanm authored and pdgendt committed Sep 10, 2024
1 parent 5c8d7b2 commit bc1462c
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions drivers/ethernet/nxp_enet/eth_nxp_enet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bc1462c

Please sign in to comment.