diff --git a/board/netmodule/imx8_nmhw23/imx8_nmhw23.c b/board/netmodule/imx8_nmhw23/imx8_nmhw23.c index d4e6f05562..d3bf86cdfd 100644 --- a/board/netmodule/imx8_nmhw23/imx8_nmhw23.c +++ b/board/netmodule/imx8_nmhw23/imx8_nmhw23.c @@ -31,9 +31,17 @@ #include "../../freescale/common/tcpc.h" #include #include +#include "../nm-common/board_descriptor.h" DECLARE_GLOBAL_DATA_PTR; + +#define BD_EEPROM_ADDR (0x50) +#define BD_ADDRESS (0x0000) +#define PD_ADDRESS (0x0200) + +static BD_Context bdctx[3]; + #define ESDHC_PAD_CTRL ((SC_PAD_CONFIG_NORMAL << PADRING_CONFIG_SHIFT) | (SC_PAD_ISO_OFF << PADRING_LPCONFIG_SHIFT) \ | (SC_PAD_28FDSOI_DSE_DV_HIGH << PADRING_DSE_SHIFT) | (SC_PAD_28FDSOI_PS_PU << PADRING_PULL_SHIFT)) @@ -195,6 +203,27 @@ int board_phy_config(struct phy_device *phydev) } #endif +static void set_mac_address(int index, uchar mac[6]) +{ + /* Then take mac from bd */ + if (is_valid_ethaddr(mac)) { + eth_env_set_enetaddr_by_index("eth", index, mac); + } + else { + printf("Trying to set invalid MAC address"); + } +} + +int board_eth_init(bd_t *bis) +{ + uint8_t mac_addr0[6] = {02,00,00,00,00,01}; + + bd_get_mac(0, mac_addr0, sizeof(mac_addr0)); + set_mac_address(0, mac_addr0); + + return 0; +} + int checkboard(void) { puts("Board: iMX8QXP MEK\n"); @@ -494,6 +523,27 @@ int board_mmc_get_env_dev(int devno) return devno; } +static int _bd_init(void) +{ + if (bd_get_context(&bdctx[0], BD_EEPROM_ADDR, BD_ADDRESS) != 0) { + printf("%s() no valid bd found\n", __func__); + return -1; + } + + if (bd_get_context(&bdctx[1], BD_EEPROM_ADDR, PD_ADDRESS) != 0) { + printf("%s() no valid pd found\n", __func__); + return -1; + } + + bd_register_context_list(bdctx, ARRAY_SIZE(bdctx)); + return 0; +} + +static inline int read_eeprom(void) +{ + return _bd_init(); +} + int board_late_init(void) { #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG @@ -510,5 +560,11 @@ int board_late_init(void) board_late_mmc_env_init(); #endif + if (read_eeprom() < 0) { + puts("Could no get board ID.\n"); + } + + board_eth_init(NULL); + return 0; }