Skip to content

Commit a197004

Browse files
Dimitri FedrauPaolo Abeni
authored andcommitted
net: phy: marvell-88q2xxx: Fix temperature measurement with reset-gpios
When using temperature measurement on Marvell 88Q2XXX devices and the reset-gpios property is set in DT, the device does a hardware reset when interface is brought down and up again. That means that the content of the register MDIO_MMD_PCS_MV_TEMP_SENSOR2 is reset to default and that leads to permanent deactivation of the temperature measurement, because activation is done in mv88q2xxx_probe. To fix this move activation of temperature measurement to mv88q222x_config_init. Fixes: a557a92 ("net: phy: marvell-88q2xxx: add support for temperature sensor") Reviewed-by: Niklas Söderlund <[email protected]> Signed-off-by: Dimitri Fedrau <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 92e5995 commit a197004

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

drivers/net/phy/marvell-88q2xxx.c

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@
9595

9696
#define MDIO_MMD_PCS_MV_TDR_OFF_CUTOFF 65246
9797

98+
struct mv88q2xxx_priv {
99+
bool enable_temp;
100+
};
101+
98102
struct mmd_val {
99103
int devad;
100104
u32 regnum;
@@ -710,17 +714,12 @@ static const struct hwmon_chip_info mv88q2xxx_hwmon_chip_info = {
710714

711715
static int mv88q2xxx_hwmon_probe(struct phy_device *phydev)
712716
{
717+
struct mv88q2xxx_priv *priv = phydev->priv;
713718
struct device *dev = &phydev->mdio.dev;
714719
struct device *hwmon;
715720
char *hwmon_name;
716-
int ret;
717-
718-
/* Enable temperature sense */
719-
ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, MDIO_MMD_PCS_MV_TEMP_SENSOR2,
720-
MDIO_MMD_PCS_MV_TEMP_SENSOR2_DIS_MASK, 0);
721-
if (ret < 0)
722-
return ret;
723721

722+
priv->enable_temp = true;
724723
hwmon_name = devm_hwmon_sanitize_name(dev, dev_name(dev));
725724
if (IS_ERR(hwmon_name))
726725
return PTR_ERR(hwmon_name);
@@ -743,6 +742,14 @@ static int mv88q2xxx_hwmon_probe(struct phy_device *phydev)
743742

744743
static int mv88q2xxx_probe(struct phy_device *phydev)
745744
{
745+
struct mv88q2xxx_priv *priv;
746+
747+
priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
748+
if (!priv)
749+
return -ENOMEM;
750+
751+
phydev->priv = priv;
752+
746753
return mv88q2xxx_hwmon_probe(phydev);
747754
}
748755

@@ -810,6 +817,18 @@ static int mv88q222x_revb1_revb2_config_init(struct phy_device *phydev)
810817

811818
static int mv88q222x_config_init(struct phy_device *phydev)
812819
{
820+
struct mv88q2xxx_priv *priv = phydev->priv;
821+
int ret;
822+
823+
/* Enable temperature sense */
824+
if (priv->enable_temp) {
825+
ret = phy_modify_mmd(phydev, MDIO_MMD_PCS,
826+
MDIO_MMD_PCS_MV_TEMP_SENSOR2,
827+
MDIO_MMD_PCS_MV_TEMP_SENSOR2_DIS_MASK, 0);
828+
if (ret < 0)
829+
return ret;
830+
}
831+
813832
if (phydev->c45_ids.device_ids[MDIO_MMD_PMAPMD] == PHY_ID_88Q2220_REVB0)
814833
return mv88q222x_revb0_config_init(phydev);
815834
else

0 commit comments

Comments
 (0)