Skip to content

Commit 1fe976d

Browse files
palidavem330
authored andcommitted
net: phy: marvell: fix detection of PHY on Topaz switches
Since commit fee2d54 ("net: phy: marvell: mv88e6390 temperature sensor reading"), Linux reports the temperature of Topaz hwmon as constant -75°C. This is because switches from the Topaz family (88E6141 / 88E6341) have the address of the temperature sensor register different from Peridot. This address is instead compatible with 88E1510 PHYs, as was used for Topaz before the above mentioned commit. Create a new mapping table between switch family and PHY ID for families which don't have a model number. And define PHY IDs for Topaz and Peridot families. Create a new PHY ID and a new PHY driver for Topaz's internal PHY. The only difference from Peridot's PHY driver is the HWMON probing method. Prior this change Topaz's internal PHY is detected by kernel as: PHY [...] driver [Marvell 88E6390] (irq=63) And afterwards as: PHY [...] driver [Marvell 88E6341 Family] (irq=63) Signed-off-by: Pali Rohár <[email protected]> BugLink: globalscaletechnologies/linux#1 Fixes: fee2d54 ("net: phy: marvell: mv88e6390 temperature sensor reading") Reviewed-by: Marek Behún <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6628ddf commit 1fe976d

File tree

3 files changed

+45
-22
lines changed

3 files changed

+45
-22
lines changed

drivers/net/dsa/mv88e6xxx/chip.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3026,10 +3026,17 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)
30263026
return err;
30273027
}
30283028

3029+
/* prod_id for switch families which do not have a PHY model number */
3030+
static const u16 family_prod_id_table[] = {
3031+
[MV88E6XXX_FAMILY_6341] = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
3032+
[MV88E6XXX_FAMILY_6390] = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
3033+
};
3034+
30293035
static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
30303036
{
30313037
struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
30323038
struct mv88e6xxx_chip *chip = mdio_bus->chip;
3039+
u16 prod_id;
30333040
u16 val;
30343041
int err;
30353042

@@ -3040,23 +3047,12 @@ static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
30403047
err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
30413048
mv88e6xxx_reg_unlock(chip);
30423049

3043-
if (reg == MII_PHYSID2) {
3044-
/* Some internal PHYs don't have a model number. */
3045-
if (chip->info->family != MV88E6XXX_FAMILY_6165)
3046-
/* Then there is the 6165 family. It gets is
3047-
* PHYs correct. But it can also have two
3048-
* SERDES interfaces in the PHY address
3049-
* space. And these don't have a model
3050-
* number. But they are not PHYs, so we don't
3051-
* want to give them something a PHY driver
3052-
* will recognise.
3053-
*
3054-
* Use the mv88e6390 family model number
3055-
* instead, for anything which really could be
3056-
* a PHY,
3057-
*/
3058-
if (!(val & 0x3f0))
3059-
val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
3050+
/* Some internal PHYs don't have a model number. */
3051+
if (reg == MII_PHYSID2 && !(val & 0x3f0) &&
3052+
chip->info->family < ARRAY_SIZE(family_prod_id_table)) {
3053+
prod_id = family_prod_id_table[chip->info->family];
3054+
if (prod_id)
3055+
val |= prod_id >> 4;
30603056
}
30613057

30623058
return err ? err : val;

drivers/net/phy/marvell.c

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3021,9 +3021,34 @@ static struct phy_driver marvell_drivers[] = {
30213021
.get_stats = marvell_get_stats,
30223022
},
30233023
{
3024-
.phy_id = MARVELL_PHY_ID_88E6390,
3024+
.phy_id = MARVELL_PHY_ID_88E6341_FAMILY,
30253025
.phy_id_mask = MARVELL_PHY_ID_MASK,
3026-
.name = "Marvell 88E6390",
3026+
.name = "Marvell 88E6341 Family",
3027+
/* PHY_GBIT_FEATURES */
3028+
.flags = PHY_POLL_CABLE_TEST,
3029+
.probe = m88e1510_probe,
3030+
.config_init = marvell_config_init,
3031+
.config_aneg = m88e6390_config_aneg,
3032+
.read_status = marvell_read_status,
3033+
.config_intr = marvell_config_intr,
3034+
.handle_interrupt = marvell_handle_interrupt,
3035+
.resume = genphy_resume,
3036+
.suspend = genphy_suspend,
3037+
.read_page = marvell_read_page,
3038+
.write_page = marvell_write_page,
3039+
.get_sset_count = marvell_get_sset_count,
3040+
.get_strings = marvell_get_strings,
3041+
.get_stats = marvell_get_stats,
3042+
.get_tunable = m88e1540_get_tunable,
3043+
.set_tunable = m88e1540_set_tunable,
3044+
.cable_test_start = marvell_vct7_cable_test_start,
3045+
.cable_test_tdr_start = marvell_vct5_cable_test_tdr_start,
3046+
.cable_test_get_status = marvell_vct7_cable_test_get_status,
3047+
},
3048+
{
3049+
.phy_id = MARVELL_PHY_ID_88E6390_FAMILY,
3050+
.phy_id_mask = MARVELL_PHY_ID_MASK,
3051+
.name = "Marvell 88E6390 Family",
30273052
/* PHY_GBIT_FEATURES */
30283053
.flags = PHY_POLL_CABLE_TEST,
30293054
.probe = m88e6390_probe,
@@ -3107,7 +3132,8 @@ static struct mdio_device_id __maybe_unused marvell_tbl[] = {
31073132
{ MARVELL_PHY_ID_88E1540, MARVELL_PHY_ID_MASK },
31083133
{ MARVELL_PHY_ID_88E1545, MARVELL_PHY_ID_MASK },
31093134
{ MARVELL_PHY_ID_88E3016, MARVELL_PHY_ID_MASK },
3110-
{ MARVELL_PHY_ID_88E6390, MARVELL_PHY_ID_MASK },
3135+
{ MARVELL_PHY_ID_88E6341_FAMILY, MARVELL_PHY_ID_MASK },
3136+
{ MARVELL_PHY_ID_88E6390_FAMILY, MARVELL_PHY_ID_MASK },
31113137
{ MARVELL_PHY_ID_88E1340S, MARVELL_PHY_ID_MASK },
31123138
{ MARVELL_PHY_ID_88E1548P, MARVELL_PHY_ID_MASK },
31133139
{ }

include/linux/marvell_phy.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@
2828
/* Marvel 88E1111 in Finisar SFP module with modified PHY ID */
2929
#define MARVELL_PHY_ID_88E1111_FINISAR 0x01ff0cc0
3030

31-
/* The MV88e6390 Ethernet switch contains embedded PHYs. These PHYs do
31+
/* These Ethernet switch families contain embedded PHYs, but they do
3232
* not have a model ID. So the switch driver traps reads to the ID2
3333
* register and returns the switch family ID
3434
*/
35-
#define MARVELL_PHY_ID_88E6390 0x01410f90
35+
#define MARVELL_PHY_ID_88E6341_FAMILY 0x01410f41
36+
#define MARVELL_PHY_ID_88E6390_FAMILY 0x01410f90
3637

3738
#define MARVELL_PHY_FAMILY_ID(id) ((id) >> 4)
3839

0 commit comments

Comments
 (0)