Skip to content

Commit c3e302e

Browse files
baruchsiachdavem330
authored andcommitted
net: phy: marvell10g: fix temperature sensor on 2110
Read the temperature sensor register from the correct location for the 88E2110 PHY. There is no enable/disable bit on 2110, so make mv3310_hwmon_config() run on 88X3310 only. Fixes: 62d0153 ("net: phy: marvell10g: add support for the 88x2110 PHY") Cc: Maxime Chevallier <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: Baruch Siach <[email protected]> Reviewed-by: Russell King <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8738c85 commit c3e302e

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

drivers/net/phy/marvell10g.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ enum {
6666
MV_PCS_CSSR1_SPD2_2500 = 0x0004,
6767
MV_PCS_CSSR1_SPD2_10000 = 0x0000,
6868

69+
/* Temperature read register (88E2110 only) */
70+
MV_PCS_TEMP = 0x8042,
71+
6972
/* These registers appear at 0x800X and 0xa00X - the 0xa00X control
7073
* registers appear to set themselves to the 0x800X when AN is
7174
* restarted, but status registers appear readable from either.
@@ -77,6 +80,7 @@ enum {
7780
MV_V2_PORT_CTRL = 0xf001,
7881
MV_V2_PORT_CTRL_SWRST = BIT(15),
7982
MV_V2_PORT_CTRL_PWRDOWN = BIT(11),
83+
/* Temperature control/read registers (88X3310 only) */
8084
MV_V2_TEMP_CTRL = 0xf08a,
8185
MV_V2_TEMP_CTRL_MASK = 0xc000,
8286
MV_V2_TEMP_CTRL_SAMPLE = 0x0000,
@@ -104,6 +108,24 @@ static umode_t mv3310_hwmon_is_visible(const void *data,
104108
return 0;
105109
}
106110

111+
static int mv3310_hwmon_read_temp_reg(struct phy_device *phydev)
112+
{
113+
return phy_read_mmd(phydev, MDIO_MMD_VEND2, MV_V2_TEMP);
114+
}
115+
116+
static int mv2110_hwmon_read_temp_reg(struct phy_device *phydev)
117+
{
118+
return phy_read_mmd(phydev, MDIO_MMD_PCS, MV_PCS_TEMP);
119+
}
120+
121+
static int mv10g_hwmon_read_temp_reg(struct phy_device *phydev)
122+
{
123+
if (phydev->drv->phy_id == MARVELL_PHY_ID_88X3310)
124+
return mv3310_hwmon_read_temp_reg(phydev);
125+
else /* MARVELL_PHY_ID_88E2110 */
126+
return mv2110_hwmon_read_temp_reg(phydev);
127+
}
128+
107129
static int mv3310_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
108130
u32 attr, int channel, long *value)
109131
{
@@ -116,7 +138,7 @@ static int mv3310_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
116138
}
117139

118140
if (type == hwmon_temp && attr == hwmon_temp_input) {
119-
temp = phy_read_mmd(phydev, MDIO_MMD_VEND2, MV_V2_TEMP);
141+
temp = mv10g_hwmon_read_temp_reg(phydev);
120142
if (temp < 0)
121143
return temp;
122144

@@ -169,6 +191,9 @@ static int mv3310_hwmon_config(struct phy_device *phydev, bool enable)
169191
u16 val;
170192
int ret;
171193

194+
if (phydev->drv->phy_id != MARVELL_PHY_ID_88X3310)
195+
return 0;
196+
172197
ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, MV_V2_TEMP,
173198
MV_V2_TEMP_UNKNOWN);
174199
if (ret < 0)

0 commit comments

Comments
 (0)