Patchwork [U-Boot,v7,1/4] net: imx: Add multi-FEC support for imx_get_mac_from_fuse

login
register
mail settings
Submitter Fabio Estevam
Date Dec. 20, 2011, 3:46 p.m.
Message ID <1324395994-10786-1-git-send-email-festevam@gmail.com>
Download mbox | patch
Permalink /patch/132438/
State Accepted
Commit be252b654a018cd9f513b0f2a5da4855a209c40c
Delegated to: Stefano Babic
Headers show

Comments

Fabio Estevam - Dec. 20, 2011, 3:46 p.m.
Add multi-FEC support for imx_get_mac_from_fuse by passing dev_id as a parameter.

This feature is important on mx28 SoC for example that has two FEC ports.

Cc: Ben Warren <biggerbadderben@gmail.com>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Change since v6:
- No changes. Introduced on this series

 arch/arm/cpu/arm1136/mx35/generic.c      |    2 +-
 arch/arm/cpu/arm926ejs/mx25/generic.c    |    2 +-
 arch/arm/cpu/arm926ejs/mx27/generic.c    |    2 +-
 arch/arm/cpu/armv7/mx6/soc.c             |    2 +-
 arch/arm/include/asm/arch-mx6/imx-regs.h |    2 +-
 board/denx/m28evk/m28evk.c               |    4 ++--
 drivers/net/fec_mxc.c                    |    9 +++++----
 drivers/net/fec_mxc.h                    |    2 +-
 8 files changed, 13 insertions(+), 12 deletions(-)
Stefano Babic - Dec. 28, 2011, 1:50 p.m.
On 20/12/2011 16:46, Fabio Estevam wrote:
> Add multi-FEC support for imx_get_mac_from_fuse by passing dev_id as a parameter.
> 
> This feature is important on mx28 SoC for example that has two FEC ports.
> 
> Cc: Ben Warren <biggerbadderben@gmail.com>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Patch

diff --git a/arch/arm/cpu/arm1136/mx35/generic.c b/arch/arm/cpu/arm1136/mx35/generic.c
index ac4838f..d41613e 100644
--- a/arch/arm/cpu/arm1136/mx35/generic.c
+++ b/arch/arm/cpu/arm1136/mx35/generic.c
@@ -393,7 +393,7 @@  unsigned int mxc_get_clock(enum mxc_clock clk)
 /*
  * The MX35 has no fuse for MAC, return a NULL MAC
  */
-void imx_get_mac_from_fuse(unsigned char *mac)
+void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
 {
 	memset(mac, 0, 6);
 }
diff --git a/arch/arm/cpu/arm926ejs/mx25/generic.c b/arch/arm/cpu/arm926ejs/mx25/generic.c
index c045a0b..9cadb7c 100644
--- a/arch/arm/cpu/arm926ejs/mx25/generic.c
+++ b/arch/arm/cpu/arm926ejs/mx25/generic.c
@@ -312,7 +312,7 @@  void mx25_fec_init_pins(void)
 
 }
 
-void imx_get_mac_from_fuse(unsigned char *mac)
+void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
 {
 	int i;
 	struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
diff --git a/arch/arm/cpu/arm926ejs/mx27/generic.c b/arch/arm/cpu/arm926ejs/mx27/generic.c
index 222a8e9..34c20e1 100644
--- a/arch/arm/cpu/arm926ejs/mx27/generic.c
+++ b/arch/arm/cpu/arm926ejs/mx27/generic.c
@@ -314,7 +314,7 @@  void mx27_fec_init_pins(void)
 		imx_gpio_mode(mode[i]);
 }
 
-void imx_get_mac_from_fuse(unsigned char *mac)
+void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
 {
 	int i;
 	struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
diff --git a/arch/arm/cpu/armv7/mx6/soc.c b/arch/arm/cpu/armv7/mx6/soc.c
index dff5e4e..5a6f9e2 100644
--- a/arch/arm/cpu/armv7/mx6/soc.c
+++ b/arch/arm/cpu/armv7/mx6/soc.c
@@ -63,7 +63,7 @@  int arch_cpu_init(void)
 #endif
 
 #if defined(CONFIG_FEC_MXC)
-void imx_get_mac_from_fuse(unsigned char *mac)
+void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
 {
 	struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
 	struct fuse_bank *bank = &iim->bank[4];
diff --git a/arch/arm/include/asm/arch-mx6/imx-regs.h b/arch/arm/include/asm/arch-mx6/imx-regs.h
index 85d55b7..dfec6b0 100644
--- a/arch/arm/include/asm/arch-mx6/imx-regs.h
+++ b/arch/arm/include/asm/arch-mx6/imx-regs.h
@@ -167,7 +167,7 @@ 
 #if !(defined(__KERNEL_STRICT_NAMES) || defined(__ASSEMBLY__))
 #include <asm/types.h>
 
-extern void imx_get_mac_from_fuse(unsigned char *mac);
+extern void imx_get_mac_from_fuse(int dev_id, unsigned char *mac);
 
 /* System Reset Controller (SRC) */
 struct src {
diff --git a/board/denx/m28evk/m28evk.c b/board/denx/m28evk/m28evk.c
index fcee046..a0fabc0 100644
--- a/board/denx/m28evk/m28evk.c
+++ b/board/denx/m28evk/m28evk.c
@@ -181,7 +181,7 @@  int board_eth_init(bd_t *bis)
 #ifdef	CONFIG_M28_FEC_MAC_IN_OCOTP
 
 #define	MXS_OCOTP_MAX_TIMEOUT	1000000
-void imx_get_mac_from_fuse(char *mac)
+void imx_get_mac_from_fuse(int dev_id, char *mac)
 {
 	struct mx28_ocotp_regs *ocotp_regs =
 		(struct mx28_ocotp_regs *)MXS_OCOTP_BASE;
@@ -207,7 +207,7 @@  void imx_get_mac_from_fuse(char *mac)
 	mac[5] = data & 0xff;
 }
 #else
-void imx_get_mac_from_fuse(char *mac)
+void imx_get_mac_from_fuse(int dev_id, char *mac)
 {
 	memset(mac, 0, 6);
 }
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index b05a4c0..1529a27 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -345,9 +345,10 @@  static void fec_rbd_clean(int last, struct fec_bd *pRbd)
 	writew(0, &pRbd->data_length);
 }
 
-static int fec_get_hwaddr(struct eth_device *dev, unsigned char *mac)
+static int fec_get_hwaddr(struct eth_device *dev, int dev_id,
+						unsigned char *mac)
 {
-	imx_get_mac_from_fuse(mac);
+	imx_get_mac_from_fuse(dev_id, mac);
 	return !is_valid_ether_addr(mac);
 }
 
@@ -812,8 +813,8 @@  static int fec_probe(bd_t *bd, int dev_id, int phy_id, uint32_t base_addr)
 
 	eth_register(edev);
 
-	if (fec_get_hwaddr(edev, ethaddr) == 0) {
-		debug("got MAC address from fuse: %pM\n", ethaddr);
+	if (fec_get_hwaddr(edev, dev_id, ethaddr) == 0) {
+		debug("got MAC%d address from fuse: %pM\n", dev_id, ethaddr);
 		memcpy(edev->enetaddr, ethaddr, 6);
 	}
 
diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h
index 8b26645..6c4aa4b 100644
--- a/drivers/net/fec_mxc.h
+++ b/drivers/net/fec_mxc.h
@@ -32,7 +32,7 @@ 
 #ifndef __FEC_MXC_H
 #define __FEC_MXC_H
 
-void imx_get_mac_from_fuse(unsigned char *mac);
+void imx_get_mac_from_fuse(int dev_id, unsigned char *mac);
 
 /**
  * Layout description of the FEC