public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] imx: Get fec mac address from fuse
@ 2010-10-22 11:25 Jason Liu
  2010-10-22 11:25 ` [U-Boot] [PATCH 2/2] MX5: board version not printed corretly on MX51EVK Jason Liu
  2010-10-26  7:45 ` [U-Boot] [PATCH 1/2] imx: Get fec mac address from fuse Stefano Babic
  0 siblings, 2 replies; 15+ messages in thread
From: Jason Liu @ 2010-10-22 11:25 UTC (permalink / raw)
  To: u-boot

The patch is to support getting FEC MAC address from fuse bank.

Signed-off-by: Jason Liu <r64343@freescale.com>
---
 arch/arm/include/asm/arch-mx25/imx-regs.h |   10 +++-------
 arch/arm/include/asm/arch-mx27/imx-regs.h |    5 ++---
 arch/arm/include/asm/arch-mx5/imx-regs.h  |   24 ++++++++++++++++++++++++
 drivers/net/fec_mxc.c                     |   17 +++++------------
 4 files changed, 34 insertions(+), 22 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..429f893 100644
--- a/arch/arm/include/asm/arch-mx27/imx-regs.h
+++ b/arch/arm/include/asm/arch-mx27/imx-regs.h
@@ -202,8 +202,7 @@ struct iim_regs {
 	u32 iim_scs1;
 	u32 iim_scs2;
 	u32 iim_scs3;
-	u32 res[0x1F0];
-	u32 iim_bank_area0[0x100];
+	u32 iim_bank_area[0x100 * 2];
 };
 #endif
 
@@ -513,7 +512,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-mx5/imx-regs.h b/arch/arm/include/asm/arch-mx5/imx-regs.h
index 3ddda40..892099c 100644
--- a/arch/arm/include/asm/arch-mx5/imx-regs.h
+++ b/arch/arm/include/asm/arch-mx5/imx-regs.h
@@ -204,6 +204,9 @@
 #define BOARD_REV_1_0           0x0
 #define BOARD_REV_2_0           0x1
 
+#define IMX_IIM_BASE		(IIM_BASE_ADDR)
+#define IIM_MAC			0x109
+
 #if !(defined(__KERNEL_STRICT_NAMES) || defined(__ASSEMBLY__))
 #include <asm/types.h>
 
@@ -274,6 +277,27 @@ struct src {
 	u32	sisr;
 	u32	simr;
 };
+
+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 3f09c2b..e8d7b98 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -312,21 +312,17 @@ 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
+	/*
+	 * The MX27 can store the mac address in internal eeprom
+	 * This mechanism is also supported now by MX51 or MX25
+	 */
 	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[6-1-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)
@@ -414,9 +410,6 @@ static int fec_init(struct eth_device *dev, bd_t* bd)
 	uint32_t base;
 	struct fec_priv *fec = (struct fec_priv *)dev->priv;
 
-	/* Initialize MAC address */
-	fec_set_hwaddr(dev);
-
 	/*
 	 * reserve memory for both buffer descriptor chains at once
 	 * Datasheet forces the startaddress of each chain is 16 byte
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [U-Boot] [PATCH 1/2] imx: Get fec mac address from fuse
@ 2010-10-25 13:07 Shawn Guo
  0 siblings, 0 replies; 15+ messages in thread
From: Shawn Guo @ 2010-10-25 13:07 UTC (permalink / raw)
  To: u-boot

I was not in the mail list when Jason posted the patch, so I emulated
the reply message.

> diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
> index 3f09c2b..e8d7b98 100644
> --- a/drivers/net/fec_mxc.c
> +++ b/drivers/net/fec_mxc.c
> @@ -312,21 +312,17 @@ 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
> +	/*
> +	 * The MX27 can store the mac address in internal eeprom
> +	 * This mechanism is also supported now by MX51 or MX25
> +	 */
>
The comment was added to distinguish the MX27 support from MX51/25 on
mac fuse.  Since the support becomes common, can we just simply remove
the comment?  Also, the mac is implemented in fuse like the message
title tells than "eeprom".

>  	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[6-1-i] = readl(&iim->iim_bank_area[IIM_MAC + i]);
>
There is a bug.  The fix could be as below (tested on mx51evk).

-               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
> }


-- 
Regards,
Shawn

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2010-10-27 18:59 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-22 11:25 [U-Boot] [PATCH 1/2] imx: Get fec mac address from fuse Jason Liu
2010-10-22 11:25 ` [U-Boot] [PATCH 2/2] MX5: board version not printed corretly on MX51EVK Jason Liu
2010-10-26  7:53   ` Stefano Babic
2010-10-26 10:29     ` Jason Liu
2010-10-27  7:22       ` Stefano Babic
2010-10-26  7:45 ` [U-Boot] [PATCH 1/2] imx: Get fec mac address from fuse Stefano Babic
2010-10-26 10:35   ` Jason Liu
2010-10-27  7:21     ` Stefano Babic
2010-10-27  7:40       ` Jason Liu
2010-10-27  8:49         ` Stefano Babic
2010-10-27  9:21           ` Jason Liu
2010-10-27 17:50             ` John Rigby
2010-10-27 18:06               ` Wolfgang Denk
2010-10-27 18:59                 ` John Rigby
  -- strict thread matches above, loose matches on Subject: below --
2010-10-25 13:07 Shawn Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox