[U-Boot] [PATCH 13/41] imx8: implement imx_get_mac_from_fuse
Peng Fan
peng.fan at nxp.com
Mon May 28 12:24:58 UTC 2018
Implement imx_get_mac_from_fuse for i.MX8, this will be used by fec_mxc
driver to get the mac address.
Signed-off-by: Peng Fan <peng.fan at nxp.com>
---
arch/arm/mach-imx/imx8/cpu.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/arch/arm/mach-imx/imx8/cpu.c b/arch/arm/mach-imx/imx8/cpu.c
index fa32a9362c..2b58f510b4 100644
--- a/arch/arm/mach-imx/imx8/cpu.c
+++ b/arch/arm/mach-imx/imx8/cpu.c
@@ -79,6 +79,50 @@ int print_cpuinfo(void)
}
#endif
+#if defined(CONFIG_IMX8QXP)
+#define FUSE_MAC0_WORD0 708
+#define FUSE_MAC0_WORD1 709
+#define FUSE_MAC1_WORD0 710
+#define FUSE_MAC1_WORD1 711
+#endif
+
+void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
+{
+ sc_err_t err;
+ sc_ipc_t ipc;
+ u32 val1 = 0, val2 = 0;
+ u32 word1, word2;
+
+ ipc = gd->arch.ipc_channel_handle;
+
+ if (dev_id == 0) {
+ word1 = FUSE_MAC0_WORD0;
+ word2 = FUSE_MAC0_WORD1;
+ } else {
+ word1 = FUSE_MAC1_WORD0;
+ word2 = FUSE_MAC1_WORD1;
+ }
+
+ err = sc_misc_otp_fuse_read(ipc, word1, &val1);
+ if (err != SC_ERR_NONE) {
+ printf("%s fuse %d read error: %d\n", __func__, word1, err);
+ return;
+ }
+
+ err = sc_misc_otp_fuse_read(ipc, word2, &val2);
+ if (err != SC_ERR_NONE) {
+ printf("%s fuse %d read error: %d\n", __func__, word2, err);
+ return;
+ }
+
+ mac[0] = val1;
+ mac[1] = val1 >> 8;
+ mac[2] = val1 >> 16;
+ mac[3] = val1 >> 24;
+ mac[4] = val2;
+ mac[5] = val2 >> 8;
+}
+
int print_bootinfo(void)
{
enum boot_device bt_dev = get_boot_device();
--
2.14.1
More information about the U-Boot
mailing list