Commit c3e302ed authored by Baruch Siach's avatar Baruch Siach Committed by David S. Miller

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: 62d01535 ("net: phy: marvell10g: add support for the 88x2110 PHY")
Cc: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarBaruch Siach <baruch@tkos.co.il>
Reviewed-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8738c85c
...@@ -66,6 +66,9 @@ enum { ...@@ -66,6 +66,9 @@ enum {
MV_PCS_CSSR1_SPD2_2500 = 0x0004, MV_PCS_CSSR1_SPD2_2500 = 0x0004,
MV_PCS_CSSR1_SPD2_10000 = 0x0000, MV_PCS_CSSR1_SPD2_10000 = 0x0000,
/* Temperature read register (88E2110 only) */
MV_PCS_TEMP = 0x8042,
/* These registers appear at 0x800X and 0xa00X - the 0xa00X control /* These registers appear at 0x800X and 0xa00X - the 0xa00X control
* registers appear to set themselves to the 0x800X when AN is * registers appear to set themselves to the 0x800X when AN is
* restarted, but status registers appear readable from either. * restarted, but status registers appear readable from either.
...@@ -77,6 +80,7 @@ enum { ...@@ -77,6 +80,7 @@ enum {
MV_V2_PORT_CTRL = 0xf001, MV_V2_PORT_CTRL = 0xf001,
MV_V2_PORT_CTRL_SWRST = BIT(15), MV_V2_PORT_CTRL_SWRST = BIT(15),
MV_V2_PORT_CTRL_PWRDOWN = BIT(11), MV_V2_PORT_CTRL_PWRDOWN = BIT(11),
/* Temperature control/read registers (88X3310 only) */
MV_V2_TEMP_CTRL = 0xf08a, MV_V2_TEMP_CTRL = 0xf08a,
MV_V2_TEMP_CTRL_MASK = 0xc000, MV_V2_TEMP_CTRL_MASK = 0xc000,
MV_V2_TEMP_CTRL_SAMPLE = 0x0000, MV_V2_TEMP_CTRL_SAMPLE = 0x0000,
...@@ -104,6 +108,24 @@ static umode_t mv3310_hwmon_is_visible(const void *data, ...@@ -104,6 +108,24 @@ static umode_t mv3310_hwmon_is_visible(const void *data,
return 0; return 0;
} }
static int mv3310_hwmon_read_temp_reg(struct phy_device *phydev)
{
return phy_read_mmd(phydev, MDIO_MMD_VEND2, MV_V2_TEMP);
}
static int mv2110_hwmon_read_temp_reg(struct phy_device *phydev)
{
return phy_read_mmd(phydev, MDIO_MMD_PCS, MV_PCS_TEMP);
}
static int mv10g_hwmon_read_temp_reg(struct phy_device *phydev)
{
if (phydev->drv->phy_id == MARVELL_PHY_ID_88X3310)
return mv3310_hwmon_read_temp_reg(phydev);
else /* MARVELL_PHY_ID_88E2110 */
return mv2110_hwmon_read_temp_reg(phydev);
}
static int mv3310_hwmon_read(struct device *dev, enum hwmon_sensor_types type, static int mv3310_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long *value) u32 attr, int channel, long *value)
{ {
...@@ -116,7 +138,7 @@ static int mv3310_hwmon_read(struct device *dev, enum hwmon_sensor_types type, ...@@ -116,7 +138,7 @@ static int mv3310_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
} }
if (type == hwmon_temp && attr == hwmon_temp_input) { if (type == hwmon_temp && attr == hwmon_temp_input) {
temp = phy_read_mmd(phydev, MDIO_MMD_VEND2, MV_V2_TEMP); temp = mv10g_hwmon_read_temp_reg(phydev);
if (temp < 0) if (temp < 0)
return temp; return temp;
...@@ -169,6 +191,9 @@ static int mv3310_hwmon_config(struct phy_device *phydev, bool enable) ...@@ -169,6 +191,9 @@ static int mv3310_hwmon_config(struct phy_device *phydev, bool enable)
u16 val; u16 val;
int ret; int ret;
if (phydev->drv->phy_id != MARVELL_PHY_ID_88X3310)
return 0;
ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, MV_V2_TEMP, ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, MV_V2_TEMP,
MV_V2_TEMP_UNKNOWN); MV_V2_TEMP_UNKNOWN);
if (ret < 0) if (ret < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment