+static int fxgmac_pre_powerdown(struct fxgmac_pdata *pdata)
+{
+ u32 val = 0;
+ int ret;
+
+ fxgmac_disable_rx(pdata);
+
+ yt_dbg(pdata, "%s, phy and mac status update\n", __func__);
+
+ if (device_may_wakeup(pdata->dev)) {
+ val = rd32_mem(pdata, EPHY_CTRL);
+ if (val & EPHY_CTRL_STA_LINKUP) {
+ ret = phy_speed_down(pdata->phydev, true);
+ if (ret < 0) {
+ yt_err(pdata, "%s, phy_speed_down err:%d\n", __func__, ret);
+ return ret;
+ }
+
+ ret = phy_read_status(pdata->phydev);
+ if (ret < 0) {
+ yt_err(pdata, "%s, phy_read_status err:%d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ pdata->phy_speed = pdata->phydev->speed;
+ pdata->phy_duplex = pdata->phydev->duplex;
+ yt_dbg(pdata, "%s, speed :%d, duplex :%d\n", __func__,
+ pdata->phy_speed, pdata->phy_duplex);
+
+ fxgmac_config_mac_speed(pdata);
phy_speed_down() will trigger an autoneg cycle. Once the link has
established the adjust_link callback will be called telling you the
new speed and duplex. The only time you can safely access
phydev->speed and phydev->duplex is during that callback. At other
times the values can be inconsistent.
Andrew