[PATCH net-next v2 3/3] net: phy: marvell10g: set the PHY in low power by default

From: Antoine Tenart
Date: Fri Mar 01 2019 - 06:01:17 EST


When the Marvell 10G PHYs are set out of reset, the LPOWER bit is set
depending on an hardware configuration choice. We also do not know what
is the PHY state at boot time. Hence, set the PHY in low power by
default when this driver probes.

Signed-off-by: Antoine Tenart <antoine.tenart@xxxxxxxxxxx>
---
drivers/net/phy/marvell10g.c | 47 ++++++++++++++++++------------------
1 file changed, 24 insertions(+), 23 deletions(-)

diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c
index 4f6f96080182..765edd34a7dd 100644
--- a/drivers/net/phy/marvell10g.c
+++ b/drivers/net/phy/marvell10g.c
@@ -201,29 +201,6 @@ static int mv3310_hwmon_probe(struct phy_device *phydev)
}
#endif

-static int mv3310_probe(struct phy_device *phydev)
-{
- struct mv3310_priv *priv;
- u32 mmd_mask = MDIO_DEVS_PMAPMD | MDIO_DEVS_AN;
- int ret;
-
- if (!phydev->is_c45 ||
- (phydev->c45_ids.devices_in_package & mmd_mask) != mmd_mask)
- return -ENODEV;
-
- priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
- if (!priv)
- return -ENOMEM;
-
- dev_set_drvdata(&phydev->mdio.dev, priv);
-
- ret = mv3310_hwmon_probe(phydev);
- if (ret)
- return ret;
-
- return 0;
-}
-
static int mv3310_suspend(struct phy_device *phydev)
{
phy_modify_mmd(phydev, MDIO_MMD_PCS, MV_PCS_BASE_T + MDIO_CTRL1,
@@ -248,6 +225,30 @@ static int mv3310_resume(struct phy_device *phydev)
return mv3310_hwmon_config(phydev, true);
}

+static int mv3310_probe(struct phy_device *phydev)
+{
+ struct mv3310_priv *priv;
+ u32 mmd_mask = MDIO_DEVS_PMAPMD | MDIO_DEVS_AN;
+ int ret;
+
+ if (!phydev->is_c45 ||
+ (phydev->c45_ids.devices_in_package & mmd_mask) != mmd_mask)
+ return -ENODEV;
+
+ priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ dev_set_drvdata(&phydev->mdio.dev, priv);
+
+ ret = mv3310_hwmon_probe(phydev);
+ if (ret)
+ return ret;
+
+ /* Set the PHY in low power mode by default */
+ return mv3310_suspend(phydev);
+}
+
/* Some PHYs in the Alaska family such as the 88X3310 and the 88E2010
* don't set bit 14 in PMA Extended Abilities (1.11), although they do
* support 2.5GBASET and 5GBASET. For these models, we can still read their
--
2.20.1