Skip to content

Commit 3822683

Browse files
paligregkh
authored andcommitted
net: phy: marvell: fix detection of PHY on Topaz switches
commit 1fe976d upstream. 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 <pali@kernel.org> BugLink: globalscaletechnologies/linux#1 Fixes: fee2d54 ("net: phy: marvell: mv88e6390 temperature sensor reading") Reviewed-by: Marek Behún <kabel@kernel.org> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent cec3b77 commit 3822683

3 files changed

Lines changed: 42 additions & 22 deletions

File tree

drivers/net/dsa/mv88e6xxx/chip.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2766,10 +2766,17 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)
27662766
return err;
27672767
}
27682768

2769+
/* prod_id for switch families which do not have a PHY model number */
2770+
static const u16 family_prod_id_table[] = {
2771+
[MV88E6XXX_FAMILY_6341] = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
2772+
[MV88E6XXX_FAMILY_6390] = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
2773+
};
2774+
27692775
static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
27702776
{
27712777
struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
27722778
struct mv88e6xxx_chip *chip = mdio_bus->chip;
2779+
u16 prod_id;
27732780
u16 val;
27742781
int err;
27752782

@@ -2780,23 +2787,12 @@ static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
27802787
err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
27812788
mv88e6xxx_reg_unlock(chip);
27822789

2783-
if (reg == MII_PHYSID2) {
2784-
/* Some internal PHYs don't have a model number. */
2785-
if (chip->info->family != MV88E6XXX_FAMILY_6165)
2786-
/* Then there is the 6165 family. It gets is
2787-
* PHYs correct. But it can also have two
2788-
* SERDES interfaces in the PHY address
2789-
* space. And these don't have a model
2790-
* number. But they are not PHYs, so we don't
2791-
* want to give them something a PHY driver
2792-
* will recognise.
2793-
*
2794-
* Use the mv88e6390 family model number
2795-
* instead, for anything which really could be
2796-
* a PHY,
2797-
*/
2798-
if (!(val & 0x3f0))
2799-
val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
2790+
/* Some internal PHYs don't have a model number. */
2791+
if (reg == MII_PHYSID2 && !(val & 0x3f0) &&
2792+
chip->info->family < ARRAY_SIZE(family_prod_id_table)) {
2793+
prod_id = family_prod_id_table[chip->info->family];
2794+
if (prod_id)
2795+
val |= prod_id >> 4;
28002796
}
28012797

28022798
return err ? err : val;

drivers/net/phy/marvell.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,9 +2401,31 @@ static struct phy_driver marvell_drivers[] = {
24012401
.get_stats = marvell_get_stats,
24022402
},
24032403
{
2404-
.phy_id = MARVELL_PHY_ID_88E6390,
2404+
.phy_id = MARVELL_PHY_ID_88E6341_FAMILY,
24052405
.phy_id_mask = MARVELL_PHY_ID_MASK,
2406-
.name = "Marvell 88E6390",
2406+
.name = "Marvell 88E6341 Family",
2407+
/* PHY_GBIT_FEATURES */
2408+
.probe = m88e1510_probe,
2409+
.config_init = &marvell_config_init,
2410+
.config_aneg = &m88e6390_config_aneg,
2411+
.read_status = &marvell_read_status,
2412+
.ack_interrupt = &marvell_ack_interrupt,
2413+
.config_intr = &marvell_config_intr,
2414+
.did_interrupt = &m88e1121_did_interrupt,
2415+
.resume = &genphy_resume,
2416+
.suspend = &genphy_suspend,
2417+
.read_page = marvell_read_page,
2418+
.write_page = marvell_write_page,
2419+
.get_sset_count = marvell_get_sset_count,
2420+
.get_strings = marvell_get_strings,
2421+
.get_stats = marvell_get_stats,
2422+
.get_tunable = m88e1540_get_tunable,
2423+
.set_tunable = m88e1540_set_tunable,
2424+
},
2425+
{
2426+
.phy_id = MARVELL_PHY_ID_88E6390_FAMILY,
2427+
.phy_id_mask = MARVELL_PHY_ID_MASK,
2428+
.name = "Marvell 88E6390 Family",
24072429
/* PHY_GBIT_FEATURES */
24082430
.probe = m88e6390_probe,
24092431
.config_init = &marvell_config_init,
@@ -2441,7 +2463,8 @@ static struct mdio_device_id __maybe_unused marvell_tbl[] = {
24412463
{ MARVELL_PHY_ID_88E1540, MARVELL_PHY_ID_MASK },
24422464
{ MARVELL_PHY_ID_88E1545, MARVELL_PHY_ID_MASK },
24432465
{ MARVELL_PHY_ID_88E3016, MARVELL_PHY_ID_MASK },
2444-
{ MARVELL_PHY_ID_88E6390, MARVELL_PHY_ID_MASK },
2466+
{ MARVELL_PHY_ID_88E6341_FAMILY, MARVELL_PHY_ID_MASK },
2467+
{ MARVELL_PHY_ID_88E6390_FAMILY, MARVELL_PHY_ID_MASK },
24452468
{ }
24462469
};
24472470

include/linux/marvell_phy.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@
2323
#define MARVELL_PHY_ID_88X3310 0x002b09a0
2424
#define MARVELL_PHY_ID_88E2110 0x002b09b0
2525

26-
/* The MV88e6390 Ethernet switch contains embedded PHYs. These PHYs do
26+
/* These Ethernet switch families contain embedded PHYs, but they do
2727
* not have a model ID. So the switch driver traps reads to the ID2
2828
* register and returns the switch family ID
2929
*/
30-
#define MARVELL_PHY_ID_88E6390 0x01410f90
30+
#define MARVELL_PHY_ID_88E6341_FAMILY 0x01410f41
31+
#define MARVELL_PHY_ID_88E6390_FAMILY 0x01410f90
3132

3233
#define MARVELL_PHY_FAMILY_ID(id) ((id) >> 4)
3334

0 commit comments

Comments
 (0)