Skip to contentSkip to conversation

net: imx: Add multi-FEC support for imx_get_mac_from_fuse

PATCH New Fabio Estevam 3 participants 11 messages Dec 20, 2011 – Dec 28, 2011

Subsystems (3)
lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH v7 1/4 net: imx: Add multi-FEC support for imx_get_mac_from_fuse

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.

---
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(-)
arch/arm/cpu/arm1136/mx35/generic.c +1 -1
index ac4838f..d41613e 100644
@@ -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);
 }
arch/arm/cpu/arm926ejs/mx25/generic.c +1 -1
index c045a0b..9cadb7c 100644
@@ -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;
arch/arm/cpu/arm926ejs/mx27/generic.c +1 -1
index 222a8e9..34c20e1 100644
@@ -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;
arch/arm/cpu/armv7/mx6/soc.c +1 -1
index dff5e4e..5a6f9e2 100644
@@ -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];
arch/arm/include/asm/arch-mx6/imx-regs.h +1 -1
index 85d55b7..dfec6b0 100644
@@ -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 {
board/denx/m28evk/m28evk.c +2 -2
index fcee046..a0fabc0 100644
@@ -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);
 }
drivers/net/fec_mxc.c +5 -4
index b05a4c0..1529a27 100644
@@ -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);
 	}
 
drivers/net/fec_mxc.h +1 -1
index 8b26645..6c4aa4b 100644
@@ -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
Signature · 1 line
1.7.1
author reviewer
#1 lore raw

PATCH v7 2/4 mx28: Let imx_get_mac_from_fuse be common for mx28

Let imx_get_mac_from_fuse function be a common function, so that other mx28 boards can reuse it.

---
Changes since v6:
- Let mac[5] be set inside mx28_adjust_mac
Changes since v5:
- Allow the MAC vendor to be overriden
Changes since v4:
- No changes
Change since v3:
- Add a note about the first two MAC addresses being from Freescale vendor.

 arch/arm/cpu/arm926ejs/mx28/mx28.c |   46 ++++++++++++++++++++++++++++++++++++
 board/denx/m28evk/m28evk.c         |   35 ---------------------------
 2 files changed, 46 insertions(+), 35 deletions(-)
arch/arm/cpu/arm926ejs/mx28/mx28.c +46 -0
index 088c019..ee4e337 100644
@@ -214,6 +214,52 @@ int cpu_eth_init(bd_t *bis)
 }
 #endif
 
+static void __mx28_adjust_mac(int dev_id, char *mac)
+{
+	mac[0] = 0x00;
+	mac[1] = 0x04; /* Use FSL vendor MAC address by default */
+
+	if (dev_id == 1) /* Let MAC1 be MAC0 + 1 by default */
+		mac[5] += 1;
+}
+
+void mx28_adjust_mac(int dev_id, char *mac)
+	__attribute__((weak, alias("__mx28_adjust_mac")));
+
+#ifdef	CONFIG_MX28_FEC_MAC_IN_OCOTP
+
+#define	MXS_OCOTP_MAX_TIMEOUT	1000000
+void imx_get_mac_from_fuse(int dev_id, char *mac)
+{
+	struct mx28_ocotp_regs *ocotp_regs =
+		(struct mx28_ocotp_regs *)MXS_OCOTP_BASE;
+	uint32_t data;
+
+	memset(mac, 0, 6);
+
+	writel(OCOTP_CTRL_RD_BANK_OPEN, &ocotp_regs->hw_ocotp_ctrl_set);
+
+	if (mx28_wait_mask_clr(&ocotp_regs->hw_ocotp_ctrl_reg, OCOTP_CTRL_BUSY,
+				MXS_OCOTP_MAX_TIMEOUT)) {
+		printf("MXS FEC: Can't get MAC from OCOTP\n");
+		return;
+	}
+
+	data = readl(&ocotp_regs->hw_ocotp_cust0);
+
+	mac[2] = (data >> 24) & 0xff;
+	mac[3] = (data >> 16) & 0xff;
+	mac[4] = (data >> 8) & 0xff;
+	mac[5] = data & 0xff;
+	mx28_adjust_mac(dev_id, mac);
+}
+#else
+void imx_get_mac_from_fuse(int dev_id, char *mac)
+{
+	memset(mac, 0, 6);
+}
+#endif
+
 U_BOOT_CMD(
 	clocks,	CONFIG_SYS_MAXARGS, 1, do_mx28_showclocks,
 	"display clocks",
board/denx/m28evk/m28evk.c +0 -35
index a0fabc0..005446a 100644
@@ -178,39 +178,4 @@ int board_eth_init(bd_t *bis)
 	return ret;
 }
 
-#ifdef	CONFIG_M28_FEC_MAC_IN_OCOTP
-
-#define	MXS_OCOTP_MAX_TIMEOUT	1000000
-void imx_get_mac_from_fuse(int dev_id, char *mac)
-{
-	struct mx28_ocotp_regs *ocotp_regs =
-		(struct mx28_ocotp_regs *)MXS_OCOTP_BASE;
-	uint32_t data;
-
-	memset(mac, 0, 6);
-
-	writel(OCOTP_CTRL_RD_BANK_OPEN, &ocotp_regs->hw_ocotp_ctrl_set);
-
-	if (mx28_wait_mask_clr(&ocotp_regs->hw_ocotp_ctrl_reg, OCOTP_CTRL_BUSY,
-				MXS_OCOTP_MAX_TIMEOUT)) {
-		printf("MXS FEC: Can't get MAC from OCOTP\n");
-		return;
-	}
-
-	data = readl(&ocotp_regs->hw_ocotp_cust0);
-
-	mac[0] = 0x00;
-	mac[1] = 0x04;
-	mac[2] = (data >> 24) & 0xff;
-	mac[3] = (data >> 16) & 0xff;
-	mac[4] = (data >> 8) & 0xff;
-	mac[5] = data & 0xff;
-}
-#else
-void imx_get_mac_from_fuse(int dev_id, char *mac)
-{
-	memset(mac, 0, 6);
-}
-#endif
-
 #endif
Signature · 1 line
1.7.1
#2 lore raw

PATCH v7 2/4 mx28: Let imx_get_mac_from_fuse be common for mx28

Quoted 23 lines

Let imx_get_mac_from_fuse function be a common function, so that other mx28 boards can reuse it.

---
Changes since v6:
- Let mac[5] be set inside mx28_adjust_mac
Changes since v5:
- Allow the MAC vendor to be overriden
Changes since v4:
- No changes
Change since v3:
- Add a note about the first two MAC addresses being from Freescale vendor.

 arch/arm/cpu/arm926ejs/mx28/mx28.c |   46

++++++++++++++++++++++++++++++++++++ board/denx/m28evk/m28evk.c |
35 --------------------------- 2 files changed, 46 insertions(+), 35
deletions(-)

(quoted diff) +0 -0

b/arch/arm/cpu/arm926ejs/mx28/mx28.c index 088c019..ee4e337 100644

arch/arm/cpu/arm926ejs/mx28/mx28.c int cpu_eth_init(bd_t *bis) · line 217

Quoted 4 lines
arch/arm/cpu/arm926ejs/mx28/mx28.c +1 -0
@@ -214,6 +214,52 @@ int cpu_eth_init(bd_t *bis)
 }
 #endif
 
+static void __mx28_adjust_mac(int dev_id, char *mac)

unsigned char * ... see the header file in your previous patch ;-)

Quoted 5 lines
arch/arm/cpu/arm926ejs/mx28/mx28.c +5 -0
+{
+	mac[0] = 0x00;
+	mac[1] = 0x04; /* Use FSL vendor MAC address by default */
+
+	if (dev_id == 1) /* Let MAC1 be MAC0 + 1 by default */

arch/arm/cpu/arm926ejs/mx28/mx28.c int cpu_eth_init(bd_t *bis) · line 232

Quoted 10 lines
arch/arm/cpu/arm926ejs/mx28/mx28.c +10 -0
+		mac[5] += 1;
+}
+
+void mx28_adjust_mac(int dev_id, char *mac)
+	__attribute__((weak, alias("__mx28_adjust_mac")));
+
+#ifdef	CONFIG_MX28_FEC_MAC_IN_OCOTP
+
+#define	MXS_OCOTP_MAX_TIMEOUT	1000000
+void imx_get_mac_from_fuse(int dev_id, char *mac)

DTTO

Quoted 15 lines
arch/arm/cpu/arm926ejs/mx28/mx28.c +15 -0
+{
+	struct mx28_ocotp_regs *ocotp_regs =
+		(struct mx28_ocotp_regs *)MXS_OCOTP_BASE;
+	uint32_t data;
+
+	memset(mac, 0, 6);
+
+	writel(OCOTP_CTRL_RD_BANK_OPEN, &ocotp_regs->hw_ocotp_ctrl_set);
+
+	if (mx28_wait_mask_clr(&ocotp_regs->hw_ocotp_ctrl_reg, OCOTP_CTRL_BUSY,
+				MXS_OCOTP_MAX_TIMEOUT)) {
+		printf("MXS FEC: Can't get MAC from OCOTP\n");
+		return;
+	}
+

arch/arm/cpu/arm926ejs/mx28/mx28.c int cpu_eth_init(bd_t *bis) · line 257

Quoted 10 lines
arch/arm/cpu/arm926ejs/mx28/mx28.c +10 -0
+	data = readl(&ocotp_regs->hw_ocotp_cust0);
+
+	mac[2] = (data >> 24) & 0xff;
+	mac[3] = (data >> 16) & 0xff;
+	mac[4] = (data >> 8) & 0xff;
+	mac[5] = data & 0xff;
+	mx28_adjust_mac(dev_id, mac);
+}
+#else
+void imx_get_mac_from_fuse(int dev_id, char *mac)

DTTO

Quoted 42 lines
arch/arm/cpu/arm926ejs/mx28/mx28.c +5 -0
+{
+	memset(mac, 0, 6);
+}
+#endif
+
 U_BOOT_CMD(
 	clocks,	CONFIG_SYS_MAXARGS, 1, do_mx28_showclocks,
 	"display clocks",
board/denx/m28evk/m28evk.c +0 -26
index a0fabc0..005446a 100644
@@ -178,39 +178,4 @@ int board_eth_init(bd_t *bis)
 	return ret;
 }
 
-#ifdef	CONFIG_M28_FEC_MAC_IN_OCOTP
-
-#define	MXS_OCOTP_MAX_TIMEOUT	1000000
-void imx_get_mac_from_fuse(int dev_id, char *mac)
-{
-	struct mx28_ocotp_regs *ocotp_regs =
-		(struct mx28_ocotp_regs *)MXS_OCOTP_BASE;
-	uint32_t data;
-
-	memset(mac, 0, 6);
-
-	writel(OCOTP_CTRL_RD_BANK_OPEN, &ocotp_regs->hw_ocotp_ctrl_set);
-
-	if (mx28_wait_mask_clr(&ocotp_regs->hw_ocotp_ctrl_reg, OCOTP_CTRL_BUSY,
-				MXS_OCOTP_MAX_TIMEOUT)) {
-		printf("MXS FEC: Can't get MAC from OCOTP\n");
-		return;
-	}
-
-	data = readl(&ocotp_regs->hw_ocotp_cust0);
-
-	mac[0] = 0x00;
-	mac[1] = 0x04;
-	mac[2] = (data >> 24) & 0xff;
-	mac[3] = (data >> 16) & 0xff;
-	mac[4] = (data >> 8) & 0xff;

board/denx/m28evk/m28evk.c int board_eth_init(bd_t *bis) · line 181

Quoted 10 lines
board/denx/m28evk/m28evk.c +0 -9
-	mac[5] = data & 0xff;
-}
-#else
-void imx_get_mac_from_fuse(int dev_id, char *mac)
-{
-	memset(mac, 0, 6);
-}
-#endif
-
 #endif

M

author reviewer
#3 lore raw

PATCH v8 2/4 mx28: Let imx_get_mac_from_fuse be common for mx28

In reply to Fabio Estevam

Let imx_get_mac_from_fuse function be a common function, so that other mx28 boards can reuse it.

---
Changes since v7:
- Use unsigned char instead of char
Changes since v6:
- Let mac[5] be set inside mx28_adjust_mac
Changes since v5:
- Allow the MAC vendor to be overriden
Changes since v4:
- No changes
Change since v3:
- Add a note about the first two MAC addresses being from Freescale vendor.

 arch/arm/cpu/arm926ejs/mx28/mx28.c |   46 ++++++++++++++++++++++++++++++++++++
 board/denx/m28evk/m28evk.c         |   35 ---------------------------
 2 files changed, 46 insertions(+), 35 deletions(-)
arch/arm/cpu/arm926ejs/mx28/mx28.c +46 -0
index 088c019..ee4e337 100644
@@ -214,6 +214,52 @@ int cpu_eth_init(bd_t *bis)
 }
 #endif
 
+static void __mx28_adjust_mac(int dev_id, unsigned char *mac)
+{
+	mac[0] = 0x00;
+	mac[1] = 0x04; /* Use FSL vendor MAC address by default */
+
+	if (dev_id == 1) /* Let MAC1 be MAC0 + 1 by default */
+		mac[5] += 1;
+}
+
+void mx28_adjust_mac(int dev_id, unsigned char *mac)
+	__attribute__((weak, alias("__mx28_adjust_mac")));
+
+#ifdef	CONFIG_MX28_FEC_MAC_IN_OCOTP
+
+#define	MXS_OCOTP_MAX_TIMEOUT	1000000
+void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
+{
+	struct mx28_ocotp_regs *ocotp_regs =
+		(struct mx28_ocotp_regs *)MXS_OCOTP_BASE;
+	uint32_t data;
+
+	memset(mac, 0, 6);
+
+	writel(OCOTP_CTRL_RD_BANK_OPEN, &ocotp_regs->hw_ocotp_ctrl_set);
+
+	if (mx28_wait_mask_clr(&ocotp_regs->hw_ocotp_ctrl_reg, OCOTP_CTRL_BUSY,
+				MXS_OCOTP_MAX_TIMEOUT)) {
+		printf("MXS FEC: Can't get MAC from OCOTP\n");
+		return;
+	}
+
+	data = readl(&ocotp_regs->hw_ocotp_cust0);
+
+	mac[2] = (data >> 24) & 0xff;
+	mac[3] = (data >> 16) & 0xff;
+	mac[4] = (data >> 8) & 0xff;
+	mac[5] = data & 0xff;
+	mx28_adjust_mac(dev_id, mac);
+}
+#else
+void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
+{
+	memset(mac, 0, 6);
+}
+#endif
+
 U_BOOT_CMD(
 	clocks,	CONFIG_SYS_MAXARGS, 1, do_mx28_showclocks,
 	"display clocks",
board/denx/m28evk/m28evk.c +0 -35
index a0fabc0..005446a 100644
@@ -178,39 +178,4 @@ int board_eth_init(bd_t *bis)
 	return ret;
 }
 
-#ifdef	CONFIG_M28_FEC_MAC_IN_OCOTP
-
-#define	MXS_OCOTP_MAX_TIMEOUT	1000000
-void imx_get_mac_from_fuse(int dev_id, char *mac)
-{
-	struct mx28_ocotp_regs *ocotp_regs =
-		(struct mx28_ocotp_regs *)MXS_OCOTP_BASE;
-	uint32_t data;
-
-	memset(mac, 0, 6);
-
-	writel(OCOTP_CTRL_RD_BANK_OPEN, &ocotp_regs->hw_ocotp_ctrl_set);
-
-	if (mx28_wait_mask_clr(&ocotp_regs->hw_ocotp_ctrl_reg, OCOTP_CTRL_BUSY,
-				MXS_OCOTP_MAX_TIMEOUT)) {
-		printf("MXS FEC: Can't get MAC from OCOTP\n");
-		return;
-	}
-
-	data = readl(&ocotp_regs->hw_ocotp_cust0);
-
-	mac[0] = 0x00;
-	mac[1] = 0x04;
-	mac[2] = (data >> 24) & 0xff;
-	mac[3] = (data >> 16) & 0xff;
-	mac[4] = (data >> 8) & 0xff;
-	mac[5] = data & 0xff;
-}
-#else
-void imx_get_mac_from_fuse(int dev_id, char *mac)
-{
-	memset(mac, 0, 6);
-}
-#endif
-
 #endif
Signature · 1 line
1.7.1
#4 lore raw

PATCH v8 2/4 mx28: Let imx_get_mac_from_fuse be common for mx28

Quoted 111 lines

Let imx_get_mac_from_fuse function be a common function, so that other mx28 boards can reuse it.

---
Changes since v7:
- Use unsigned char instead of char
Changes since v6:
- Let mac[5] be set inside mx28_adjust_mac
Changes since v5:
- Allow the MAC vendor to be overriden
Changes since v4:
- No changes
Change since v3:
- Add a note about the first two MAC addresses being from Freescale vendor.

 arch/arm/cpu/arm926ejs/mx28/mx28.c |   46

++++++++++++++++++++++++++++++++++++ board/denx/m28evk/m28evk.c |
35 --------------------------- 2 files changed, 46 insertions(+), 35
deletions(-)

(quoted diff) +0 -0

b/arch/arm/cpu/arm926ejs/mx28/mx28.c index 088c019..ee4e337 100644

arch/arm/cpu/arm926ejs/mx28/mx28.c +46 -0
@@ -214,6 +214,52 @@ int cpu_eth_init(bd_t *bis)
 }
 #endif
 
+static void __mx28_adjust_mac(int dev_id, unsigned char *mac)
+{
+	mac[0] = 0x00;
+	mac[1] = 0x04; /* Use FSL vendor MAC address by default */
+
+	if (dev_id == 1) /* Let MAC1 be MAC0 + 1 by default */
+		mac[5] += 1;
+}
+
+void mx28_adjust_mac(int dev_id, unsigned char *mac)
+	__attribute__((weak, alias("__mx28_adjust_mac")));
+
+#ifdef	CONFIG_MX28_FEC_MAC_IN_OCOTP
+
+#define	MXS_OCOTP_MAX_TIMEOUT	1000000
+void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
+{
+	struct mx28_ocotp_regs *ocotp_regs =
+		(struct mx28_ocotp_regs *)MXS_OCOTP_BASE;
+	uint32_t data;
+
+	memset(mac, 0, 6);
+
+	writel(OCOTP_CTRL_RD_BANK_OPEN, &ocotp_regs->hw_ocotp_ctrl_set);
+
+	if (mx28_wait_mask_clr(&ocotp_regs->hw_ocotp_ctrl_reg, OCOTP_CTRL_BUSY,
+				MXS_OCOTP_MAX_TIMEOUT)) {
+		printf("MXS FEC: Can't get MAC from OCOTP\n");
+		return;
+	}
+
+	data = readl(&ocotp_regs->hw_ocotp_cust0);
+
+	mac[2] = (data >> 24) & 0xff;
+	mac[3] = (data >> 16) & 0xff;
+	mac[4] = (data >> 8) & 0xff;
+	mac[5] = data & 0xff;
+	mx28_adjust_mac(dev_id, mac);
+}
+#else
+void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
+{
+	memset(mac, 0, 6);
+}
+#endif
+
 U_BOOT_CMD(
 	clocks,	CONFIG_SYS_MAXARGS, 1, do_mx28_showclocks,
 	"display clocks",
board/denx/m28evk/m28evk.c +0 -26
index a0fabc0..005446a 100644
@@ -178,39 +178,4 @@ int board_eth_init(bd_t *bis)
 	return ret;
 }
 
-#ifdef	CONFIG_M28_FEC_MAC_IN_OCOTP
-
-#define	MXS_OCOTP_MAX_TIMEOUT	1000000
-void imx_get_mac_from_fuse(int dev_id, char *mac)
-{
-	struct mx28_ocotp_regs *ocotp_regs =
-		(struct mx28_ocotp_regs *)MXS_OCOTP_BASE;
-	uint32_t data;
-
-	memset(mac, 0, 6);
-
-	writel(OCOTP_CTRL_RD_BANK_OPEN, &ocotp_regs->hw_ocotp_ctrl_set);
-
-	if (mx28_wait_mask_clr(&ocotp_regs->hw_ocotp_ctrl_reg, OCOTP_CTRL_BUSY,
-				MXS_OCOTP_MAX_TIMEOUT)) {
-		printf("MXS FEC: Can't get MAC from OCOTP\n");
-		return;
-	}
-
-	data = readl(&ocotp_regs->hw_ocotp_cust0);
-
-	mac[0] = 0x00;
-	mac[1] = 0x04;
-	mac[2] = (data >> 24) & 0xff;
-	mac[3] = (data >> 16) & 0xff;
-	mac[4] = (data >> 8) & 0xff;

board/denx/m28evk/m28evk.c int board_eth_init(bd_t *bis) · line 181

Quoted 10 lines
board/denx/m28evk/m28evk.c +0 -9
-	mac[5] = data & 0xff;
-}
-#else
-void imx_get_mac_from_fuse(int dev_id, char *mac)
-{
-	memset(mac, 0, 6);
-}
-#endif
-
 #endif
#5 lore raw

PATCH v8 2/4 mx28: Let imx_get_mac_from_fuse be common for mx28

In reply to Fabio Estevam
Quoted 5 lines · Fabio Estevam

Let imx_get_mac_from_fuse function be a common function, so that other mx28 boards can reuse it.

---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
#6 lore raw

PATCH v7 2/4 mx28: Let imx_get_mac_from_fuse be common for mx28

In reply to Fabio Estevam
Quoted 5 lines · Fabio Estevam

Let imx_get_mac_from_fuse function be a common function, so that other mx28 boards can reuse it.

---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
author reviewer
#7 lore raw

PATCH v7 3/4 mx28: Let dram_init be common for mx28

In reply to Fabio Estevam

Let dram_init function be a common function, so that other mx28 boards can reuse it.

---
Changes since v6:
- Added Acked-by line
Changes since v5:
- Change return value on dram_init()
Changes since v4:
- Call mx28_dram_init from m28evk.c
Changes since v3:
- Rename dram_init to mx28_dram_init

 arch/arm/cpu/arm926ejs/mx28/mx28.c         |   21 +++++++++++++++++++++
 arch/arm/include/asm/arch-mx28/sys_proto.h |    2 ++
 board/denx/m28evk/m28evk.c                 |   18 +-----------------
 3 files changed, 24 insertions(+), 17 deletions(-)
arch/arm/cpu/arm926ejs/mx28/mx28.c +21 -0
index ee4e337..c95e900 100644
@@ -260,6 +260,27 @@ void imx_get_mac_from_fuse(int dev_id, char *mac)
 }
 #endif
 
+#define	HW_DIGCTRL_SCRATCH0	0x8001c280
+#define	HW_DIGCTRL_SCRATCH1	0x8001c290
+int mx28_dram_init(void)
+{
+	uint32_t sz[2];
+
+	sz[0] = readl(HW_DIGCTRL_SCRATCH0);
+	sz[1] = readl(HW_DIGCTRL_SCRATCH1);
+
+	if (sz[0] != sz[1]) {
+		printf("MX28:\n"
+			"Error, the RAM size in HW_DIGCTRL_SCRATCH0 and\n"
+			"HW_DIGCTRL_SCRATCH1 is not the same. Please\n"
+			"verify these two registers contain valid RAM size!\n");
+		hang();
+	}
+
+	gd->ram_size = sz[0];
+	return 0;
+}
+
 U_BOOT_CMD(
 	clocks,	CONFIG_SYS_MAXARGS, 1, do_mx28_showclocks,
 	"display clocks",
arch/arm/include/asm/arch-mx28/sys_proto.h +2 -0
index be1f7db..f101494 100644
@@ -35,4 +35,6 @@ void mx28_common_spl_init(const iomux_cfg_t *iomux_setup,
 			const unsigned int iomux_size);
 #endif
 
+int mx28_dram_init(void);
+
 #endif	/* __MX28_H__ */
board/denx/m28evk/m28evk.c +1 -17
index 005446a..53df476 100644
@@ -70,25 +70,9 @@ int board_init(void)
 	return 0;
 }
 
-#define	HW_DIGCTRL_SCRATCH0	0x8001c280
-#define	HW_DIGCTRL_SCRATCH1	0x8001c290
 int dram_init(void)
 {
-	uint32_t sz[2];
-
-	sz[0] = readl(HW_DIGCTRL_SCRATCH0);
-	sz[1] = readl(HW_DIGCTRL_SCRATCH1);
-
-	if (sz[0] != sz[1]) {
-		printf("MX28:\n"
-			"Error, the RAM size in HW_DIGCTRL_SCRATCH0 and\n"
-			"HW_DIGCTRL_SCRATCH1 is not the same. Please\n"
-			"verify these two registers contain valid RAM size!\n");
-		hang();
-	}
-
-	gd->ram_size = sz[0];
-	return 0;
+	return mx28_dram_init();
 }
 
 #ifdef	CONFIG_CMD_MMC
Signature · 1 line
1.7.1
#8 lore raw

PATCH v7 3/4 mx28: Let dram_init be common for mx28

Quoted 6 lines · Fabio Estevam

Let dram_init function be a common function, so that other mx28 boards can reuse it.

---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
author reviewer
#9 lore raw

PATCH v7 4/4 mx28evk: Add initial support for MX28EVK board

In reply to Fabio Estevam

Add initial support for Freescale MX28EVK board.

Tested boot via SD card and by loading a kernel via TFTP through the FEC interface.

---
- For correct operation of saving environment variables into the SD card, the following patch is needed:
http://lists.denx.de/pipermail/u-boot/2011-November/111448.html
Changes since v6:
- Added Acked-by line
Changes since v5:
- Fix tab vs spaces on mx28evk.h
- Change return value on dram_init()
Changes since v4:
- No changes
Changes since v3:
- Fix Copyright in mx28evk.h
- Call mx28_dram_init from dram_init
Changes since v2:
- Generate the patch again due to error in applying unrelated changes Changes since v1:
- Read the MAC from fuses
- Use tabs instead of space in u-boot.bd
- Use puts instead of print
- Factor out mac reading function
- Factor out ddr size calculation function
- Use GENERATED_GBL_DATA_SIZE
- Protect CONFIG_ENV_IS_IN_MMC

 MAINTAINERS                       |    1 +
 board/freescale/mx28evk/Makefile  |   49 ++++++++++
 board/freescale/mx28evk/iomux.c   |  138 +++++++++++++++++++++++++++++
 board/freescale/mx28evk/mx28evk.c |  169 +++++++++++++++++++++++++++++++++++
 board/freescale/mx28evk/u-boot.bd |   14 +++
 boards.cfg                        |    1 +
 include/configs/mx28evk.h         |  176 +++++++++++++++++++++++++++++++++++++
 7 files changed, 548 insertions(+), 0 deletions(-)
 create mode 100644 board/freescale/mx28evk/Makefile
 create mode 100644 board/freescale/mx28evk/iomux.c
 create mode 100644 board/freescale/mx28evk/mx28evk.c
 create mode 100644 board/freescale/mx28evk/u-boot.bd
 create mode 100644 include/configs/mx28evk.h
MAINTAINERS +1 -0
index a56ca10..72e1089 100644
@@ -639,6 +639,7 @@ Kristoffer Ericson <[email protected]>
 Fabio Estevam <[email protected]>
 
 	mx25pdk		i.MX25
+	mx28evk		i.MX28
 	mx31pdk		i.MX31
 	mx53ard		i.MX53
 	mx53smd		i.MX53
board/freescale/mx28evk/Makefile new file +49 -0

49 lines not on this page · raw message

board/freescale/mx28evk/iomux.c new file +138 -0

138 lines not on this page · raw message

board/freescale/mx28evk/mx28evk.c new file +169 -0

169 lines not on this page · raw message

board/freescale/mx28evk/u-boot.bd new file +14 -0
new file mode 100644
index 0000000..c60615a
@@ -0,0 +1,14 @@
+sources {
+	u_boot_spl="spl/u-boot-spl.bin";
+	u_boot="u-boot.bin";
+}
+
+section (0) {
+	load u_boot_spl > 0x0000;
+	load ivt (entry = 0x0014) > 0x8000;
+	hab call 0x8000;
+
+	load u_boot > 0x40000100;
+	load ivt (entry = 0x40000100) > 0x8000;
+	hab call 0x8000;
+}
boards.cfg +1 -0
index 1e5b3e0..e859024 100644
@@ -160,6 +160,7 @@ zmx25                        arm         arm926ejs   zmx25               syteco
 imx27lite                    arm         arm926ejs   imx27lite           logicpd        mx27
 magnesium                    arm         arm926ejs   imx27lite           logicpd        mx27
 m28evk                       arm         arm926ejs   -                   denx           mx28
+mx28evk                      arm         arm926ejs   -                   freescale      mx28
 nhk8815                      arm         arm926ejs   nhk8815             st             nomadik
 nhk8815_onenand              arm         arm926ejs   nhk8815             st             nomadik       nhk8815:BOOT_ONENAND
 omap1610h2		     arm	 arm926ejs   omap1610inn	 ti		omap	    omap1610inn:CS3_BOOT
include/configs/mx28evk.h new file +176 -0

176 lines not on this page · raw message

Signature · 1 line
1.7.1
#10 lore raw

PATCH v7 1/4 net: imx: Add multi-FEC support for imx_get_mac_from_fuse

In reply to Fabio Estevam
Quoted 7 lines · Fabio Estevam

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.

---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================