ARM: imx: imx8mn-ddr4-evk: Add ethernet support
Subsystems (2)
PATCH v2 1/1 ARM: imx: imx8mn-ddr4-evk: Add ethernet support
Add support for ethernet on the imx8mn-ddr4-evk.
---
V2: Get rid of the IS_ENABLED macros, the ethernet on this board
is always present
--- arch/arm/dts/imx8mn-evk.dtsi | 1 + board/freescale/imx8mn_evk/imx8mn_evk.c | 36 ++++++++++++++++++++++--- configs/imx8mn_ddr4_evk_defconfig | 5 ++++ 3 files changed, 39 insertions(+), 3 deletions(-)
arch/arm/dts/imx8mn-evk.dtsi +1 -0
@@ -53,6 +53,7 @@ pinctrl-0 = <&pinctrl_fec1>; phy-mode = "rgmii-id"; phy-handle = <ðphy0>; + phy-reset-gpios = <&gpio4 22 GPIO_ACTIVE_LOW>; fsl,magic-packet; status = "okay";
board/freescale/imx8mn_evk/imx8mn_evk.c +33 -3
@@ -7,17 +7,47 @@#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; +} + +static void 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 ); +} + +int board_phy_config (struct phy_device *phydev) +{ +/* 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 ; } -int board_mmc_get_env_dev (int devno) +int board_init (void ) { -return devno; +setup_fec (); + +return 0 ; }int board_late_init (void )
configs/imx8mn_ddr4_evk_defconfig +5 -0
@@ -67,7 +67,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
PATCH v2 1/1 ARM: imx: imx8mn-ddr4-evk: Add ethernet support
Quoted 5 lines
Add support for ethernet on the imx8mn-ddr4-evk.
Signed-off-by Marek Vasut <[email protected]>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] =====================================================================
Hi Marek,
board/freescale/imx8mn_evk/imx8mn_evk.c line 39
Quoted 10 lines
board/freescale/imx8mn_evk/imx8mn_evk.c +10
-0+int board_phy_config (struct phy_device *phydev) +{ +/* 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 );
This is a AR8031, correct? Is there a reason why you don't use the device tree binding to set RGMII voltage, and RX and tx delays?
-michael
On 2/21/22 11:10, Michael Walle wrote:
Hi,
Quoted 5 lines
Quoted 5 lines
board/freescale/imx8mn_evk/imx8mn_evk.c +5
-0+int board_phy_config (struct phy_device *phydev) +{ +/* 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 );
Quoted 8 lines
board/freescale/imx8mn_evk/imx8mn_evk.c line 39
Quoted 5 lines
board/freescale/imx8mn_evk/imx8mn_evk.c +5
-0+ +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 );This is a AR8031, correct? Is there a reason why you don't use the device tree binding to set RGMII voltage, and RX and tx delays?
I quickly cobbled this together from another board, since I needed ethernet to do other tests with this board and the ethernet support was missing. If you can send subsequent patch to flip this to DT-only setup, I can test the patch on the board.
PHY should be AR8031, yes.
Hi Marek,
Am 21.02.22 um 17:49 schrieb Marek Vasut:
Quoted 18 lines · Michael Walle
Hi,
Quoted 5 lines
Quoted 5 lines
board/freescale/imx8mn_evk/imx8mn_evk.c +5
-0+int board_phy_config (struct phy_device *phydev) +{ + /* 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);Quoted 8 lines
Quoted 5 lines
+
+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);This is a AR8031, correct? Is there a reason why you don't use the device tree binding to set RGMII voltage, and RX and tx delays?
Quoted 4 lines
I quickly cobbled this together from another board, since I needed ethernet to do other tests with this board and the ethernet support was missing. If you can send subsequent patch to flip this to DT-only setup, I can test the patch on the board.
So why don't you post it as RFC?
To be honest it seems a bit contradictory that you normally take a critical position on other people's patches when they use legacy code instead of DM/DT (which is alright) and then send a half-baked approach yourself and expect other people to fix it for you afterwards.
I don't want to complain, it just occurred to me.
Frieder
Quoted 1 line · Frieder Schrempf
Hi Marek,
Hi,
Quoted 19 lines
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
board/freescale/imx8mn_evk/imx8mn_evk.c +5
-0+int board_phy_config (struct phy_device *phydev) +{ + /* 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);Quoted 8 lines
Quoted 5 lines
+
+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);This is a AR8031, correct? Is there a reason why you don't use the device tree binding to set RGMII voltage, and RX and tx delays?
Quoted 4 lines
I quickly cobbled this together from another board, since I needed ethernet to do other tests with this board and the ethernet support was missing. If you can send subsequent patch to flip this to DT-only setup, I can test the patch on the board.
Quoted 7 lines
So why don't you post it as RFC?
To be honest it seems a bit contradictory that you normally take a critical position on other people's patches when they use legacy code instead of DM/DT (which is alright) and then send a half-baked approach yourself and expect other people to fix it for you afterwards.I don't want to complain, it just occurred to me.
It's just a patch I had half-baked in a tree for over a year, so I sent it. It didn't occur to me there is now a way to do this in DT, since the patch was in my tree for so long and I only dealt with the ar803x PHY recently. I will try and convert this to DT next time I have the board on my desk, but if someone is faster ... even better.
Hi Marek,
Am 2022-02-21 17:49, schrieb Marek Vasut:
Quoted 15 lines · Michael Walle
Quoted 5 lines
Quoted 5 lines
board/freescale/imx8mn_evk/imx8mn_evk.c +5
-0+int board_phy_config (struct phy_device *phydev) +{ +/* 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 );Quoted 8 lines
board/freescale/imx8mn_evk/imx8mn_evk.c line 39
Quoted 5 lines
board/freescale/imx8mn_evk/imx8mn_evk.c +5
-0+ +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 );This is a AR8031, correct? Is there a reason why you don't use the device tree binding to set RGMII voltage, and RX and tx delays?
Quoted 4 lines
I quickly cobbled this together from another board, since I needed ethernet to do other tests with this board and the ethernet support was missing. If you can send subsequent patch to flip this to DT-only setup, I can test the patch on the board.
I neither have this board, nor do I care much about it. I just saw the usual hardcoded atheros phy settings being done in the board setup. That being said, you can find an example in:
arch/arm/dts/fsl-ls1028a-kontron-sl28-var4.dts
But you have to figure out what you need. I guess the last four writes are the rgmii delays which are handled by
phy-mode = "rgmii-id";
The 0x8 to 0x1f is 1.8V RGMII voltage, you'd need to look at the schematics if that voltage is actually used. A Zero means 1.5V. If it's using 2.5V then you don't have to do anything because an external regulator is used.
-michael
Quoted 1 line · Michael Walle
Hi Marek,
Hi,
Quoted 26 lines
Am 2022-02-21 17:49, schrieb Marek Vasut:
Quoted 15 lines · Michael Walle
Quoted 5 lines
Quoted 5 lines
board/freescale/imx8mn_evk/imx8mn_evk.c +5
-0+int board_phy_config (struct phy_device *phydev) +{ + /* 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);Quoted 8 lines
Quoted 5 lines
+
+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);This is a AR8031, correct? Is there a reason why you don't use the device tree binding to set RGMII voltage, and RX and tx delays?
Quoted 4 lines
I quickly cobbled this together from another board, since I needed ethernet to do other tests with this board and the ethernet support was missing. If you can send subsequent patch to flip this to DT-only setup, I can test the patch on the board.
I neither have this board, nor do I care much about it. I just saw the usual hardcoded atheros phy settings being done in the board setup. That being said, you can find an example in:
arch/arm/dts/fsl-ls1028a-kontron-sl28-var4.dts
Quoted 8 lines
But you have to figure out what you need. I guess the last four writes are the rgmii delays which are handled by
phy-mode = "rgmii-id";The
0x8to0x1fis 1.8V RGMII voltage, you'd need to look at the schematics if that voltage is actually used. A Zero means 1.5V. If it's using 2.5V then you don't have to do anything because an external regulator is used.
One might almost think that's what NXP should've done for a while, considering this is a devkit and missing ethernet is a problem for any network boot.
So unless NXP is faster, I will try and convert this to DT next time I have the board on my desk.