arch/imx9/enet: Move imx9_phy_boardinitialize to "ifup" phase

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>
This commit is contained in:
Jukka Laitinen 2026-01-30 08:37:42 +02:00 committed by Alan C. Assis
parent 15fa005e5b
commit fdaeb00910

View file

@ -182,6 +182,7 @@ enum phy_type_t
struct imx9_driver_s
{
struct net_driver_s dev; /* Interface understood by the network */
int intf; /* Interface number within the driver */
const uint32_t base; /* Base address of ENET controller */
const int clk_gate; /* Enet clock gate */
const int irq; /* Enet interrupt */
@ -2170,6 +2171,17 @@ static int imx9_determine_phy(struct imx9_driver_s *priv)
int retries;
int ret;
#ifdef CONFIG_IMX9_ENET_PHYINIT
/* Perform any necessary, one-time, board-specific PHY initialization */
ret = imx9_phy_boardinitialize(priv->intf);
if (ret < 0)
{
nerr("ERROR: Failed to initialize the PHY: %d\n", ret);
return ret;
}
#endif
for (i = 0; i < priv->n_phys; i++)
{
priv->phyaddr = (uint8_t)priv->phy_list[i].address_lo;
@ -3201,6 +3213,7 @@ int imx9_netinitialize(int intf)
/* Get the interface structure associated with this interface number. */
priv = &g_enet[intf];
priv->intf = intf;
/* Disable the ENET clock */
@ -3292,17 +3305,6 @@ int imx9_netinitialize(int intf)
#endif
#ifdef CONFIG_IMX9_ENET_PHYINIT
/* Perform any necessary, one-time, board-specific PHY initialization */
ret = imx9_phy_boardinitialize(intf);
if (ret < 0)
{
nerr("ERROR: Failed to initialize the PHY: %d\n", ret);
return ret;
}
#endif
/* Put the interface in the down state. This usually amounts to resetting
* the device and/or calling imx9_ifdown().
*/