Skip to contentSkip to conversation

mx6: soc: Add ENET2 mac address support

PATCH Superseded Ye Li 3 participants 4 messages Jan 26, 2016

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Ye Li

author
#0 lore raw

PATCH v2 1/2 mx6: soc: Add ENET2 mac address support

The i.MX6SX and i.MX6UL has two ENET controllers, add support for reading MAC address from fuse for ENET2.

---
Changes for v2:
- Add second MAC address to README.imx6.
- Rename mac_addr_low and mac_addr_high fields to mac_addr0 and mac_addr1 to align with the reigster names in RM.

 arch/arm/cpu/armv7/mx6/soc.c             |   32 +++++++++++++++++++++--------
 arch/arm/include/asm/arch-mx6/imx-regs.h |   23 ++------------------
 doc/README.imx6                          |    5 +++-
 3 files changed, 30 insertions(+), 30 deletions(-)
arch/arm/cpu/armv7/mx6/soc.c +23 -9
index bf5ae8c..f83dfa0 100644
@@ -364,15 +364,29 @@ void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
 	struct fuse_bank4_regs *fuse =
 			(struct fuse_bank4_regs *)bank->fuse_regs;
 
-	u32 value = readl(&fuse->mac_addr_high);
-	mac[0] = (value >> 8);
-	mac[1] = value ;
-
-	value = readl(&fuse->mac_addr_low);
-	mac[2] = value >> 24 ;
-	mac[3] = value >> 16 ;
-	mac[4] = value >> 8 ;
-	mac[5] = value ;
+	if ((is_cpu_type(MXC_CPU_MX6SX) || is_cpu_type(MXC_CPU_MX6UL)) && 
+		1 == dev_id) {
+		u32 value = readl(&fuse->mac_addr2);
+		mac[0] = value >> 24 ;
+		mac[1] = value >> 16 ;
+		mac[2] = value >> 8 ;
+		mac[3] = value ;
+
+		value = readl(&fuse->mac_addr1);
+		mac[4] = value >> 24 ;
+		mac[5] = value >> 16 ;
+		
+	} else {
+		u32 value = readl(&fuse->mac_addr1);
+		mac[0] = (value >> 8);
+		mac[1] = value ;
+
+		value = readl(&fuse->mac_addr0);
+		mac[2] = value >> 24 ;
+		mac[3] = value >> 16 ;
+		mac[4] = value >> 8 ;
+		mac[5] = value ;
+	}
 
 }
 #endif
arch/arm/include/asm/arch-mx6/imx-regs.h +3 -20
index f24525e..5c45bf6 100644
@@ -715,39 +715,22 @@ struct fuse_bank1_regs {
 	u32	rsvd7[3];
 };
 
-#if (defined(CONFIG_MX6SX) || defined(CONFIG_MX6UL))
 struct fuse_bank4_regs {
 	u32 sjc_resp_low;
 	u32 rsvd0[3];
 	u32 sjc_resp_high;
 	u32 rsvd1[3];
-	u32 mac_addr_low;
+	u32 mac_addr0;
 	u32 rsvd2[3];
-	u32 mac_addr_high;
+	u32 mac_addr1;
 	u32 rsvd3[3];
-	u32 mac_addr2;
+	u32 mac_addr2; /*For i.MX6SX and i.MX6UL*/
 	u32 rsvd4[7];
 	u32 gp1;
 	u32 rsvd5[3];
 	u32 gp2;
 	u32 rsvd6[3];
 };
-#else
-struct fuse_bank4_regs {
-	u32	sjc_resp_low;
-	u32     rsvd0[3];
-	u32     sjc_resp_high;
-	u32     rsvd1[3];
-	u32	mac_addr_low;
-	u32     rsvd2[3];
-	u32     mac_addr_high;
-	u32	rsvd3[0xb];
-	u32	gp1;
-	u32	rsvd4[3];
-	u32	gp2;
-	u32	rsvd5[3];
-};
-#endif
 
 struct aipstz_regs {
 	u32	mprot0;
doc/README.imx6 +4 -1
index e26ab71..7c9a4ac 100644
@@ -7,7 +7,10 @@ SoC.
 -----------------------------------
 
 1.1 MAC Address: It is stored in fuse bank 4, with the 32 lsbs in word 2 and the
-    16 msbs in word 3.
+    16 msbs in word 3[15:0].
+    For i.MX6SX and i.MX6UL, they have two MAC addresses. The second MAC address
+    is stored in fuse bank 4, with the 16 lsb in word 3[31:16] and the 32 msbs in 
+    word 4.
 
 Example:
 
Signature · 1 line
1.7.4.1
author
#1 lore raw

PATCH v2 2/2 imx: mx6sxsabreauto: Add support for mx6sx SABREAUTO board

Initial version for mx6sx SABREAUTO board support with features:
PMIC, QSPI, NAND flash, SD/MMC, USB, Ethernet, I2C, IO Expander.

---
Changes for v2:
- None

 arch/arm/cpu/armv7/mx6/Kconfig                  |    6 +
 board/freescale/mx6sxsabreauto/Kconfig          |   12 +
 board/freescale/mx6sxsabreauto/MAINTAINERS      |    6 +
 board/freescale/mx6sxsabreauto/Makefile         |    6 +
 board/freescale/mx6sxsabreauto/imximage.cfg     |  136 ++++++
 board/freescale/mx6sxsabreauto/mx6sxsabreauto.c |  508 +++++++++++++++++++++++
 configs/mx6sxsabreauto_defconfig                |   11 +
 include/configs/mx6sxsabreauto.h                |  212 ++++++++++
 8 files changed, 897 insertions(+), 0 deletions(-)
 create mode 100644 board/freescale/mx6sxsabreauto/Kconfig
 create mode 100644 board/freescale/mx6sxsabreauto/MAINTAINERS
 create mode 100644 board/freescale/mx6sxsabreauto/Makefile
 create mode 100644 board/freescale/mx6sxsabreauto/imximage.cfg
 create mode 100644 board/freescale/mx6sxsabreauto/mx6sxsabreauto.c
 create mode 100644 configs/mx6sxsabreauto_defconfig
 create mode 100644 include/configs/mx6sxsabreauto.h
arch/arm/cpu/armv7/mx6/Kconfig +6 -0
index 8489182..c72a150 100644
@@ -96,6 +96,11 @@ config TARGET_MX6SXSABRESD
 	select DM
 	select DM_THERMAL
 
+config TARGET_MX6SXSABREAUTO
+        bool "mx6sxsabreauto"
+        select DM
+        select DM_THERMAL
+
 config TARGET_MX6UL_9X9_EVK
 	bool "mx6ul_9x9_evk"
 	select MX6UL
@@ -166,6 +171,7 @@ source "board/freescale/mx6qsabreauto/Kconfig"
 source "board/freescale/mx6sabresd/Kconfig"
 source "board/freescale/mx6slevk/Kconfig"
 source "board/freescale/mx6sxsabresd/Kconfig"
+source "board/freescale/mx6sxsabreauto/Kconfig"
 source "board/freescale/mx6ul_14x14_evk/Kconfig"
 source "board/gateworks/gw_ventana/Kconfig"
 source "board/kosagi/novena/Kconfig"
board/freescale/mx6sxsabreauto/Kconfig new file +12 -0
new file mode 100644
index 0000000..ae2ea02
@@ -0,0 +1,12 @@
+if TARGET_MX6SXSABREAUTO
+
+config SYS_BOARD
+	default "mx6sxsabreauto"
+
+config SYS_VENDOR
+	default "freescale"
+
+config SYS_CONFIG_NAME
+	default "mx6sxsabreauto"
+
+endif
board/freescale/mx6sxsabreauto/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000..6f2ff44
@@ -0,0 +1,6 @@
+MX6SXSABREAUTO BOARD
+M:	Fabio Estevam <[email protected]>
+S:	Maintained
+F:	board/freescale/mx6sxsabreauto/
+F:	include/configs/mx6sxsabreauto.h
+F:	configs/mx6sxsabreauto_defconfig
board/freescale/mx6sxsabreauto/Makefile new file +6 -0
new file mode 100644
index 0000000..f0cd1ce
@@ -0,0 +1,6 @@
+# (C) Copyright 2014 Freescale Semiconductor, Inc.
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y  := mx6sxsabreauto.o
board/freescale/mx6sxsabreauto/imximage.cfg new file +136 -0

136 lines not on this page · raw message

board/freescale/mx6sxsabreauto/mx6sxsabreauto.c new file +508 -0

508 lines not on this page · raw message

configs/mx6sxsabreauto_defconfig new file +11 -0
new file mode 100644
index 0000000..d9e35df
@@ -0,0 +1,11 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MX6=y
+CONFIG_TARGET_MX6SXSABREAUTO=y
+CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6sxsabreauto/imximage.cfg,MX6SX"
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_GPIO=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_BAR=y
+CONFIG_SPI_FLASH_STMICRO=y
include/configs/mx6sxsabreauto.h new file +212 -0

212 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#2 lore raw

PATCH v2 1/2 mx6: soc: Add ENET2 mac address support

In reply to Ye Li
Quoted 29 lines · Ye Li

The i.MX6SX and i.MX6UL has two ENET controllers, add support for reading MAC address from fuse for ENET2.

---
Changes for v2:
- Add second MAC address to README.imx6.
- Rename mac_addr_low and mac_addr_high fields to mac_addr0 and mac_addr1 to align with the reigster names in RM.

 arch/arm/cpu/armv7/mx6/soc.c             |   32 +++++++++++++++++++++--------
 arch/arm/include/asm/arch-mx6/imx-regs.h |   23 ++------------------
 doc/README.imx6                          |    5 +++-
 3 files changed, 30 insertions(+), 30 deletions(-)
arch/arm/cpu/armv7/mx6/soc.c +0 -6
index bf5ae8c..f83dfa0 100644
@@ -364,15 +364,29 @@ void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
        struct fuse_bank4_regs *fuse =
                        (struct fuse_bank4_regs *)bank->fuse_regs;
 
-       u32 value = readl(&fuse->mac_addr_high);
-       mac[0] = (value >> 8);
-       mac[1] = value ;
-
-       value = readl(&fuse->mac_addr_low);
-       mac[2] = value >> 24 ;

arch/arm/cpu/armv7/mx6/soc.c void imx_get_mac_from_fuse(int dev_id, unsigned char *mac) · line 373

Quoted 10 lines
arch/arm/cpu/armv7/mx6/soc.c +7 -3
-       mac[3] = value >> 16 ;
-       mac[4] = value >> 8 ;
-       mac[5] = value ;
+       if ((is_cpu_type(MXC_CPU_MX6SX) || is_cpu_type(MXC_CPU_MX6UL)) &&
+               1 == dev_id) {
+               u32 value = readl(&fuse->mac_addr2);
+               mac[0] = value >> 24 ;
+               mac[1] = value >> 16 ;
+               mac[2] = value >> 8 ;
+               mac[3] = value ;

I'm surprised the compiler doesn't warn you about your int being too big. If it does, you should address that before sending a v3.

Quoted 89 lines
arch/arm/cpu/armv7/mx6/soc.c +16 -0
+
+               value = readl(&fuse->mac_addr1);
+               mac[4] = value >> 24 ;
+               mac[5] = value >> 16 ;
+
+       } else {
+               u32 value = readl(&fuse->mac_addr1);
+               mac[0] = (value >> 8);
+               mac[1] = value ;
+
+               value = readl(&fuse->mac_addr0);
+               mac[2] = value >> 24 ;
+               mac[3] = value >> 16 ;
+               mac[4] = value >> 8 ;
+               mac[5] = value ;
+       }
 
 }
 #endif
arch/arm/include/asm/arch-mx6/imx-regs.h +3 -20
index f24525e..5c45bf6 100644
@@ -715,39 +715,22 @@ struct fuse_bank1_regs {
        u32     rsvd7[3];
 };
 
-#if (defined(CONFIG_MX6SX) || defined(CONFIG_MX6UL))
 struct fuse_bank4_regs {
        u32 sjc_resp_low;
        u32 rsvd0[3];
        u32 sjc_resp_high;
        u32 rsvd1[3];
-       u32 mac_addr_low;
+       u32 mac_addr0;
        u32 rsvd2[3];
-       u32 mac_addr_high;
+       u32 mac_addr1;
        u32 rsvd3[3];
-       u32 mac_addr2;
+       u32 mac_addr2; /*For i.MX6SX and i.MX6UL*/
        u32 rsvd4[7];
        u32 gp1;
        u32 rsvd5[3];
        u32 gp2;
        u32 rsvd6[3];
 };
-#else
-struct fuse_bank4_regs {
-       u32     sjc_resp_low;
-       u32     rsvd0[3];
-       u32     sjc_resp_high;
-       u32     rsvd1[3];
-       u32     mac_addr_low;
-       u32     rsvd2[3];
-       u32     mac_addr_high;
-       u32     rsvd3[0xb];
-       u32     gp1;
-       u32     rsvd4[3];
-       u32     gp2;
-       u32     rsvd5[3];
-};
-#endif
 
 struct aipstz_regs {
        u32     mprot0;
doc/README.imx6 +4 -2
index e26ab71..7c9a4ac 100644
@@ -7,7 +7,10 @@ SoC.
 -----------------------------------
 
 1.1 MAC Address: It is stored in fuse bank 4, with the 32 lsbs in word 2 and the
-    16 msbs in word 3.
+    16 msbs in word 3[15:0].
+    For i.MX6SX and i.MX6UL, they have two MAC addresses. The second MAC address
+    is stored in fuse bank 4, with the 16 lsb in word 3[31:16] and the 32 msbs in
+    word 4.
 
 Example:
 
--

1.7.4.1

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

reviewer
#3 lore raw

PATCH v2 1/2 mx6: soc: Add ENET2 mac address support

In reply to Ye Li

arch/arm/cpu/armv7/mx6/soc.c void imx_get_mac_from_fuse(int dev_id, unsigned char *mac) · line 368

Quoted 2 lines · Ye Li
arch/arm/cpu/armv7/mx6/soc.c +2 -0
+       if ((is_cpu_type(MXC_CPU_MX6SX) || is_cpu_type(MXC_CPU_MX6UL)) &&
+               1 == dev_id) {

dev_id == 1, please