From 7ffb5c11a087fc63d7708a9dd23bdbf66523f9fa Mon Sep 17 00:00:00 2001 From: GAEHWILER Reto Date: Tue, 3 Mar 2020 09:18:02 -0600 Subject: [PATCH] arch/arm/src/stm32h7/stm32_ethernet.c: Re-organization of stm32_phy_boardinitialize PHY has to be up and running before ethreset call --- arch/arm/src/stm32h7/stm32_ethernet.c | 33 ++++++++++++++++++--------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/arch/arm/src/stm32h7/stm32_ethernet.c b/arch/arm/src/stm32h7/stm32_ethernet.c index 9e11744c49..839a6b1351 100644 --- a/arch/arm/src/stm32h7/stm32_ethernet.c +++ b/arch/arm/src/stm32h7/stm32_ethernet.c @@ -3476,17 +3476,6 @@ static int stm32_phyinit(struct stm32_ethmac_s *priv) stm32_phyregdump(); #endif - /* Perform any necessary, board-specific PHY initialization */ - -#ifdef CONFIG_STM32H7_PHYINIT - ret = stm32_phy_boardinitialize(0); - if (ret < 0) - { - nerr("ERROR: Failed to initialize the PHY: %d\n", ret); - return ret; - } -#endif - /* Special workaround for the Davicom DM9161 PHY is required. */ #ifdef CONFIG_ETH0_PHY_DM9161 @@ -4263,6 +4252,17 @@ static int stm32_ethconfig(struct stm32_ethmac_s *priv) * sequence in stm32_rcc.c. */ +#ifdef CONFIG_STM32H7_PHYINIT + /* Perform any necessary, board-specific PHY initialization */ + + ret = stm32_phy_boardinitialize(0); + if (ret < 0) + { + nerr("ERROR: Failed to initialize the PHY: %d\n", ret); + return ret; + } +#endif + /* Initialize the free buffer list */ stm32_initbuffer(priv, &g_txbuffer[priv->intf * TXBUFFER_SIZE]); @@ -4380,6 +4380,17 @@ static inline int stm32_ethinitialize(int intf) return -EAGAIN; } +#ifdef CONFIG_STM32H7_PHYINIT + /* Perform any necessary, board-specific PHY initialization */ + + ret = stm32_phy_boardinitialize(0); + if (ret < 0) + { + nerr("ERROR: Failed to initialize the PHY: %d\n", ret); + return ret; + } +#endif + /* Put the interface in the down state. */ stm32_ifdown(&priv->dev);