Skip to content

Commit

Permalink
amd-xgbe-phy: On suspend, save CTRL1 reg for use on resume
Browse files Browse the repository at this point in the history
Reads to registers are undefined when the PCS is powered down. To be
safe, save the CTRL1 register used for power down during suspend and
restore that value during resume.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Lendacky, Thomas authored and David S. Miller committed Jan 17, 2015
1 parent 94c043e commit 03e50fd
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions drivers/net/phy/amd-xgbe-phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ struct amd_xgbe_phy_priv {
struct work_struct an_work;
struct workqueue_struct *an_workqueue;
unsigned int parallel_detect;

unsigned int lpm_ctrl; /* CTRL1 for resume */
};

static int amd_xgbe_an_enable_kr_training(struct phy_device *phydev)
Expand Down Expand Up @@ -1250,6 +1252,7 @@ static int amd_xgbe_phy_read_status(struct phy_device *phydev)

static int amd_xgbe_phy_suspend(struct phy_device *phydev)
{
struct amd_xgbe_phy_priv *priv = phydev->priv;
int ret;

mutex_lock(&phydev->lock);
Expand All @@ -1258,6 +1261,8 @@ static int amd_xgbe_phy_suspend(struct phy_device *phydev)
if (ret < 0)
goto unlock;

priv->lpm_ctrl = ret;

ret |= MDIO_CTRL1_LPOWER;
phy_write_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1, ret);

Expand All @@ -1271,23 +1276,16 @@ static int amd_xgbe_phy_suspend(struct phy_device *phydev)

static int amd_xgbe_phy_resume(struct phy_device *phydev)
{
int ret;
struct amd_xgbe_phy_priv *priv = phydev->priv;

mutex_lock(&phydev->lock);

ret = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1);
if (ret < 0)
goto unlock;

ret &= ~MDIO_CTRL1_LPOWER;
phy_write_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1, ret);

ret = 0;
priv->lpm_ctrl &= ~MDIO_CTRL1_LPOWER;
phy_write_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1, priv->lpm_ctrl);

unlock:
mutex_unlock(&phydev->lock);

return ret;
return 0;
}

static int amd_xgbe_phy_probe(struct phy_device *phydev)
Expand Down

0 comments on commit 03e50fd

Please sign in to comment.