Skip to content

Conversation

@jlaitine
Copy link
Contributor

@jlaitine jlaitine commented Jan 30, 2026

Summary

This PR has two commits:

  • Correct the configuration flag CONFIG_IMX9_ENET_PHYINIT, which is mistakenly written as CONFIG_IMX9_ENET1_PHYINIT in the Kconfig. Also move it to more proper place in Kconfig.
  • Move the imx9_phy_boardinitialize to a later phase in ethernet initialization, to enable usage of sleeps and work-queues in board-specific logic.

I needed this function on a custom board, which needs to separately enable the ethernet phy via an i2c command to another device. While doing this, I found out that the

  1. PHY is being reset unnecessarily early in the boot flow, and using i2c or sleep is not possible (without specifying CONFIG_NETDEV_LATEINIT, which shouldn't be necessary just for this).
  2. It was not possible to even configure the function into use due to mismatch in the CONFIG flag name
  3. I'd like to physically reset/power on the phy again every time the interface is taken up

This PR fixes those issues.

Impact

In theory, affects only imx9 based boards with CONFIG_IMX9_ENET_PHYINIT. Which shouldn't exist, since the flag was not usable due to misspelling it in Kconfig. So essentially, no boards are affected.

Testing

Tested on a custom hardware, which requires explicitly powering on the ethernet phy. After implementing the needed "imx9_phy_boardinitialize" in the board files, and enabling the CONFIG_IMX9_ENET_PHYINIT, I can see that the

  • PHY link LED starts working
  • Board can communicate with PC over ethernet when connected:
nsh> ping 192.168.202.254
PING 192.168.202.254 56 bytes of data
56 bytes from 192.168.202.254: icmp_seq=0 time=0.0 ms
56 bytes from 192.168.202.254: icmp_seq=1 time=0.0 ms
56 bytes from 192.168.202.254: icmp_seq=2 time=0.0 ms
56 bytes from 192.168.202.254: icmp_seq=3 time=0.0 ms
56 bytes from 192.168.202.254: icmp_seq=4 time=0.0 ms
56 bytes from 192.168.202.254: icmp_seq=5 time=0.0 ms
56 bytes from 192.168.202.254: icmp_seq=6 time=0.0 ms
56 bytes from 192.168.202.254: icmp_seq=7 time=0.0 ms
56 bytes from 192.168.202.254: icmp_seq=8 time=0.0 ms
56 bytes from 192.168.202.254: icmp_seq=9 time=0.0 ms

@github-actions github-actions bot added Arch: arm64 Issues related to ARM64 (64-bit) architecture Size: S The size of the change in this PR is small labels Jan 30, 2026
The function is for any ethernet interface, given as paramter to the function,
it is not for ENET1 only. The correct name is already used
in the code, but the Kconfig had it wrong.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Move the board-specific phy initialization from early boot into ifup phase. The
board specific phy initialization may need to implement delays, or bus
communication, for example via i2c bus.

These OS services are not necessarily available yet in arm64_netinitialize, and
PHY initialization is not necessary until the driver actually starts using it.
In addition, this allows the board to reset the ethernet phy at every ifup,
if needed for error recover.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
@acassis
Copy link
Contributor

acassis commented Jan 30, 2026

@jlaitine the ping latency seems incorrect, I think it cannot be 0.0s, is your clock/timer system configured correctly?

@jlaitine
Copy link
Contributor Author

jlaitine commented Jan 30, 2026

@jlaitine the ping latency seems incorrect, I think it cannot be 0.0s, is your clock/timer system configured correctly?

Yes, everything related timing is right. Actually, I have never looked into where that latency figure comes from. Pinging the other way (pinging the device from PC), the latency is around 0.5ms:

$ ping 192.168.202.1
PING 192.168.202.1 (192.168.202.1) 56(84) bytes of data.
64 bytes from 192.168.202.1: icmp_seq=1 ttl=64 time=0.394 ms
64 bytes from 192.168.202.1: icmp_seq=2 ttl=64 time=0.570 ms
64 bytes from 192.168.202.1: icmp_seq=3 ttl=64 time=0.502 ms

That has, however, nothing to do with this PR, the link is up and working fine :)

EDIT: Looks like on my system, measuring the ping time works on the systick accuracy, and the systick is 10ms. This is why it shows just 0.0 ms:

priv->start = clock();
...
priv->elapsed = TICK2USEC(clock() - priv->start);

So I am not concerned about that detail.

@acassis acassis merged commit fdaeb00 into apache:master Feb 1, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm64 Issues related to ARM64 (64-bit) architecture Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants