Skip to content
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

drivers: ethernet: nxp_enet: Handle -ENOTSUP for fixed-link in phy_co… #87242

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
drivers: ethernet: nxp_enet: Handle -ENOTSUP for fixed-link in PHY co…
…nfig

Modified nxp_enet_phy_configure to handle -ENOTSUP returned by the PHY
driver, indicating a fixed-link setup. If -ENOTSUP is returned, a warning
is logged, and PHY configuration is skipped without causing initialization
to fail.

Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
ofirshe committed Mar 18, 2025
commit 4cafc01a1c215b653cb6f5393e69d92288e735de
24 changes: 23 additions & 1 deletion drivers/ethernet/eth_nxp_enet.c
Original file line number Diff line number Diff line change
@@ -461,14 +461,36 @@ static int nxp_enet_phy_configure(const struct device *phy, uint8_t phy_mode)
{
enum phy_link_speed speeds = LINK_HALF_10BASE_T | LINK_FULL_10BASE_T |
LINK_HALF_100BASE_T | LINK_FULL_100BASE_T;
int ret;
struct phy_link_state state;

if (COND_CODE_1(IS_ENABLED(CONFIG_ETH_NXP_ENET_1G),
(phy_mode == NXP_ENET_RGMII_MODE), (0))) {
speeds |= (LINK_HALF_1000BASE_T | LINK_FULL_1000BASE_T);
}

/* Configure the PHY */
return phy_configure_link(phy, speeds);
ret = phy_configure_link(phy, speeds);

if (ret == -ENOTSUP) {
phy_get_link_state(phy, &state);

if (state.is_up) {
LOG_WRN("phy_configure_link returned -ENOTSUP, but link is up. "
"Speed: %s, %s-duplex",
PHY_LINK_IS_SPEED_1000M(state.speed) ? "1 Gbits" :
PHY_LINK_IS_SPEED_100M(state.speed) ? "100 Mbits" : "10 Mbits",
PHY_LINK_IS_FULL_DUPLEX(state.speed) ? "full" : "half");
} else {
LOG_ERR("phy_configure_link returned -ENOTSUP and link is down.");
return -ENETDOWN;
}
} else if (ret) {
LOG_ERR("phy_configure_link failed with error: %d", ret);
return ret;
}

return 0;
}

static void nxp_enet_phy_cb(const struct device *phy,