Skip to content

bugfix: driver: esp32: eth_mdio: fix clock and function calls #74442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

sylvioalves
Copy link
Collaborator

@sylvioalves sylvioalves commented Jun 17, 2024

Both MDIO and Ethernet drivers share the same clock subsystem. After clock control update in #73807, clock_control_on() now returns -EALREADY for already initialized clock subsystem. As a result, ethernet driver won't initialize as needed.
Due to the same clock control and hal updates, internal functions required updates.

Fixes #74440
Fixes #74632

As this PR updates hal_espressif, it also fixes #74632.

LucasTambor
LucasTambor previously approved these changes Jun 17, 2024
@sylvioalves sylvioalves added this to the v3.7.0 milestone Jun 17, 2024
@sylvioalves sylvioalves force-pushed the bugfix/eth_mdio_clock_issue branch 2 times, most recently from a5bcf24 to 8619fe3 Compare June 17, 2024 20:22
@sylvioalves
Copy link
Collaborator Author

It is also important to mention that current clock_control_api test interface considers that -EALREADY is an error:
https://github.com/zephyrproject-rtos/zephyr/blob/main/tests/drivers/clock_control/clock_control_api/src/test_clock_control.c#L261

@sylvioalves sylvioalves changed the title bugfix: driver: esp32: eth_mdio: fix shared clock check bugfix: driver: esp32: eth_mdio: fix clock and function calls Jun 17, 2024
@sylvioalves sylvioalves marked this pull request as draft June 17, 2024 20:49
@sylvioalves sylvioalves force-pushed the bugfix/eth_mdio_clock_issue branch from 26573fb to b7fff40 Compare June 17, 2024 20:56
@zephyrbot
Copy link
Collaborator

zephyrbot commented Jun 17, 2024

The following west manifest projects have been modified in this Pull Request:

Name Old Revision New Revision Diff
hal_espressif zephyrproject-rtos/hal_espressif@99dce94 zephyrproject-rtos/hal_espressif@e4e8df6 (zephyr) zephyrproject-rtos/[email protected]

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@sylvioalves sylvioalves force-pushed the bugfix/eth_mdio_clock_issue branch from b7fff40 to 722b380 Compare June 18, 2024 11:01
@sylvioalves sylvioalves force-pushed the bugfix/eth_mdio_clock_issue branch 3 times, most recently from 394669c to 79169f6 Compare June 20, 2024 18:22
@sylvioalves sylvioalves marked this pull request as ready for review June 20, 2024 18:24
@sylvioalves sylvioalves force-pushed the bugfix/eth_mdio_clock_issue branch from 79169f6 to 668ba35 Compare June 20, 2024 20:16
Both MDIO and Ethernet drivers share the same clock subsystem.
After clock control update in zephyrproject-rtos#73807, clock_control_on()
now returns -EALREADY for already initialized clock subsystem.
As a result, ethernet driver won't initialize as needed.

Fixes zephyrproject-rtos#74440

Signed-off-by: Sylvio Alves <[email protected]>
@sylvioalves sylvioalves force-pushed the bugfix/eth_mdio_clock_issue branch from 668ba35 to cbdfe89 Compare June 21, 2024 01:11
@sylvioalves
Copy link
Collaborator Author

sylvioalves commented Jun 21, 2024

Bebased again to check whether Babblesim stops failing.

@sylvioalves sylvioalves force-pushed the bugfix/eth_mdio_clock_issue branch 2 times, most recently from e997047 to dc3a6bf Compare June 21, 2024 12:17
When external PHY has crystal, ESP32 can be configured
to use custom GPIO as clock source for it. However, due to
latest clock subsystem and hal updates, current driver
fails to build and blocks its usage.

Signed-off-by: Sylvio Alves <[email protected]>
@sylvioalves sylvioalves force-pushed the bugfix/eth_mdio_clock_issue branch from dc3a6bf to a63d426 Compare June 21, 2024 12:58
@nashif nashif merged commit 6b4beb9 into zephyrproject-rtos:main Jun 24, 2024
25 checks passed
iwasz added a commit to iwasz/zephyr that referenced this pull request Jul 25, 2024
When GPIO17 or 16 is used as an external REF_CLK signal, the output is
enabled in eth_esp32.c This was added in PR number zephyrproject-rtos#65759 and then refined
in PR zephyrproject-rtos#74442. However this does not work for PHYs which need the REF_CLK
for MDIO communication, such as LAN8720A. In such cases phy_mii driver
tries to get the ID of such a PHY before REF_CLK is present. Therefore
in this PR I propose to move REF_CLK initialization from eth_esp32.c to
mdio_esp32.c which gets initialized before PHY and ETH.

Signed-off-by: Łukasz Iwaszkiewicz <[email protected]>
kartben pushed a commit that referenced this pull request Apr 23, 2025
When GPIO17 or 16 is used as an external REF_CLK signal, the output is
enabled in eth_esp32.c This was added in PR number #65759 and then refined
in PR #74442. However this does not work for PHYs which need the REF_CLK
for MDIO communication, such as LAN8720A. In such cases phy_mii driver
tries to get the ID of such a PHY before REF_CLK is present. Therefore
in this PR I propose to move REF_CLK initialization from eth_esp32.c to
mdio_esp32.c which gets initialized before PHY and ETH.

Signed-off-by: Łukasz Iwaszkiewicz <[email protected]>
owuatmosic pushed a commit to owuatmosic/zephyr that referenced this pull request Apr 24, 2025
When GPIO17 or 16 is used as an external REF_CLK signal, the output is
enabled in eth_esp32.c This was added in PR number zephyrproject-rtos#65759 and then refined
in PR zephyrproject-rtos#74442. However this does not work for PHYs which need the REF_CLK
for MDIO communication, such as LAN8720A. In such cases phy_mii driver
tries to get the ID of such a PHY before REF_CLK is present. Therefore
in this PR I propose to move REF_CLK initialization from eth_esp32.c to
mdio_esp32.c which gets initialized before PHY and ETH.

Signed-off-by: Łukasz Iwaszkiewicz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

esp32: can´t built project using base64 sources ESP32 ethernet interface do not start
6 participants