summaryrefslogtreecommitdiff
path: root/arch/arm/mach-imx
diff options
context:
space:
mode:
authorAnatolij Gustschin <agust@denx.de>2018-10-18 14:28:23 +0200
committerStefano Babic <sbabic@denx.de>2018-10-22 12:59:01 +0200
commit70b4b49b91e2bfb148307dc4e35594740ba00514 (patch)
tree31da97a163e716b73a217f10955585839ed88d53 /arch/arm/mach-imx
parent1ef20a3d812281b5979ec0cb030b91124987e0b6 (diff)
downloadu-boot-70b4b49b91e2bfb148307dc4e35594740ba00514.tar.gz
u-boot-70b4b49b91e2bfb148307dc4e35594740ba00514.tar.bz2
u-boot-70b4b49b91e2bfb148307dc4e35594740ba00514.zip
imx8: cpu: add function for reading FEC MAC from fuse
FEC driver requires imx_get_mac_from_fuse(). Add it in preparation for ENETx support. Signed-off-by: Anatolij Gustschin <agust@denx.de> Cc: Stefano Babic <sbabic@denx.de> Reviewed-by: Peng Fan <peng.fan@nxp.com>
Diffstat (limited to 'arch/arm/mach-imx')
-rw-r--r--arch/arm/mach-imx/imx8/cpu.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/arch/arm/mach-imx/imx8/cpu.c b/arch/arm/mach-imx/imx8/cpu.c
index d80b4b175d..da34a94a23 100644
--- a/arch/arm/mach-imx/imx8/cpu.c
+++ b/arch/arm/mach-imx/imx8/cpu.c
@@ -543,3 +543,41 @@ u64 get_page_table_size(void)
return size;
}
#endif
+
+#define FUSE_MAC0_WORD0 708
+#define FUSE_MAC0_WORD1 709
+#define FUSE_MAC1_WORD0 710
+#define FUSE_MAC1_WORD1 711
+
+void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
+{
+ u32 word[2], val[2] = {};
+ int i, ret;
+
+ if (dev_id == 0) {
+ word[0] = FUSE_MAC0_WORD0;
+ word[1] = FUSE_MAC0_WORD1;
+ } else {
+ word[0] = FUSE_MAC1_WORD0;
+ word[1] = FUSE_MAC1_WORD1;
+ }
+
+ for (i = 0; i < 2; i++) {
+ ret = sc_misc_otp_fuse_read(-1, word[i], &val[i]);
+ if (ret < 0)
+ goto err;
+ }
+
+ mac[0] = val[0];
+ mac[1] = val[0] >> 8;
+ mac[2] = val[0] >> 16;
+ mac[3] = val[0] >> 24;
+ mac[4] = val[1];
+ mac[5] = val[1] >> 8;
+
+ 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:
+ printf("%s: fuse %d, err: %d\n", __func__, word[i], ret);
+}