Skip to content

Commit c069fb0

Browse files
maass-hamburgfabiobaltieri
authored andcommitted
drivers: ethernet: remove phy_configure_link() usage
remove the use of phy_configure_link() in the ethernet drivers. The user can now select the default speeds via DT prop, doing another phy_configure_link() in the eth driver would overwrite that. Signed-off-by: Fin Maaß <[email protected]>
1 parent 139bf24 commit c069fb0

File tree

2 files changed

+4
-58
lines changed

2 files changed

+4
-58
lines changed

drivers/ethernet/eth_nxp_enet.c

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -459,51 +459,12 @@ static void eth_nxp_enet_rx_thread(struct k_work *work)
459459
ENET_EnableInterrupts(data->base, kENET_RxFrameInterrupt);
460460
}
461461

462-
static int nxp_enet_phy_configure(const struct device *phy, uint8_t phy_mode)
463-
{
464-
enum phy_link_speed speeds = LINK_HALF_10BASE | LINK_FULL_10BASE |
465-
LINK_HALF_100BASE | LINK_FULL_100BASE;
466-
int ret;
467-
struct phy_link_state state;
468-
469-
if (COND_CODE_1(IS_ENABLED(CONFIG_ETH_NXP_ENET_1G),
470-
(phy_mode == NXP_ENET_RGMII_MODE), (0))) {
471-
speeds |= (LINK_HALF_1000BASE | LINK_FULL_1000BASE);
472-
}
473-
474-
/* Configure the PHY */
475-
ret = phy_configure_link(phy, speeds, 0);
476-
if (ret == -EALREADY) {
477-
return 0;
478-
} else if (ret == -ENOTSUP || ret == -ENOSYS) {
479-
phy_get_link_state(phy, &state);
480-
481-
if (state.is_up) {
482-
LOG_WRN("phy_configure_link returned %d, but link is up. "
483-
"Speed: %s, %s-duplex",
484-
ret,
485-
PHY_LINK_IS_SPEED_1000M(state.speed) ? "1 Gbits" :
486-
PHY_LINK_IS_SPEED_100M(state.speed) ? "100 Mbits" : "10 Mbits",
487-
PHY_LINK_IS_FULL_DUPLEX(state.speed) ? "full" : "half");
488-
} else {
489-
LOG_ERR("phy_configure_link returned %d and link is down.", ret);
490-
return -ENETDOWN;
491-
}
492-
} else if (ret) {
493-
LOG_ERR("phy_configure_link failed with error: %d", ret);
494-
return ret;
495-
}
496-
497-
return 0;
498-
}
499-
500462
static void nxp_enet_phy_cb(const struct device *phy,
501463
struct phy_link_state *state,
502464
void *eth_dev)
503465
{
504466
const struct device *dev = eth_dev;
505467
struct nxp_enet_mac_data *data = dev->data;
506-
const struct nxp_enet_mac_config *config = dev->config;
507468
enet_mii_speed_t speed;
508469
enet_mii_duplex_t duplex;
509470

@@ -527,16 +488,13 @@ static void nxp_enet_phy_cb(const struct device *phy,
527488
}
528489

529490
ENET_SetMII(data->base, speed, duplex);
530-
}
531-
532-
LOG_INF("Link is %s", state->is_up ? "up" : "down");
533491

534-
if (!state->is_up) {
535-
net_eth_carrier_off(data->iface);
536-
nxp_enet_phy_configure(phy, config->phy_mode);
537-
} else {
538492
net_eth_carrier_on(data->iface);
493+
} else {
494+
net_eth_carrier_off(data->iface);
539495
}
496+
497+
LOG_INF("Link is %s", state->is_up ? "up" : "down");
540498
}
541499

542500
static void eth_nxp_enet_iface_init(struct net_if *iface)
@@ -813,11 +771,6 @@ static int eth_nxp_enet_init(const struct device *dev)
813771

814772
ENET_ActiveRead(data->base);
815773

816-
err = nxp_enet_phy_configure(config->phy_dev, config->phy_mode);
817-
if (err) {
818-
return err;
819-
}
820-
821774
LOG_DBG("%s MAC %02x:%02x:%02x:%02x:%02x:%02x",
822775
dev->name,
823776
data->mac_addr[0], data->mac_addr[1],

drivers/ethernet/eth_xilinx_axienet.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -534,13 +534,6 @@ static int xilinx_axienet_probe(const struct device *dev)
534534
XILINX_AXIENET_RECEIVER_CONFIGURATION_FLOW_CONTROL_OFFSET,
535535
XILINX_AXIENET_RECEIVER_CONFIGURATION_FLOW_CONTROL_EN_MASK);
536536

537-
/* at time of writing, hardware does not support half duplex */
538-
err = phy_configure_link(config->phy,
539-
LINK_FULL_10BASE | LINK_FULL_100BASE | LINK_FULL_1000BASE, 0);
540-
if (err) {
541-
LOG_WRN("Could not configure PHY: %d", -err);
542-
}
543-
544537
LOG_INF("RX Checksum offloading %s",
545538
config->have_rx_csum_offload ? "requested" : "disabled");
546539
LOG_INF("TX Checksum offloading %s",

0 commit comments

Comments
 (0)