drivers: ethernet: Update STM32 Ethernet driver to support MDIO if enabled.

Moved the definition of the phy device from depending on stm32hx
series SOC to its own #if...#else...#endif. This way mdio support
can be enabled on any stm32 soc that supports it by defining the
mdio node in the devicetree.

I have tested this in a custom board.

Signed-off-by: Rahul Arasikere <arasikere.rahul@gmail.com>
This commit is contained in:
Rahul Arasikere 2024-07-26 11:16:35 -04:00 committed by Fabio Baltieri
parent 8b01f83157
commit 6c4136812c
1 changed files with 5 additions and 1 deletions

View File

@ -56,13 +56,17 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#define PHY_ADDR CONFIG_ETH_STM32_HAL_PHY_ADDRESS
#if defined(CONFIG_SOC_SERIES_STM32H7X) || defined(CONFIG_SOC_SERIES_STM32H5X)
#if defined(CONFIG_MDIO)
#define DEVICE_PHY_BY_NAME(n) \
DEVICE_DT_GET(DT_CHILD(DT_INST_CHILD(n, mdio), ethernet_phy_0))
static const struct device *eth_stm32_phy_dev = DEVICE_PHY_BY_NAME(0);
#endif
#if defined(CONFIG_SOC_SERIES_STM32H7X) || defined(CONFIG_SOC_SERIES_STM32H5X)
#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */
#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */