This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 8d888837e4a arch/arm/imxrt: imxrt_enet: fix YT8512 setup and add
LAN8720 PHY notify
8d888837e4a is described below
commit 8d888837e4a33cc98c0981a0498580535a3bb1c3
Author: Alan Carvalho de Assis <[email protected]>
AuthorDate: Thu Oct 15 16:28:54 2026 -0300
arch/arm/imxrt: imxrt_enet: fix YT8512 setup and add LAN8720 PHY notify
With CONFIG_ETH0_PHY_MULTI, the YT8512 specific initialization in
imxrt_initphy() was executed for every PHY except the YT8512, because
the imxrt_phy_is() test was inverted. On a LAN8720 it writes to
registers 30/31 (interrupt mask and special control/status), clearing
the 4B5B enable bit and breaking 100BASE-TX. Only run it when the
detected PHY is a YT8512.
imxrt_phyintenable() returned -ENOSYS for the LAN8720/LAN8742A, so
SIOCMIINOTIFY (used by the NETINIT link monitor) failed on boards using
these PHYs. Enable the link down and auto-negotiation complete
interrupts on them, both when selected at compile time and at run time
with CONFIG_ETH0_PHY_MULTI.
Signed-off-by: Alan Carvalho de Assis <[email protected]>
Assisted-by: Claude Opus 5.5
---
arch/arm/src/imxrt/imxrt_enet.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/arch/arm/src/imxrt/imxrt_enet.c b/arch/arm/src/imxrt/imxrt_enet.c
index 0592257fbf3..a62ca540e88 100644
--- a/arch/arm/src/imxrt/imxrt_enet.c
+++ b/arch/arm/src/imxrt/imxrt_enet.c
@@ -2031,7 +2031,8 @@ static int imxrt_phyintenable(struct imxrt_driver_s *priv)
{
#if defined(CONFIG_ETH0_PHY_KSZ8051) || defined(CONFIG_ETH0_PHY_KSZ8061) || \
defined(CONFIG_ETH0_PHY_KSZ8081) || defined(CONFIG_ETH0_PHY_DP83825I) || \
- defined(CONFIG_ETH0_YT8512) || defined(CONFIG_ETH0_PHY_MULTI)
+ defined(CONFIG_ETH0_YT8512) || defined(CONFIG_ETH0_PHY_LAN8720) || \
+ defined(CONFIG_ETH0_PHY_LAN8742A) || defined(CONFIG_ETH0_PHY_MULTI)
uint16_t phyval;
int ret;
@@ -2049,7 +2050,14 @@ static int imxrt_phyintenable(struct imxrt_driver_s
*priv)
wreg = MII_YT8512_IMR;
# endif
- /* Run time YT8512 defaults */
+ /* Compile time LAN8720/LAN8742A defaults */
+# if defined(CONFIG_ETH0_PHY_LAN8720) || defined(CONFIG_ETH0_PHY_LAN8742A)
+ mask = MII_LAN8720_INT_LINKDOWN | MII_LAN8720_INT_ANCOMPLETE;
+ rreg = MII_LAN8720_ISR;
+ wreg = MII_LAN8720_IMR;
+# endif
+
+ /* Run time YT8512 and LAN8720/LAN8742A defaults */
# if defined(CONFIG_ETH0_PHY_MULTI)
if (imxrt_phy_is(priv, MII_YT8512_NAME))
{
@@ -2057,6 +2065,13 @@ static int imxrt_phyintenable(struct imxrt_driver_s
*priv)
rreg = MII_YT8512_ISR;
wreg = MII_YT8512_IMR;
}
+ else if (imxrt_phy_is(priv, MII_LAN8720_NAME) ||
+ imxrt_phy_is(priv, MII_LAN8742A_NAME))
+ {
+ mask = MII_LAN8720_INT_LINKDOWN | MII_LAN8720_INT_ANCOMPLETE;
+ rreg = MII_LAN8720_ISR;
+ wreg = MII_LAN8720_IMR;
+ }
else if (!(imxrt_phy_is(priv, MII_KSZ8051_NAME) ||
imxrt_phy_is(priv, MII_KSZ8061_NAME) ||
imxrt_phy_is(priv, MII_KSZ8081_NAME) ||
@@ -2777,7 +2792,7 @@ static inline int imxrt_initphy(struct imxrt_driver_s
*priv, bool renogphy)
#if defined(CONFIG_ETH0_PHY_YT8512) || defined(CONFIG_ETH0_PHY_MULTI)
# if defined(CONFIG_ETH0_PHY_MULTI)
- if (!imxrt_phy_is(priv, MII_YT8512_NAME))
+ if (imxrt_phy_is(priv, MII_YT8512_NAME))
{
# endif
/* Reset PHY */