Skip to contentSkip to conversation

ARM: imx: imx8mn-ddr4-evk: Fix boot from SD card

PATCH In review Marek Vasut 2 participants 5 messages Feb 13, 2022 – Feb 19, 2022

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

PATCH 1/2 ARM: imx: imx8mn-ddr4-evk: Fix boot from SD card

Enable missing config options to make the board boot from SD card.

Cc Fabio Estevam <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
---
 configs/imx8mn_evk_defconfig | 8 ++++++++
 1 file changed, 8 insertions(+)
configs/imx8mn_evk_defconfig +8 -0
index 865d657a6d1..1117096d6ee 100644
@@ -14,6 +14,7 @@ CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx8mn-evk"
 CONFIG_SPL_TEXT_BASE=0x912000
 CONFIG_TARGET_IMX8MN_EVK=y
+CONFIG_SPL_MMC=y
 CONFIG_SPL_SERIAL=y
 CONFIG_SPL_DRIVERS_MISC=y
 CONFIG_SPL=y
@@ -30,6 +31,9 @@ CONFIG_ARCH_MISC_INIT=y
 CONFIG_BOARD_LATE_INIT=y
 CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_BOOTROM_SUPPORT=y
+# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
+CONFIG_SPL_LEGACY_IMAGE_SUPPORT=y
+CONFIG_SPL_LEGACY_IMAGE_CRC_CHECK=y
 CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x300
@@ -64,9 +68,12 @@ CONFIG_MXC_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_MMC_IO_VOLTAGE=y
+CONFIG_SPL_MMC_IO_VOLTAGE=y
 CONFIG_MMC_UHS_SUPPORT=y
+CONFIG_SPL_MMC_UHS_SUPPORT=y
 CONFIG_MMC_HS400_ES_SUPPORT=y
 CONFIG_MMC_HS400_SUPPORT=y
+CONFIG_SPL_MMC_HS400_SUPPORT=y
 CONFIG_FSL_USDHC=y
 CONFIG_PHYLIB=y
 CONFIG_DM_ETH=y
@@ -76,6 +83,7 @@ CONFIG_PINCTRL_IMX8M=y
 CONFIG_DM_PMIC=y
 CONFIG_SPL_DM_PMIC_PCA9450=y
 CONFIG_DM_REGULATOR=y
+CONFIG_SPL_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
 CONFIG_MXC_UART=y
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 ARM: imx: imx8mn-ddr4-evk: Add ethernet support

Add support for ethernet on the imx8mn-ddr4-evk.

Cc Fabio Estevam <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
---
 arch/arm/dts/imx8mn-evk.dtsi            |  1 +
 board/freescale/imx8mn_evk/imx8mn_evk.c | 41 +++++++++++++++++++++++--
 configs/imx8mn_ddr4_evk_defconfig       |  8 +++++
 3 files changed, 47 insertions(+), 3 deletions(-)
arch/arm/dts/imx8mn-evk.dtsi +1 -0
index 76d042a4cf0..416fadb22b1 100644
@@ -53,6 +53,7 @@
 	pinctrl-0 = <&pinctrl_fec1>;
 	phy-mode = "rgmii-id";
 	phy-handle = <&ethphy0>;
+	phy-reset-gpios = <&gpio4 22 GPIO_ACTIVE_LOW>;
 	fsl,magic-packet;
 	status = "okay";
 
board/freescale/imx8mn_evk/imx8mn_evk.c +38 -3

55 lines not on this page · raw message

configs/imx8mn_ddr4_evk_defconfig +8 -0
index 28cc551dc41..a760709772f 100644
@@ -43,6 +43,9 @@ CONFIG_CMD_FUSE=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_PING=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
@@ -67,7 +70,12 @@ CONFIG_MMC_HS400_ES_SUPPORT=y
 CONFIG_MMC_HS400_SUPPORT=y
 CONFIG_FSL_USDHC=y
 CONFIG_PHYLIB=y
+CONFIG_PHY_ATHEROS=y
 CONFIG_DM_ETH=y
+CONFIG_DM_ETH_PHY=y
+CONFIG_PHY_GIGE=y
+CONFIG_FEC_MXC=y
+CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
 CONFIG_PINCTRL_IMX8M=y
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 2/2] ARM: imx: imx8mn-ddr4-evk: Add ethernet support

Hi Marek,

Quoted 7 lines · Marek Vasut

Add support for ethernet on the imx8mn-ddr4-evk.

Cc Fabio Estevam <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>

---

I have not pushed this patch because I am puzzled. There is nothing wrong in the patch, and I can apply it, but CI fails randomly. There is a warning during compilation of this board, see:

https://source.denx.de/u-boot/custodians/u-boot-imx/-/jobs/394060

However, this makes no sense. It looks like that

+ if (IS_ENABLED(CONFIG_FEC_MXC))
+ setup_fec();

This has effect, while during preprocessing of the same file:

+#if IS_ENABLED(CONFIG_FEC_MXC)
+static int setup_fec(void)

it looks like as "deactivated", no idea why. The warning makes no sense by reading the code. And if I build the board locally, with make or buildman, everything fine - no error at all. But, even locally, "buildman aarch64" reports this warning. No idea why, but I cannot add this to PR else the breakage goes into Tom's tree.

Of course, if I drop #if IS_ENABLED(CONFIG_FEC_MXC), everything fine, but it does not means it is a solution.

Best regards,
Stefano

Quoted 104 lines
  arch/arm/dts/imx8mn-evk.dtsi            |  1 +
  board/freescale/imx8mn_evk/imx8mn_evk.c | 41 +++++++++++++++++++++++--
  configs/imx8mn_ddr4_evk_defconfig       |  8 +++++
  3 files changed, 47 insertions(+), 3 deletions(-)
arch/arm/dts/imx8mn-evk.dtsi +1 -0
index 76d042a4cf0..416fadb22b1 100644
@@ -53,6 +53,7 @@
  	pinctrl-0 = <&pinctrl_fec1>;
  	phy-mode = "rgmii-id";
  	phy-handle = <&ethphy0>;
+	phy-reset-gpios = <&gpio4 22 GPIO_ACTIVE_LOW>;
  	fsl,magic-packet;
  	status = "okay";
 
board/freescale/imx8mn_evk/imx8mn_evk.c +38 -3
index 9a0a0488bf4..6979bbcbe52 100644
@@ -7,17 +7,52 @@
  #include <env.h>
  #include <init.h>
  #include <asm/global_data.h>
+#include <miiphy.h>
+#include <netdev.h>
+#include <asm/io.h>
 
  DECLARE_GLOBAL_DATA_PTR;
 
-int board_init(void)
+int board_mmc_get_env_dev(int devno)
+{
+	return devno;
+}
+
+#if IS_ENABLED(CONFIG_FEC_MXC)
+static int setup_fec(void)
  {
+	struct iomuxc_gpr_base_regs *gpr =
+		(struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
+
+	/* Use 125M anatop REF_CLK1 for ENET1, not from external */
+	clrsetbits_le32(&gpr->gpr[1], 0x2000, 0);
+
  	return 0;
  }
 
-int board_mmc_get_env_dev(int devno)
+int board_phy_config(struct phy_device *phydev)
  {
-	return devno;
+	/* enable rgmii rxc skew and phy mode select to RGMII copper */
+	phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f);
+	phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8);
+
+	phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x00);
+	phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x82ee);
+	phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05);
+	phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100);
+
+	if (phydev->drv->config)
+		phydev->drv->config(phydev);
+	return 0;
+}
+#endif
+
+int board_init(void)
+{
+	if (IS_ENABLED(CONFIG_FEC_MXC))
+		setup_fec();
+
+	return 0;
  }
 
  int board_late_init(void)
configs/imx8mn_ddr4_evk_defconfig +8 -0
index 28cc551dc41..a760709772f 100644
@@ -43,6 +43,9 @@ CONFIG_CMD_FUSE=y
  CONFIG_CMD_GPIO=y
  CONFIG_CMD_I2C=y
  CONFIG_CMD_MMC=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_PING=y
  CONFIG_CMD_CACHE=y
  CONFIG_CMD_REGULATOR=y
  CONFIG_CMD_EXT4_WRITE=y
@@ -67,7 +70,12 @@ CONFIG_MMC_HS400_ES_SUPPORT=y
  CONFIG_MMC_HS400_SUPPORT=y
  CONFIG_FSL_USDHC=y
  CONFIG_PHYLIB=y
+CONFIG_PHY_ATHEROS=y
  CONFIG_DM_ETH=y
+CONFIG_DM_ETH_PHY=y
+CONFIG_PHY_GIGE=y
+CONFIG_FEC_MXC=y
+CONFIG_MII=y
  CONFIG_PINCTRL=y
  CONFIG_SPL_PINCTRL=y
  CONFIG_PINCTRL_IMX8M=y
Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#3 lore raw

Re: [PATCH 2/2] ARM: imx: imx8mn-ddr4-evk: Add ethernet support

On 2/19/22 14:06, Stefano Babic wrote:

Hi,

[...]

Quoted 14 lines

I have not pushed this patch because I am puzzled. There is nothing wrong in the patch, and I can apply it, but CI fails randomly. There is a warning during compilation of this board, see:

https://source.denx.de/u-boot/custodians/u-boot-imx/-/jobs/394060

However, this makes no sense. It looks like that

+       if (IS_ENABLED(CONFIG_FEC_MXC))
+               setup_fec();

This has effect, while during preprocessing of the same file:

board/freescale/imx8mn_evk/imx8mn_evk.c +2 -0
+#if IS_ENABLED(CONFIG_FEC_MXC)
+static int setup_fec(void)
Quoted 3 lines

it looks like as "deactivated", no idea why. The warning makes no sense by reading the code. And if I build the board locally, with  make or buildman, everything fine - no error at all.  But, even locally, "buildman aarch64" reports this warning. No idea why, but I cannot add this to PR else the breakage goes into Tom's tree.

Of course, if I drop #if IS_ENABLED(CONFIG_FEC_MXC), everything fine, but it does not means it is a solution.

The ethernet on this board is always present, so maybe that is the solution here. Although I also don't know why this failed in the CI and not during local build, some clang detail maybe ?

#4 lore raw

PATCH 1/2 ARM: imx: imx8mn-ddr4-evk: Fix boot from SD card

In reply to Marek Vasut
Quoted 5 lines

Enable missing config options to make the board boot from SD card.

Cc Fabio Estevam <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>

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

Best regards,
Stefano Babic

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