[PATCH] u-boot mx51evk: read fec mac address from fuse
Shawn Guo
shawn.gsc at gmail.com
Thu Oct 21 17:47:41 UTC 2010
The patch is to read FEC MAC address from fuse bank.
It consolidates the definition of iim_bank_area in iim_regs
across i.mx family. As different i.mx SoC could have MAC bits
defined in different fuse bank, it may be reasonable to
consolidate iim_bank_area as one and use IIM_MAC as offset
to address the MAC field, so that the same fec_get_hwaddr
function can be shared across i.mx family.
Signed-off-by: Shawn Guo <shawn.gsc at gmail.com>
---
arch/arm/include/asm/arch-mx25/imx-regs.h | 10 +++-------
arch/arm/include/asm/arch-mx27/imx-regs.h | 4 ++--
arch/arm/include/asm/arch-mx51/imx-regs.h | 24 ++++++++++++++++++++++++
drivers/net/fec_mxc.c | 10 +---------
4 files changed, 30 insertions(+), 18 deletions(-)
diff --git a/arch/arm/include/asm/arch-mx25/imx-regs.h b/arch/arm/include/asm/arch-mx25/imx-regs.h
index f709bd8..35eb303 100644
--- a/arch/arm/include/asm/arch-mx25/imx-regs.h
+++ b/arch/arm/include/asm/arch-mx25/imx-regs.h
@@ -128,12 +128,8 @@ struct iim_regs {
u32 iim_prev;
u32 iim_srev;
u32 iim_prog_p;
- u32 res1[0x1f5];
- u32 iim_bank_area0[0x20];
- u32 res2[0xe0];
- u32 iim_bank_area1[0x20];
- u32 res3[0xe0];
- u32 iim_bank_area2[0x20];
+ u32 res[0x1f5];
+ u32 iim_bank_area[0x100 * 3];
};
#endif
@@ -311,6 +307,6 @@ struct iim_regs {
#define WCR_WDE 0x04
/* FUSE bank offsets */
-#define IIM0_MAC 0x1a
+#define IIM_MAC 0x1a
#endif /* _IMX_REGS_H */
diff --git a/arch/arm/include/asm/arch-mx27/imx-regs.h b/arch/arm/include/asm/arch-mx27/imx-regs.h
index 6ecddaa..9fdd5c5 100644
--- a/arch/arm/include/asm/arch-mx27/imx-regs.h
+++ b/arch/arm/include/asm/arch-mx27/imx-regs.h
@@ -203,7 +203,7 @@ struct iim_regs {
u32 iim_scs2;
u32 iim_scs3;
u32 res[0x1F0];
- u32 iim_bank_area0[0x100];
+ u32 iim_bank_area[0x100 * 2];
};
#endif
@@ -513,7 +513,7 @@ struct iim_regs {
#define IIM_ERR_PARITYE (1 << 1)
/* Definitions for i.MX27 TO2 */
-#define IIM0_MAC 5
+#define IIM_MAC 5
#define IIM0_SCC_KEY 11
#define IIM1_SUID 1
diff --git a/arch/arm/include/asm/arch-mx51/imx-regs.h b/arch/arm/include/asm/arch-mx51/imx-regs.h
index 3887d3c..4ae7371 100644
--- a/arch/arm/include/asm/arch-mx51/imx-regs.h
+++ b/arch/arm/include/asm/arch-mx51/imx-regs.h
@@ -207,6 +207,10 @@
#define BOARD_REV_1_0 0x0
#define BOARD_REV_2_0 0x1
+/* FUSE */
+#define IMX_IIM_BASE (IIM_BASE_ADDR)
+#define IIM_MAC 0x109
+
#ifndef __ASSEMBLY__
struct clkctl {
@@ -256,6 +260,26 @@ struct weim {
u32 cswcr2;
};
+struct iim_regs {
+ u32 stat;
+ u32 statm;
+ u32 err;
+ u32 emask;
+ u32 fctl;
+ u32 ua;
+ u32 la;
+ u32 sdat;
+ u32 prev;
+ u32 srev;
+ u32 preg_p;
+ u32 scs0;
+ u32 scs1;
+ u32 scs2;
+ u32 scs3;
+ u32 res[0x1f1];
+ u32 iim_bank_area[0x100 * 4];
+};
+
#endif /* __ASSEMBLER__*/
#endif /* __ASM_ARCH_MXC_MX51_H__ */
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 050c0e1..e5a2376 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -312,21 +312,13 @@ static void fec_rbd_clean(int last, struct fec_bd *pRbd)
static int fec_get_hwaddr(struct eth_device *dev, unsigned char *mac)
{
-/*
- * The MX27 can store the mac address in internal eeprom
- * This mechanism is not supported now by MX51 or MX25
- */
-#if defined(CONFIG_MX51) || defined(CONFIG_MX25)
- return -1;
-#else
struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
int i;
for (i = 0; i < 6; i++)
- mac[6-1-i] = readl(&iim->iim_bank_area0[IIM0_MAC + i]);
+ mac[i] = readl(&iim->iim_bank_area[IIM_MAC + i]);
return !is_valid_ether_addr(mac);
-#endif
}
static int fec_set_hwaddr(struct eth_device *dev)
--
1.7.1
More information about the linaro-dev
mailing list