Skip to content

Commit

Permalink
net: phy: marvell10g: fix temperature sensor on 2110
Browse files Browse the repository at this point in the history
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 <maxime.chevallier@bootlin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Reviewed-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
baruchsiach authored and davem330 committed Apr 27, 2020
1 parent 8738c85 commit c3e302e
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion drivers/net/phy/marvell10g.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ enum {
MV_PCS_CSSR1_SPD2_2500 = 0x0004,
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
* registers appear to set themselves to the 0x800X when AN is
* restarted, but status registers appear readable from either.
Expand All @@ -77,6 +80,7 @@ enum {
MV_V2_PORT_CTRL = 0xf001,
MV_V2_PORT_CTRL_SWRST = BIT(15),
MV_V2_PORT_CTRL_PWRDOWN = BIT(11),
/* Temperature control/read registers (88X3310 only) */
MV_V2_TEMP_CTRL = 0xf08a,
MV_V2_TEMP_CTRL_MASK = 0xc000,
MV_V2_TEMP_CTRL_SAMPLE = 0x0000,
Expand Down Expand Up @@ -104,6 +108,24 @@ static umode_t mv3310_hwmon_is_visible(const void *data,
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,
u32 attr, int channel, long *value)
{
Expand All @@ -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) {
temp = phy_read_mmd(phydev, MDIO_MMD_VEND2, MV_V2_TEMP);
temp = mv10g_hwmon_read_temp_reg(phydev);
if (temp < 0)
return temp;

Expand Down Expand Up @@ -169,6 +191,9 @@ static int mv3310_hwmon_config(struct phy_device *phydev, bool enable)
u16 val;
int ret;

if (phydev->drv->phy_id != MARVELL_PHY_ID_88X3310)
return 0;

ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, MV_V2_TEMP,
MV_V2_TEMP_UNKNOWN);
if (ret < 0)
Expand Down

0 comments on commit c3e302e

Please sign in to comment.