Skip to content

Conversation

@maass-hamburg
Copy link
Member

@maass-hamburg maass-hamburg commented Mar 24, 2025

  • enable mdio also on legacy devices
  • remove phy specific code from stm32 ethernet driver
  • setting the phy-handle of the ethernac mac is now mandatory
  • phys, that don't use mdio or the standard registers can now be used.

@maass-hamburg maass-hamburg force-pushed the stm32_ethernet_improve branch from 24d4c5b to 60cc0af Compare March 25, 2025 12:30
@maass-hamburg maass-hamburg force-pushed the stm32_ethernet_improve branch from 60cc0af to ac5451d Compare March 25, 2025 15:51
Copy link
Contributor

@mathieuchopstm mathieuchopstm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I had something similar in stock (but not upstreamed); I have published the branch here if you want to take a look: https://github.com/mathieuchopstm/zephyr/tree/stm32_ethernet_rework

This branch is more conservative in terms of changes to the ETH driver, but uses some macrobatics in the MDIO driver to share the ETH_HandleTypeDef with its parent controller (saves RAM as the structure is quite large, but inhibits usage as a general-purpose MDIO; maybe an in-between solution could be found).

Another change I did was rename all "MDIO"-related stuff to clearly emphasize that this driver is for the MDIO controller built into the Ethernet IP (as opposed to the dedicated "general-purpose" MDIO controllers found on STM32H7) - this could be appreciated, but is mostly cosmetic, so not that important.

@maass-hamburg maass-hamburg force-pushed the stm32_ethernet_improve branch from f73739c to 11d3101 Compare March 31, 2025 14:50
@maass-hamburg
Copy link
Member Author

I checked HAL_ETH_Stop_IT in the HAL. It will only return HAL_ERROR, when heth->gState == HAL_ETH_STATE_STARTED is not true. In all other cases HAL_OK will be returned. That said, I prefer to not check the same value twice.

marwaiehm-st
marwaiehm-st previously approved these changes Apr 1, 2025
add mdio for legacy stm32 api

Signed-off-by: Fin Maaß <[email protected]>
The api takes care, if the mdio bus_enable and bus_disable
are not needed, so there is no need to have tis in the driver.

Signed-off-by: Fin Maaß <[email protected]>
add mdio and phy node to every stm32board that
supports ethernet.
Also set the phy-handle for every ethernet mac.

Signed-off-by: Fin Maaß <[email protected]>
mac and mdio are now on the same level, this way
phy-handle can be used.

Signed-off-by: Fin Maaß <[email protected]>
move stmmaceth clock to parent, so it can also be
used by mdio and rename it to ``stm-eth``.

Signed-off-by: Fin Maaß <[email protected]>
@maass-hamburg maass-hamburg force-pushed the stm32_ethernet_improve branch from 11d3101 to f098ec2 Compare April 1, 2025 13:32
mathieuchopstm
mathieuchopstm previously approved these changes Apr 1, 2025
Copy link
Contributor

@mathieuchopstm mathieuchopstm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM in current state. Very minor nits in the log messages:

erwango
erwango previously approved these changes Apr 1, 2025
rewirte code and remove code that use internal phy functions.
A few Kconfig options got removed, that are now set by the
phy via the DT.

Signed-off-by: Fin Maaß <[email protected]>
make stm32 mdio driver more independent

Signed-off-by: Fin Maaß <[email protected]>
unfortunatly HAL_ETH_SetMDIOClockRange() isn't available
in the V1 API, so I had to copy the parts from the hal.

Signed-off-by: Fin Maaß <[email protected]>
update migration guide for changes of the
stm32 ethernet driver.

Signed-off-by: Fin Maaß <[email protected]>
@maass-hamburg
Copy link
Member Author

applied suggested changes by @mathieuchopstm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Ethernet area: MDIO platform: STM32 ST Micro STM32 Release Notes To be mentioned in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants