[PATCH 0/4] imx93: add DWC EQoS MAC driver support

This series makes the DWC EQos MAC work on i.MX93. It depends on the i.MX93 CCF driver: https://lore.kernel.org/u-boot/20230725080856.26567-1-sebastien.szymanski@ar...
Tested on i.MX93 EVK board: u-boot=> dhcp ethernet@428a0000 Waiting for PHY auto negotiation to complete........ done BOOTP broadcast 1 *** Unhandled DHCP Option in OFFER/ACK: 125 *** Unhandled DHCP Option in OFFER/ACK: 125 DHCP client bound to address 192.168.1.50 (35 ms)
u-boot=> ping 192.168.1.51 Using ethernet@428a0000 device host 192.168.1.51 is alive u-boot=>
Sébastien Szymanski (4): net: dwc_eth_qos: add i.MX93 support net: dwc_eth_qos: Add board_interface_eth_init() for i.MX93 net: phy: realtek: Add support for RTL8211F(D)(I)-VD-CG arm: dts: imx93-evk: remove wrong eqos compatible string
arch/arm/dts/imx93-11x11-evk-u-boot.dtsi | 4 -- arch/arm/mach-imx/imx9/clock.c | 53 ++++++++++++++++++++++++ board/freescale/imx93_evk/imx93_evk.c | 16 ------- drivers/net/dwc_eth_qos.c | 4 ++ drivers/net/dwc_eth_qos_imx.c | 3 ++ drivers/net/phy/realtek.c | 14 +++++++ 6 files changed, 74 insertions(+), 20 deletions(-)

Add support for DWC EQoS MAC on i.MX93.
Signed-off-by: Sébastien Szymanski sebastien.szymanski@armadeus.com --- drivers/net/dwc_eth_qos.c | 4 ++++ drivers/net/dwc_eth_qos_imx.c | 3 +++ 2 files changed, 7 insertions(+)
diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c index 1e92bd9ca9c0..f70f8afe5831 100644 --- a/drivers/net/dwc_eth_qos.c +++ b/drivers/net/dwc_eth_qos.c @@ -1717,6 +1717,10 @@ static const struct udevice_id eqos_ids[] = { .compatible = "nxp,imx8mp-dwmac-eqos", .data = (ulong)&eqos_imx_config }, + { + .compatible = "nxp,imx93-dwmac-eqos", + .data = (ulong)&eqos_imx_config + }, #endif
#if IS_ENABLED(CONFIG_DWC_ETH_QOS_QCOM) diff --git a/drivers/net/dwc_eth_qos_imx.c b/drivers/net/dwc_eth_qos_imx.c index 60f3f3f5a10f..e3f55dd98173 100644 --- a/drivers/net/dwc_eth_qos_imx.c +++ b/drivers/net/dwc_eth_qos_imx.c @@ -181,6 +181,9 @@ static int eqos_set_tx_clk_speed_imx(struct udevice *dev) ulong rate; int ret;
+ if (device_is_compatible(dev, "nxp,imx93-dwmac-eqos")) + return 0; + debug("%s(dev=%p):\n", __func__, dev);
if (eqos->phy->interface == PHY_INTERFACE_MODE_RMII)

Hi Sebastian,
On 27.07.23 10:33, Sébastien Szymanski wrote:
Add support for DWC EQoS MAC on i.MX93.
Signed-off-by: Sébastien Szymanski sebastien.szymanski@armadeus.com
drivers/net/dwc_eth_qos.c | 4 ++++ drivers/net/dwc_eth_qos_imx.c | 3 +++ 2 files changed, 7 insertions(+)
diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c index 1e92bd9ca9c0..f70f8afe5831 100644 --- a/drivers/net/dwc_eth_qos.c +++ b/drivers/net/dwc_eth_qos.c @@ -1717,6 +1717,10 @@ static const struct udevice_id eqos_ids[] = { .compatible = "nxp,imx8mp-dwmac-eqos", .data = (ulong)&eqos_imx_config },
{
.compatible = "nxp,imx93-dwmac-eqos",
.data = (ulong)&eqos_imx_config
}, #endif
#if IS_ENABLED(CONFIG_DWC_ETH_QOS_QCOM)
diff --git a/drivers/net/dwc_eth_qos_imx.c b/drivers/net/dwc_eth_qos_imx.c index 60f3f3f5a10f..e3f55dd98173 100644 --- a/drivers/net/dwc_eth_qos_imx.c +++ b/drivers/net/dwc_eth_qos_imx.c @@ -181,6 +181,9 @@ static int eqos_set_tx_clk_speed_imx(struct udevice *dev) ulong rate; int ret;
if (device_is_compatible(dev, "nxp,imx93-dwmac-eqos"))
return 0;
debug("%s(dev=%p):\n", __func__, dev);
if (eqos->phy->interface == PHY_INTERFACE_MODE_RMII)
Your series breaks Rockchip's boards. For example:
+aarch64-linux-ld.bfd: drivers/net/dwc_eth_qos.o:(.rodata.eqos_ids+0x28): undefined reference to `eqos_imx_config' +make[1]: *** [Makefile:1765: u-boot] Error 1 +make: *** [Makefile:177: sub-make] Error 2 aarch64: w+ rock-4c-plus-rk3399
But it is just an example, quite all boards are broken. Please check this and repost, thanks !
Best regards, Stefano

Hi Stefano,
On 10/16/23 16:22, Stefano Babic wrote:
Hi Sebastian,
On 27.07.23 10:33, Sébastien Szymanski wrote:
Add support for DWC EQoS MAC on i.MX93.
Signed-off-by: Sébastien Szymanski sebastien.szymanski@armadeus.com
drivers/net/dwc_eth_qos.c | 4 ++++ drivers/net/dwc_eth_qos_imx.c | 3 +++ 2 files changed, 7 insertions(+)
diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c index 1e92bd9ca9c0..f70f8afe5831 100644 --- a/drivers/net/dwc_eth_qos.c +++ b/drivers/net/dwc_eth_qos.c @@ -1717,6 +1717,10 @@ static const struct udevice_id eqos_ids[] = { .compatible = "nxp,imx8mp-dwmac-eqos", .data = (ulong)&eqos_imx_config }, + { + .compatible = "nxp,imx93-dwmac-eqos", + .data = (ulong)&eqos_imx_config + }, #endif #if IS_ENABLED(CONFIG_DWC_ETH_QOS_QCOM) diff --git a/drivers/net/dwc_eth_qos_imx.c b/drivers/net/dwc_eth_qos_imx.c index 60f3f3f5a10f..e3f55dd98173 100644 --- a/drivers/net/dwc_eth_qos_imx.c +++ b/drivers/net/dwc_eth_qos_imx.c @@ -181,6 +181,9 @@ static int eqos_set_tx_clk_speed_imx(struct udevice *dev) ulong rate; int ret; + if (device_is_compatible(dev, "nxp,imx93-dwmac-eqos")) + return 0;
debug("%s(dev=%p):\n", __func__, dev); if (eqos->phy->interface == PHY_INTERFACE_MODE_RMII)
Your series breaks Rockchip's boards. For example:
+aarch64-linux-ld.bfd: drivers/net/dwc_eth_qos.o:(.rodata.eqos_ids+0x28): undefined reference to `eqos_imx_config' +make[1]: *** [Makefile:1765: u-boot] Error 1 +make: *** [Makefile:177: sub-make] Error 2 aarch64: w+ rock-4c-plus-rk3399
But it is just an example, quite all boards are broken. Please check this and repost, thanks !
https://source.denx.de/u-boot/custodians/u-boot-imx/-/blob/99807515b8eeff114...
That's because, for some reason, the "nxp,imx93-dwmac-eqos" ended up in the if CONFIG_DWC_ETH_QOS_ROCKCHIP / def statement... I'll send a v2.
Also, I am confused: why did I receive mails saying other patches of this series have been applied ?
Regards,
Best regards, Stefano

On 17.10.23 10:50, Sébastien Szymanski wrote:
Hi Stefano,
On 10/16/23 16:22, Stefano Babic wrote:
Hi Sebastian,
On 27.07.23 10:33, Sébastien Szymanski wrote:
Add support for DWC EQoS MAC on i.MX93.
Signed-off-by: Sébastien Szymanski sebastien.szymanski@armadeus.com
drivers/net/dwc_eth_qos.c | 4 ++++ drivers/net/dwc_eth_qos_imx.c | 3 +++ 2 files changed, 7 insertions(+)
diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c index 1e92bd9ca9c0..f70f8afe5831 100644 --- a/drivers/net/dwc_eth_qos.c +++ b/drivers/net/dwc_eth_qos.c @@ -1717,6 +1717,10 @@ static const struct udevice_id eqos_ids[] = { .compatible = "nxp,imx8mp-dwmac-eqos", .data = (ulong)&eqos_imx_config }, + { + .compatible = "nxp,imx93-dwmac-eqos", + .data = (ulong)&eqos_imx_config + }, #endif #if IS_ENABLED(CONFIG_DWC_ETH_QOS_QCOM) diff --git a/drivers/net/dwc_eth_qos_imx.c b/drivers/net/dwc_eth_qos_imx.c index 60f3f3f5a10f..e3f55dd98173 100644 --- a/drivers/net/dwc_eth_qos_imx.c +++ b/drivers/net/dwc_eth_qos_imx.c @@ -181,6 +181,9 @@ static int eqos_set_tx_clk_speed_imx(struct udevice *dev) ulong rate; int ret; + if (device_is_compatible(dev, "nxp,imx93-dwmac-eqos")) + return 0;
debug("%s(dev=%p):\n", __func__, dev); if (eqos->phy->interface == PHY_INTERFACE_MODE_RMII)
Your series breaks Rockchip's boards. For example:
+aarch64-linux-ld.bfd: drivers/net/dwc_eth_qos.o:(.rodata.eqos_ids+0x28): undefined reference to `eqos_imx_config' +make[1]: *** [Makefile:1765: u-boot] Error 1 +make: *** [Makefile:177: sub-make] Error 2 aarch64: w+ rock-4c-plus-rk3399
But it is just an example, quite all boards are broken. Please check this and repost, thanks !
https://source.denx.de/u-boot/custodians/u-boot-imx/-/blob/99807515b8eeff114...
That's because, for some reason, the "nxp,imx93-dwmac-eqos" ended up in the if CONFIG_DWC_ETH_QOS_ROCKCHIP / def statement... I'll send a v2.
Also, I am confused: why did I receive mails saying other patches of this series have been applied ?
This is my mistake, I forget to drop the series from the list when I removed from my tree, sorry for that.
I will wait for V2.
Regards, Stefano
Regards,
Best regards, Stefano

Add a common board_interface_eth_init() called by the DWC MAC driver to setup the MAC <-> PHY interface according to the PHY mode obtained from DT. Remove the board-side configuration in the i.MX93 EVK files.
Signed-off-by: Sébastien Szymanski sebastien.szymanski@armadeus.com --- arch/arm/mach-imx/imx9/clock.c | 53 +++++++++++++++++++++++++++ board/freescale/imx93_evk/imx93_evk.c | 16 -------- 2 files changed, 53 insertions(+), 16 deletions(-)
diff --git a/arch/arm/mach-imx/imx9/clock.c b/arch/arm/mach-imx/imx9/clock.c index 766a8811c1fa..92c41e9a67bf 100644 --- a/arch/arm/mach-imx/imx9/clock.c +++ b/arch/arm/mach-imx/imx9/clock.c @@ -18,6 +18,7 @@ #include <linux/bitops.h> #include <linux/delay.h> #include <log.h> +#include <phy.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -832,6 +833,58 @@ u32 imx_get_fecclk(void) return ccm_clk_root_get_rate(WAKEUP_AXI_CLK_ROOT); }
+#if defined(CONFIG_IMX93) && defined(CONFIG_DWC_ETH_QOS) +static int imx93_eqos_interface_init(struct udevice *dev, phy_interface_t interface_type) +{ + struct blk_ctrl_wakeupmix_regs *bctrl = + (struct blk_ctrl_wakeupmix_regs *)BLK_CTRL_WAKEUPMIX_BASE_ADDR; + + clrbits_le32(&bctrl->eqos_gpr, + BCTRL_GPR_ENET_QOS_INTF_MODE_MASK | + BCTRL_GPR_ENET_QOS_CLK_GEN_EN); + + switch (interface_type) { + case PHY_INTERFACE_MODE_MII: + setbits_le32(&bctrl->eqos_gpr, + BCTRL_GPR_ENET_QOS_INTF_SEL_MII | + BCTRL_GPR_ENET_QOS_CLK_GEN_EN); + break; + case PHY_INTERFACE_MODE_RMII: + setbits_le32(&bctrl->eqos_gpr, + BCTRL_GPR_ENET_QOS_INTF_SEL_RMII | + BCTRL_GPR_ENET_QOS_CLK_GEN_EN); + break; + case PHY_INTERFACE_MODE_RGMII: + case PHY_INTERFACE_MODE_RGMII_ID: + case PHY_INTERFACE_MODE_RGMII_RXID: + case PHY_INTERFACE_MODE_RGMII_TXID: + setbits_le32(&bctrl->eqos_gpr, + BCTRL_GPR_ENET_QOS_INTF_SEL_RGMII | + BCTRL_GPR_ENET_QOS_CLK_GEN_EN); + break; + default: + return -EINVAL; + } + + return 0; +} +#else +static int imx93_eqos_interface_init(struct udevice *dev, phy_interface_t interface_type) +{ + return 0; +} +#endif + +int board_interface_eth_init(struct udevice *dev, phy_interface_t interface_type) +{ + if (IS_ENABLED(CONFIG_IMX93) && + IS_ENABLED(CONFIG_DWC_ETH_QOS) && + device_is_compatible(dev, "nxp,imx93-dwmac-eqos")) + return imx93_eqos_interface_init(dev, interface_type); + + return -EINVAL; +} + int set_clk_enet(enum enet_freq type) { u32 div; diff --git a/board/freescale/imx93_evk/imx93_evk.c b/board/freescale/imx93_evk/imx93_evk.c index f4297f8fd4d4..c54dc9d05c5c 100644 --- a/board/freescale/imx93_evk/imx93_evk.c +++ b/board/freescale/imx93_evk/imx93_evk.c @@ -49,27 +49,11 @@ int board_phy_config(struct phy_device *phydev) return 0; }
-static int setup_eqos(void) -{ - struct blk_ctrl_wakeupmix_regs *bctrl = - (struct blk_ctrl_wakeupmix_regs *)BLK_CTRL_WAKEUPMIX_BASE_ADDR; - - /* set INTF as RGMII, enable RGMII TXC clock */ - clrsetbits_le32(&bctrl->eqos_gpr, - BCTRL_GPR_ENET_QOS_INTF_MODE_MASK, - BCTRL_GPR_ENET_QOS_INTF_SEL_RGMII | BCTRL_GPR_ENET_QOS_CLK_GEN_EN); - - return set_clk_eqos(ENET_125MHZ); -} - int board_init(void) { if (IS_ENABLED(CONFIG_FEC_MXC)) setup_fec();
- if (IS_ENABLED(CONFIG_DWC_ETH_QOS)) - setup_eqos(); - return 0; }

Add support for the RTL8211F(D)(I)-VD-CG PHY present on the i.MX93 EVK board.
Signed-off-by: Sébastien Szymanski sebastien.szymanski@armadeus.com --- drivers/net/phy/realtek.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 396cac76d632..7e1036b2271f 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -446,6 +446,20 @@ U_BOOT_PHY_DRIVER(rtl8211f) = { .writeext = &rtl8211f_phy_extwrite, };
+/* Support for RTL8211F-VD PHY */ +U_BOOT_PHY_DRIVER(rtl8211fvd) = { + .name = "RealTek RTL8211F-VD", + .uid = 0x1cc878, + .mask = 0xffffff, + .features = PHY_GBIT_FEATURES, + .probe = &rtl8211f_probe, + .config = &rtl8211f_config, + .startup = &rtl8211f_startup, + .shutdown = &genphy_shutdown, + .readext = &rtl8211f_phy_extread, + .writeext = &rtl8211f_phy_extwrite, +}; + /* Support for RTL8201F PHY */ U_BOOT_PHY_DRIVER(rtl8201f) = { .name = "RealTek RTL8201F 10/100Mbps Ethernet",

The correct compatible string for i.MX93 variant of DWC EQoS MAC is now "nxp,imx93-dwmac-eqos".
Signed-off-by: Sébastien Szymanski sebastien.szymanski@armadeus.com --- arch/arm/dts/imx93-11x11-evk-u-boot.dtsi | 4 ---- 1 file changed, 4 deletions(-)
diff --git a/arch/arm/dts/imx93-11x11-evk-u-boot.dtsi b/arch/arm/dts/imx93-11x11-evk-u-boot.dtsi index 93b4d91e4c39..0521012a5324 100644 --- a/arch/arm/dts/imx93-11x11-evk-u-boot.dtsi +++ b/arch/arm/dts/imx93-11x11-evk-u-boot.dtsi @@ -112,10 +112,6 @@ phy-reset-post-delay = <100>; };
-&eqos { - compatible = "fsl,imx-eqos"; -}; - ðphy1 { reset-gpios = <&pcal6524 15 GPIO_ACTIVE_LOW>; reset-assert-us = <15000>;

Hi Sébastien,
On Thu, Jul 27, 2023 at 5:33 AM Sébastien Szymanski sebastien.szymanski@armadeus.com wrote:
This series makes the DWC EQos MAC work on i.MX93. It depends on the i.MX93 CCF driver: https://lore.kernel.org/u-boot/20230725080856.26567-1-sebastien.szymanski@ar...
Tested on i.MX93 EVK board: u-boot=> dhcp ethernet@428a0000 Waiting for PHY auto negotiation to complete........ done BOOTP broadcast 1 *** Unhandled DHCP Option in OFFER/ACK: 125 *** Unhandled DHCP Option in OFFER/ACK: 125 DHCP client bound to address 192.168.1.50 (35 ms)
u-boot=> ping 192.168.1.51 Using ethernet@428a0000 device host 192.168.1.51 is alive u-boot=>
Thanks for the series:
Reviewed-by: Fabio Estevam festevam@denx.de
participants (3)
-
Fabio Estevam
-
Stefano Babic
-
Sébastien Szymanski