aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYe Li <ye.li@nxp.com>2023-04-28 12:08:21 +0800
committerStefano Babic <sbabic@denx.de>2023-05-21 16:54:40 +0200
commitd0724433b538bcb9658541121a8af3685a2b8f25 (patch)
tree2be7631c169e730a7ab73140792bbc432abb1163
parent3db03cbd4cc99fd3bc3b4732c373e0c551bf2f88 (diff)
downloadu-boot-d0724433b538bcb9658541121a8af3685a2b8f25.zip
u-boot-d0724433b538bcb9658541121a8af3685a2b8f25.tar.gz
u-boot-d0724433b538bcb9658541121a8af3685a2b8f25.tar.bz2
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 <ping.bai@nxp.com> Signed-off-by: Ye Li <ye.li@nxp.com> Signed-off-by: Peng Fan <peng.fan@nxp.com>
-rw-r--r--arch/arm/mach-imx/imx9/soc.c49
1 files changed, 43 insertions, 6 deletions
diff --git a/arch/arm/mach-imx/imx9/soc.c b/arch/arm/mach-imx/imx9/soc.c
index f02e903..a884e08 100644
--- a/arch/arm/mach-imx/imx9/soc.c
+++ b/arch/arm/mach-imx/imx9/soc.c
@@ -30,6 +30,7 @@
#include <asm/arch-imx/cpu.h>
#include <asm/mach-imx/s400_api.h>
#include <linux/delay.h>
+#include <fuse.h>
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)