Skip to content

Commit be49443

Browse files
committed
drivers: ethernet: vsc8541: Implement cfg_link function
The cfg_link function was not implemented in this driver, which could cause the MAC driver to report errors. Add an implementation based on the phy_mii driver. Signed-off-by: Robert Hancock <robert.hancock@calian.com>
1 parent 18fefa0 commit be49443

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

drivers/ethernet/phy/phy_microchip_vsc8541.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ LOG_MODULE_REGISTER(microchip_vsc8541, CONFIG_PHY_LOG_LEVEL);
1515
#include <string.h>
1616
#include <zephyr/sys/util_macro.h>
1717
#include <zephyr/drivers/gpio.h>
18+
#include "phy_mii.h"
1819

1920
/* phy page selectors */
2021
#define PHY_PAGE_0 0x00 /* main registers space active */
@@ -404,6 +405,31 @@ static int phy_mc_vsc8541_get_link(const struct device *dev, struct phy_link_sta
404405
return 0;
405406
}
406407

408+
/**
409+
* @brief Reconfigure the link speed
410+
*
411+
* @param dev device structure to phy
412+
* @param adv_speeds speeds to be advertised
413+
* @param flags configuration flags
414+
*/
415+
static int phy_mc_vsc8541_cfg_link(const struct device *dev, enum phy_link_speed adv_speeds,
416+
enum phy_cfg_link_flag flags)
417+
{
418+
int ret = 0;
419+
420+
if ((flags & PHY_FLAG_AUTO_NEGOTIATION_DISABLED) != 0U) {
421+
ret = phy_mii_set_bmcr_reg_autoneg_disabled(dev, adv_speeds);
422+
} else {
423+
ret = phy_mii_cfg_link_autoneg(dev, adv_speeds, true);
424+
}
425+
426+
if (ret == -EALREADY) {
427+
LOG_DBG("Link already configured");
428+
}
429+
430+
return 0;
431+
}
432+
407433
/**
408434
* @brief Set callback which is used to announce link status changes
409435
*
@@ -559,6 +585,7 @@ static int phy_mc_vsc8541_write_ext(const struct device *dev, uint16_t reg_addr,
559585

560586
static DEVICE_API(ethphy, mc_vsc8541_phy_api) = {
561587
.get_link = phy_mc_vsc8541_get_link,
588+
.cfg_link = phy_mc_vsc8541_cfg_link,
562589
.link_cb_set = phy_mc_vsc8541_link_cb_set,
563590
.read = phy_mc_vsc8541_read_ext,
564591
.write = phy_mc_vsc8541_write_ext,

0 commit comments

Comments
 (0)