From: Ye Li Date: Fri, 28 Apr 2023 04:08:21 +0000 (+0800) Subject: imx9: Change hard coded MAC to read from fuse X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=d0724433b538bcb9658541121a8af3685a2b8f25;p=u-boot.git imx9: Change hard coded MAC to read from fuse The MAC addresses are hard coded for bring up. Change it to support reading from fuse. Reviewed-by: Jacky Bai Signed-off-by: Ye Li Signed-off-by: Peng Fan --- diff --git a/arch/arm/mach-imx/imx9/soc.c b/arch/arm/mach-imx/imx9/soc.c index f02e9035dd..a884e0863f 100644 --- a/arch/arm/mach-imx/imx9/soc.c +++ b/arch/arm/mach-imx/imx9/soc.c @@ -30,6 +30,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -336,12 +337,48 @@ phys_size_t get_effective_memsize(void) void imx_get_mac_from_fuse(int dev_id, unsigned char *mac) { - mac[0] = 0x1; - mac[1] = 0x2; - mac[2] = 0x3; - mac[3] = 0x4; - mac[4] = 0x5; - mac[5] = 0x6; + u32 val[2] = {}; + int ret; + + if (dev_id == 0) { + ret = fuse_read(39, 3, &val[0]); + if (ret) + goto err; + + ret = fuse_read(39, 4, &val[1]); + if (ret) + goto err; + + mac[0] = val[1] >> 8; + mac[1] = val[1]; + mac[2] = val[0] >> 24; + mac[3] = val[0] >> 16; + mac[4] = val[0] >> 8; + mac[5] = val[0]; + + } else { + ret = fuse_read(39, 5, &val[0]); + if (ret) + goto err; + + ret = fuse_read(39, 4, &val[1]); + if (ret) + goto err; + + mac[0] = val[1] >> 24; + mac[1] = val[1] >> 16; + mac[2] = val[0] >> 24; + mac[3] = val[0] >> 16; + mac[4] = val[0] >> 8; + mac[5] = val[0]; + } + + debug("%s: MAC%d: %02x.%02x.%02x.%02x.%02x.%02x\n", + __func__, dev_id, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + return; +err: + memset(mac, 0, 6); + printf("%s: fuse read err: %d\n", __func__, ret); } int print_cpuinfo(void)