Skip to content

Commit c139825

Browse files
decsnymmahadevan108
authored andcommitted
drivers: nxp_enet: Check link state in iface init
Still mark the iface as down after ethernet_init, but then actually check the link state and initialize carrier appropriately This fixes the case where, the phy driver doesn't give a callback after iface init due to the link already being up, there was no change from the phy driver perspective, so callback wouldn't happen, and therefore the interface could remain marked as down after boot even if carrier is up. Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
1 parent 0da16f7 commit c139825

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/ethernet/nxp_enet/eth_nxp_enet.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,8 @@ static void eth_nxp_enet_iface_init(struct net_if *iface)
502502
const struct device *dev = net_if_get_device(iface);
503503
struct nxp_enet_mac_data *data = dev->data;
504504
const struct nxp_enet_mac_config *config = dev->config;
505+
const struct device *phy_dev = config->phy_dev;
506+
struct phy_link_state state;
505507

506508
net_if_set_link_addr(iface, data->mac_addr,
507509
sizeof(data->mac_addr),
@@ -518,6 +520,14 @@ static void eth_nxp_enet_iface_init(struct net_if *iface)
518520
ethernet_init(iface);
519521
net_if_carrier_off(iface);
520522

523+
/* In case the phy driver doesn't report a state change due to link being up
524+
* before calling phy_configure, we should check the state ourself, and then do a
525+
* pseudo-callback
526+
*/
527+
phy_get_link_state(phy_dev, &state);
528+
529+
nxp_enet_phy_cb(phy_dev, &state, (void *)dev);
530+
521531
config->irq_config_func();
522532

523533
nxp_enet_driver_cb(config->mdio, NXP_ENET_MDIO, NXP_ENET_INTERRUPT_ENABLED, NULL);

0 commit comments

Comments
 (0)