Skip to contentSkip to conversation

ARM: dts: stm32: Update eth1addr from EEPROM if eth1 present

PATCH New Marek Vasut 2 participants 3 messages Jul 30, 2020 – Aug 13, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: dts: stm32: Update eth1addr from EEPROM if eth1 present

The STM32MP1 DHCOM has two ethernet interfaces, the on-SoM DWMAC and KS8851. Set eth1addr for the KS8851 to a MAC address of the DWMAC incremented by 1. The MAC of the DWMAC is set from on-SoM EEPROM already, but the MAC address of KS8851 was left uninitialized, so fix this.

Cc Patrice Chotard <[email protected]>
Cc Patrick Delaunay <[email protected]>
---
 arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi |  1 +
 board/dhelectronics/dh_stm32mp1/board.c    | 25 ++++++++++++++++++++--
 2 files changed, 24 insertions(+), 2 deletions(-)
arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +1 -0
index f96de9e7a3..92345b7ba3 100644
@@ -18,6 +18,7 @@
 		mmc1 = &sdmmc2;
 		spi0 = &qspi;
 		usb0 = &usbotg_hs;
+		ethernet1 = &ksz8851;
 	};
 
 	config {
board/dhelectronics/dh_stm32mp1/board.c +23 -2
index 17dbf20d76..17018716fd 100644
@@ -84,11 +84,26 @@ DECLARE_GLOBAL_DATA_PTR;
 int setup_mac_address(void)
 {
 	unsigned char enetaddr[6];
+	bool skip_eth0 = false;
+	bool skip_eth1 = false;
 	struct udevice *dev;
 	int off, ret;
 
 	ret = eth_env_get_enetaddr("ethaddr", enetaddr);
 	if (ret)	/* ethaddr is already set */
+		skip_eth0 = true;
+
+	off = fdt_path_offset(gd->fdt_blob, "ethernet1");
+	if (off < 0) {
+		/* ethernet1 is not present in the system */
+		skip_eth1 = true;
+	} else {
+		ret = eth_env_get_enetaddr("eth1addr", enetaddr);
+		if (ret)	/* eth1addr is already set */
+			skip_eth1 = true;
+	}
+
+	if (skip_eth0 && skip_eth1)
 		return 0;
 
 	off = fdt_path_offset(gd->fdt_blob, "eeprom0");
@@ -109,8 +124,14 @@ int setup_mac_address(void)
 		return ret;
 	}
 
-	if (is_valid_ethaddr(enetaddr))
-		eth_env_set_enetaddr("ethaddr", enetaddr);
+	if (is_valid_ethaddr(enetaddr)) {
+		if (!skip_eth0)
+			eth_env_set_enetaddr("ethaddr", enetaddr);
+
+		enetaddr[5]++;
+		if (!skip_eth1)
+			eth_env_set_enetaddr("eth1addr", enetaddr);
+	}
 
 	return 0;
 }
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/1 ARM: dts: stm32: Update eth1addr from EEPROM if eth1 present

Hi Marek

Quoted 63 lines · Marek Vasut

The STM32MP1 DHCOM has two ethernet interfaces, the on-SoM DWMAC and KS8851. Set eth1addr for the KS8851 to a MAC address of the DWMAC incremented by 1. The MAC of the DWMAC is set from on-SoM EEPROM already, but the MAC address of KS8851 was left uninitialized, so fix this.

Cc Patrice Chotard <[email protected]>
Cc Patrick Delaunay <[email protected]>
---
 arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi |  1 +
 board/dhelectronics/dh_stm32mp1/board.c    | 25 ++++++++++++++++++++--
 2 files changed, 24 insertions(+), 2 deletions(-)
arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +1 -0
index f96de9e7a3..92345b7ba3 100644
@@ -18,6 +18,7 @@
 		mmc1 = &sdmmc2;
 		spi0 = &qspi;
 		usb0 = &usbotg_hs;
+		ethernet1 = &ksz8851;
 	};
 
 	config {
board/dhelectronics/dh_stm32mp1/board.c +16 -2
index 17dbf20d76..17018716fd 100644
@@ -84,11 +84,26 @@ DECLARE_GLOBAL_DATA_PTR;
 int setup_mac_address(void)
 {
 	unsigned char enetaddr[6];
+	bool skip_eth0 = false;
+	bool skip_eth1 = false;
 	struct udevice *dev;
 	int off, ret;
 
 	ret = eth_env_get_enetaddr("ethaddr", enetaddr);
 	if (ret)	/* ethaddr is already set */
+		skip_eth0 = true;
+
+	off = fdt_path_offset(gd->fdt_blob, "ethernet1");
+	if (off < 0) {
+		/* ethernet1 is not present in the system */
+		skip_eth1 = true;
+	} else {
+		ret = eth_env_get_enetaddr("eth1addr", enetaddr);
+		if (ret)	/* eth1addr is already set */
+			skip_eth1 = true;
+	}
+
+	if (skip_eth0 && skip_eth1)
 		return 0;
 
 	off = fdt_path_offset(gd->fdt_blob, "eeprom0");
@@ -109,8 +124,14 @@ int setup_mac_address(void)
 		return ret;
 	}
 
-	if (is_valid_ethaddr(enetaddr))
-		eth_env_set_enetaddr("ethaddr", enetaddr);
+	if (is_valid_ethaddr(enetaddr)) {

board/dhelectronics/dh_stm32mp1/board.c int setup_mac_address(void) · line 137

Quoted 10 lines
board/dhelectronics/dh_stm32mp1/board.c +7 -0
+		if (!skip_eth0)
+			eth_env_set_enetaddr("ethaddr", enetaddr);
+
+		enetaddr[5]++;
+		if (!skip_eth1)
+			eth_env_set_enetaddr("eth1addr", enetaddr);
+	}
 
 	return 0;
 }

Thanks

Patrice

#2 lore raw

PATCH 1/1 ARM: dts: stm32: Update eth1addr from EEPROM if eth1 present

Quoted 15 lines · Patrice CHOTARD

Hi Marek

Quoted 12 lines · Marek Vasut

The STM32MP1 DHCOM has two ethernet interfaces, the on-SoM DWMAC and KS8851. Set eth1addr for the KS8851 to a MAC address of the DWMAC incremented by 1. The MAC of the DWMAC is set from on-SoM EEPROM already, but the MAC address of KS8851 was left uninitialized, so fix this.

Cc Patrice Chotard <[email protected]>
Cc Patrick Delaunay <[email protected]>
---
 arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi |  1 +
 board/dhelectronics/dh_stm32mp1/board.c    | 25 ++++++++++++++++++++--
 2 files changed, 24 insertions(+), 2 deletions(-)

Applied on u-boot-stm/master

Thanks

Quoted 67 lines
Quoted 51 lines
arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +1 -0
index f96de9e7a3..92345b7ba3 100644
@@ -18,6 +18,7 @@
 		mmc1 = &sdmmc2;
 		spi0 = &qspi;
 		usb0 = &usbotg_hs;
+		ethernet1 = &ksz8851;
 	};
 
 	config {
board/dhelectronics/dh_stm32mp1/board.c +16 -2
index 17dbf20d76..17018716fd 100644
@@ -84,11 +84,26 @@ DECLARE_GLOBAL_DATA_PTR;
 int setup_mac_address(void)
 {
 	unsigned char enetaddr[6];
+	bool skip_eth0 = false;
+	bool skip_eth1 = false;
 	struct udevice *dev;
 	int off, ret;
 
 	ret = eth_env_get_enetaddr("ethaddr", enetaddr);
 	if (ret)	/* ethaddr is already set */
+		skip_eth0 = true;
+
+	off = fdt_path_offset(gd->fdt_blob, "ethernet1");
+	if (off < 0) {
+		/* ethernet1 is not present in the system */
+		skip_eth1 = true;
+	} else {
+		ret = eth_env_get_enetaddr("eth1addr", enetaddr);
+		if (ret)	/* eth1addr is already set */
+			skip_eth1 = true;
+	}
+
+	if (skip_eth0 && skip_eth1)
 		return 0;
 
 	off = fdt_path_offset(gd->fdt_blob, "eeprom0");
@@ -109,8 +124,14 @@ int setup_mac_address(void)
 		return ret;
 	}
 
-	if (is_valid_ethaddr(enetaddr))
-		eth_env_set_enetaddr("ethaddr", enetaddr);
+	if (is_valid_ethaddr(enetaddr)) {

board/dhelectronics/dh_stm32mp1/board.c int setup_mac_address(void) · line 137

Quoted 10 lines
board/dhelectronics/dh_stm32mp1/board.c +7 -0
+		if (!skip_eth0)
+			eth_env_set_enetaddr("ethaddr", enetaddr);
+
+		enetaddr[5]++;
+		if (!skip_eth1)
+			eth_env_set_enetaddr("eth1addr", enetaddr);
+	}
 
 	return 0;
 }

Thanks

Patrice