Skip to contentSkip to conversation

imx8mn-var-som: fix ethernet for Variscite symphony board and imx8m nano SOM

PATCH Superseded Hugo Villeneuve 2 participants 12 messages May 25, 2023 – Jul 12, 2023

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

v2 cover imx8mn-var-som: fix ethernet for Variscite symphony board and imx8m nano SOM

From: Hugo Villeneuve <[email protected]>

Hello,
This patch series fixes bugs and add missing features related to the ethernet PHY on Variscite symphony carrier board with an imx8m nano SOM (P/N VAR-SOM-MX8M-NANO).

Ethernet functionality is currently broken for the VAR-SOM-MX8M-NANO.

Variscite imx8m nano SOM comes in multiple hardware configuration options. One of this hardware configuration option is called EC:
EC: Ethernet Controller PHY assembled on SOM

For SOM with the EC configuration, the ethernet PHY is located on the SOM itself, and connected to the CPU ethernet controller. It has a reset line controlled via GPIO1_IO9. In this configuration, the PHY located on the carrier board is not connected to anything and is therefore not used.

For SOM without EC configuration, the ethernet PHY on the carrier board is connected to the CPU ethernet controller. It has a reset line controlled via the GPIO expander PCA9534_IO5.

Patch 1 add code to read and display the SOM configuration stored in the SOM EEPROM. Part of this patch was submitted and accepted to the Linux kernel (section that adds the EEPROM to the device tree), so that it will be easier to sync the DT between kernel and U-Boot.

Patch 2 fixes bugs with the PHY reset properties.

Patch 3 fixes a bug with a missing PHY reset deassert delay (also submitted and accepted to kernel).

Patch 4 enables automatic read of PHY MAC address from the SOM EEPROM.

Patch 5 is used for auto-detecting at runtime the SOM hardware configuration option related to the PHY (EC), and dynamically adjust the device tree to support both SOM PHY options.

I have succesfully tested the changes on a Variscite symphony carrier board with a VAR-SOM-MX8M-NANO having the EC configuration option.

Unfortunately, I do not have a VAR-SOM-MX8M-NANO with a non-EC configuration option so I couldn't test it on real hardware, altough I simulated it and confirmed that the device tree fixing seems to be correct by using debug/print statements.

Thank you.

Changes for V2:
- Resend since I received 0 answers/comments after almost 4 weeks and I have a few minor updates to add:
- Update defconfig using savedefconfig
- Remove requirement about required patch (now in master)
- Update status of patches also sent to the Linux kernel

Hugo Villeneuve (5):
imx8mn-var-som: read and print SoM infos from eeprom on startup
imx8mn-var-som: fix non-applied PHY reset-gpios properties
arm: dts: imx8mn-var-som: fix PHY detection bug by adding deassert
delay
imx8mn-var-som: read eth MAC address from EEPROM
imx8mn-var-som: adjust PHY reset gpios according to hardware
configuration

 .../dts/imx8mn-var-som-symphony-u-boot.dtsi   |  17 ++
 arch/arm/dts/imx8mn-var-som-symphony.dts      |   4 -
 arch/arm/dts/imx8mn-var-som.dtsi              |  18 +-
 arch/arm/mach-imx/imx8m/Kconfig               |   4 +
 .../variscite/imx8mn_var_som/imx8mn_var_som.c | 214 ++++++++++++++++++
 configs/imx8mn_var_som_defconfig              |   4 +
 6 files changed, 256 insertions(+), 5 deletions(-)

base-commit: 62df7a39442902a71259568c13a4d496d5a514f4

Signature · 1 line
2.30.2
#1 lore raw

PATCH v2 1/5 imx8mn-var-som: read and print SoM infos from eeprom on startup

From: Hugo Villeneuve <[email protected]>

Enable support to read and display configuration/manufacturing infos from 4Kbit EEPROM located on SOM board.

Note: CONFIG_DISPLAY_BOARDINFO is automatically selected for ARM arch.

---
 .../dts/imx8mn-var-som-symphony-u-boot.dtsi   |   4 +
 arch/arm/dts/imx8mn-var-som.dtsi              |  10 ++
 arch/arm/mach-imx/imx8m/Kconfig               |   2 +
 .../variscite/imx8mn_var_som/imx8mn_var_som.c | 134 ++++++++++++++++++
 configs/imx8mn_var_som_defconfig              |   1 +
 5 files changed, 151 insertions(+)
arch/arm/dts/imx8mn-var-som-symphony-u-boot.dtsi +4 -0
index af80aaea0b..7272fc2b4c 100644
@@ -68,3 +68,7 @@
 &usdhc3 {
 	bootph-pre-ram;
 };
+
+&eeprom_som {
+	bootph-pre-ram;
+};
arch/arm/dts/imx8mn-var-som.dtsi +10 -0
index 87b5e23c76..dea9eff3f0 100644
@@ -11,6 +11,10 @@
 	model = "Variscite VAR-SOM-MX8MN module";
 	compatible = "variscite,var-som-mx8mn", "fsl,imx8mn";
 
+	aliases {
+		eeprom-som = &eeprom_som;
+	};
+
 	chosen {
 		stdout-path = &uart4;
 	};
@@ -222,6 +226,12 @@
 			};
 		};
 	};
+
+	eeprom_som: eeprom@52 {
+		compatible = "atmel,24c04";
+		reg = <0x52>;
+		pagesize = <16>;
+	};
 };
 
 &i2c3 {
arch/arm/mach-imx/imx8m/Kconfig +2 -0
index 7639439bdc..3450399d6f 100644
@@ -245,6 +245,8 @@ config TARGET_IMX8MN_VAR_SOM
 	select IMX8MN
 	select SUPPORT_SPL
 	select IMX8M_DDR4
+	select MISC
+	select I2C_EEPROM
 
 config TARGET_KONTRON_PITX_IMX8M
 	bool "Support Kontron pITX-imx8m"
board/variscite/imx8mn_var_som/imx8mn_var_som.c +134 -0

148 lines not on this page · raw message

configs/imx8mn_var_som_defconfig +1 -0
index 1b4f94c124..f8bbdb6935 100644
@@ -29,6 +29,7 @@ CONFIG_SPL_LOAD_FIT=y
 CONFIG_OF_SYSTEM_SETUP=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_DEFAULT_FDT_FILE="freescale/imx8mn-var-som-symphony.dtb"
+CONFIG_BOARD_TYPES=y
 CONFIG_ARCH_MISC_INIT=y
 CONFIG_SPL_MAX_SIZE=0x25000
 CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
Signature · 1 line
2.30.2
#2 lore raw

PATCH v2 1/5 imx8mn-var-som: read and print SoM infos from eeprom on startup

Quoted 5 lines

From: Hugo Villeneuve <[email protected]>
Enable support to read and display configuration/manufacturing infos from 4Kbit EEPROM located on SOM board.
Note: CONFIG_DISPLAY_BOARDINFO is automatically selected for ARM arch.

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#3 lore raw

PATCH v2 2/5 imx8mn-var-som: fix non-applied PHY reset-gpios properties

In reply to Hugo Villeneuve

From: Hugo Villeneuve <[email protected]>

Select DM_ETH_PHY so that the reset-gpios property of the ethphy node can be used.

Also select DM_PCA953X, which is needed for resetting the ethernet PHY on the carrier board via the PCA9534 I/O expander.

Commit 4e5114daf9eb ("imx8mn: synchronise device tree with linux") did synchronise device tree with linux, which in effect removed obsolete PHY reset properties and replaced them with new mdio DM properties. But the commit didn't activate DM_ETH_PHY or DM_PCA953X.

Fixes 4e5114daf9eb ("imx8mn: synchronise device tree with linux")
---
 arch/arm/mach-imx/imx8m/Kconfig  | 1 +
 configs/imx8mn_var_som_defconfig | 1 +
 2 files changed, 2 insertions(+)
arch/arm/mach-imx/imx8m/Kconfig +1 -0
index 3450399d6f..a940d8a950 100644
@@ -247,6 +247,7 @@ config TARGET_IMX8MN_VAR_SOM
 	select IMX8M_DDR4
 	select MISC
 	select I2C_EEPROM
+	select DM_ETH_PHY
 
 config TARGET_KONTRON_PITX_IMX8M
 	bool "Support Kontron pITX-imx8m"
configs/imx8mn_var_som_defconfig +1 -0
index f8bbdb6935..f0e232081f 100644
@@ -77,6 +77,7 @@ CONFIG_FASTBOOT_FLASH=y
 CONFIG_FASTBOOT_UUU_SUPPORT=y
 CONFIG_FASTBOOT_FLASH_MMC_DEV=2
 CONFIG_MXC_GPIO=y
+CONFIG_DM_PCA953X=y
 CONFIG_DM_I2C=y
 CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_MMC_IO_VOLTAGE=y
Signature · 1 line
2.30.2
#4 lore raw

PATCH v2 2/5 imx8mn-var-som: fix non-applied PHY reset-gpios properties

Quoted 11 lines

From: Hugo Villeneuve <[email protected]>
Select DM_ETH_PHY so that the reset-gpios property of the ethphy node can be used.
Also select DM_PCA953X, which is needed for resetting the ethernet PHY on the carrier board via the PCA9534 I/O expander. Commit 4e5114daf9eb ("imx8mn: synchronise device tree with linux") did synchronise device tree with linux, which in effect removed obsolete PHY reset properties and replaced them with new mdio DM properties. But the commit didn't activate DM_ETH_PHY or DM_PCA953X.

Fixes 4e5114daf9eb ("imx8mn: synchronise device tree with linux")

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#5 lore raw

PATCH v2 3/5 arm: dts: imx8mn-var-som: fix PHY detection bug by adding deassert delay

In reply to Hugo Villeneuve

From: Hugo Villeneuve <[email protected]>

While testing the ethernet interface on a Variscite symphony carrier board using an imx8mn SOM with an onboard ADIN1300 PHY (EC hardware configuration), the ethernet PHY is not detected.

The ADIN1300 datasheet indicate that the "Management interface active (t4)" state is reached at most 5ms after the reset signal is deasserted.

The device tree in Variscite custom git repository uses the following property:

    phy-reset-post-delay = <20>;

Add a new MDIO property 'reset-deassert-us' of 20ms to have the same delay inside the ethphy node. Adding this property fixes the problem with the PHY detection.

Note that this SOM can also have an Atheros AR8033 PHY. In this case, a 1ms deassert delay is sufficient. Add a comment to that effect.

Fixes c4c1ed68c1e8 ("imx8mn_var_som: Add support for Variscite

VAR-SOM-MX8M-NANO board")

---
 arch/arm/dts/imx8mn-var-som.dtsi | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
arch/arm/dts/imx8mn-var-som.dtsi +7 -1
index dea9eff3f0..4eb578a03f 100644
@@ -102,11 +102,17 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		ethphy: ethernet-phy@4 {
+		ethphy: ethernet-phy@4 { /* AR8033 or ADIN1300 */
 			compatible = "ethernet-phy-ieee802.3-c22";
 			reg = <4>;
 			reset-gpios = <&gpio1 9 GPIO_ACTIVE_LOW>;
 			reset-assert-us = <10000>;
+			/*
+			 * Deassert delay:
+			 * ADIN1300 requires 5ms.
+			 * AR8033   requires 1ms.
+			 */
+			reset-deassert-us = <20000>;
 		};
 	};
 };
Signature · 1 line
2.30.2
#6 lore raw

PATCH v2 3/5 arm: dts: imx8mn-var-som: fix PHY detection bug by adding deassert delay

Quoted 10 lines

From: Hugo Villeneuve <[email protected]>
While testing the ethernet interface on a Variscite symphony carrier board using an imx8mn SOM with an onboard ADIN1300 PHY (EC hardware configuration), the ethernet PHY is not detected.
The ADIN1300 datasheet indicate that the "Management interface active (t4)" state is reached at most 5ms after the reset signal is deasserted.
The device tree in Variscite custom git repository uses the following property:

    phy-reset-post-delay = <20>;
Quoted 8 lines

Add a new MDIO property 'reset-deassert-us' of 20ms to have the same delay inside the ethphy node. Adding this property fixes the problem with the PHY detection.
Note that this SOM can also have an Atheros AR8033 PHY. In this case, a 1ms deassert delay is sufficient. Add a comment to that effect.

Fixes c4c1ed68c1e8 ("imx8mn_var_som: Add support for Variscite

VAR-SOM-MX8M-NANO board")

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#7 lore raw

PATCH v2 4/5 imx8mn-var-som: read eth MAC address from EEPROM

In reply to Hugo Villeneuve

From: Hugo Villeneuve <[email protected]>

Read ethernet MAC address from EEPROM located on the SOM.

---
 arch/arm/dts/imx8mn-var-som-symphony-u-boot.dtsi | 13 +++++++++++++
 arch/arm/mach-imx/imx8m/Kconfig                  |  1 +
 2 files changed, 14 insertions(+)
arch/arm/dts/imx8mn-var-som-symphony-u-boot.dtsi +13 -0
index 7272fc2b4c..e0caf3179e 100644
@@ -13,6 +13,19 @@
 	bootph-pre-ram;
 };
 
+&eeprom_som {
+	#address-cells = <1>;
+	#size-cells = <1>;
+	eth_mac_address: eth-mac-address@19 {
+		reg = <0x19 0x06>;
+	};
+};
+
+&fec1 {
+	nvmem-cells = <&eth_mac_address>;
+	nvmem-cell-names = "mac-address";
+};
+
 &gpio1 {
 	bootph-pre-ram;
 };
arch/arm/mach-imx/imx8m/Kconfig +1 -0
index a940d8a950..67db3e46ec 100644
@@ -248,6 +248,7 @@ config TARGET_IMX8MN_VAR_SOM
 	select MISC
 	select I2C_EEPROM
 	select DM_ETH_PHY
+	select NVMEM
 
 config TARGET_KONTRON_PITX_IMX8M
 	bool "Support Kontron pITX-imx8m"
Signature · 1 line
2.30.2
#8 lore raw

PATCH v2 4/5 imx8mn-var-som: read eth MAC address from EEPROM

Quoted 3 lines

From: Hugo Villeneuve <[email protected]> Read ethernet MAC address from EEPROM located on the SOM.

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#9 lore raw

PATCH v2 5/5 imx8mn-var-som: adjust PHY reset gpios according to hardware configuration

In reply to Hugo Villeneuve

From: Hugo Villeneuve <[email protected]>

For SOM with the EC configuration, the ethernet PHY is located on the SOM itself, and connected to the CPU ethernet controller. It has a reset line controlled via GPIO1_IO9. In this configuration, the PHY located on the carrier board is not connected to anything and is therefore not used.

For SOM without EC configuration, the ethernet PHY on the carrier board is connected to the CPU ethernet controller. It has a reset line controlled via the GPIO expander PCA9534_IO5.

The hardware configuration (EC) is determined at runtime by reading from the SOM EEPROM.

To support both hardware configurations (EC and non-EC), adjust/fix the PHY reset gpios according to the hardware configuration read at runtime from the SOM EEPROM. This adjustement is done in U-Boot (OF_BOARD_FIXUP) and kernel (OF_BOARD_SETUP) device trees.

---
 arch/arm/dts/imx8mn-var-som-symphony.dts      |  4 -
 .../variscite/imx8mn_var_som/imx8mn_var_som.c | 80 +++++++++++++++++++
 configs/imx8mn_var_som_defconfig              |  2 +
 3 files changed, 82 insertions(+), 4 deletions(-)
arch/arm/dts/imx8mn-var-som-symphony.dts +0 -4
index 3ed7021a48..5c8e4e8175 100644
@@ -56,10 +56,6 @@
 	};
 };
 
-&ethphy {
-	reset-gpios = <&pca9534 5 GPIO_ACTIVE_HIGH>;
-};
-
 &i2c2 {
 	clock-frequency = <400000>;
 	pinctrl-names = "default";
board/variscite/imx8mn_var_som/imx8mn_var_som.c +80 -0

90 lines not on this page · raw message

configs/imx8mn_var_som_defconfig +2 -0
index f0e232081f..d8a442d623 100644
@@ -22,10 +22,12 @@ CONFIG_SPL_SYS_MALLOC_F_LEN=0x2000
 CONFIG_SPL=y
 CONFIG_SPL_IMX_ROMAPI_LOADADDR=0x48000000
 CONFIG_SYS_LOAD_ADDR=0x40480000
+CONFIG_OF_BOARD_FIXUP=y
 CONFIG_SYS_MONITOR_LEN=524288
 CONFIG_FIT=y
 CONFIG_FIT_EXTERNAL_OFFSET=0x3000
 CONFIG_SPL_LOAD_FIT=y
+CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_SYSTEM_SETUP=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_DEFAULT_FDT_FILE="freescale/imx8mn-var-som-symphony.dtb"
Signature · 1 line
2.30.2
#10 lore raw

PATCH v2 5/5 imx8mn-var-som: adjust PHY reset gpios according to hardware configuration

Quoted 15 lines

From: Hugo Villeneuve <[email protected]>
For SOM with the EC configuration, the ethernet PHY is located on the SOM itself, and connected to the CPU ethernet controller. It has a reset line controlled via GPIO1_IO9. In this configuration, the PHY located on the carrier board is not connected to anything and is therefore not used.
For SOM without EC configuration, the ethernet PHY on the carrier board is connected to the CPU ethernet controller. It has a reset line controlled via the GPIO expander PCA9534_IO5.
The hardware configuration (EC) is determined at runtime by reading from the SOM EEPROM.
To support both hardware configurations (EC and non-EC), adjust/fix the PHY reset gpios according to the hardware configuration read at runtime from the SOM EEPROM. This adjustement is done in U-Boot (OF_BOARD_FIXUP) and kernel (OF_BOARD_SETUP) device trees.

Quoted 1 line

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#11 lore raw

PATCH v2 5/5 imx8mn-var-som: adjust PHY reset gpios according to hardware configuration

In reply to Hugo Villeneuve
Quoted 15 lines

From: Hugo Villeneuve <[email protected]>
For SOM with the EC configuration, the ethernet PHY is located on the SOM itself, and connected to the CPU ethernet controller. It has a reset line controlled via GPIO1_IO9. In this configuration, the PHY located on the carrier board is not connected to anything and is therefore not used.
For SOM without EC configuration, the ethernet PHY on the carrier board is connected to the CPU ethernet controller. It has a reset line controlled via the GPIO expander PCA9534_IO5.
The hardware configuration (EC) is determined at runtime by reading from the SOM EEPROM.
To support both hardware configurations (EC and non-EC), adjust/fix the PHY reset gpios according to the hardware configuration read at runtime from the SOM EEPROM. This adjustement is done in U-Boot (OF_BOARD_FIXUP) and kernel (OF_BOARD_SETUP) device trees.

Quoted 1 line

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================