diff mbox series

net: phy: marvell: fix detection of PHY on Topaz switches

Message ID 20210418131344.21024-1-pali@kernel.org
State Superseded
Headers show
Series net: phy: marvell: fix detection of PHY on Topaz switches | expand

Commit Message

Pali Rohár April 18, 2021, 1:13 p.m. UTC
commit 1fe976d308acb6374c899a4ee8025a0a016e453e upstream.

Since commit fee2d546414d ("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: https://github.com/globalscaletechnologies/linux/issues/1
Fixes: fee2d546414d ("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>
[pali: Backported to 5.4 version]
---
This patch is backported to 5.4 version. Tested on Turris Mox with Topaz switch.
---
 drivers/net/dsa/mv88e6xxx/chip.c | 30 +++++++++++++-----------------
 drivers/net/phy/marvell.c        | 29 ++++++++++++++++++++++++++---
 include/linux/marvell_phy.h      |  5 +++--
 3 files changed, 42 insertions(+), 22 deletions(-)

Comments

Greg Kroah-Hartman April 19, 2021, 12:05 p.m. UTC | #1
On Sun, Apr 18, 2021 at 03:13:44PM +0200, Pali Rohár wrote:
> commit 1fe976d308acb6374c899a4ee8025a0a016e453e upstream.

> 

> Since commit fee2d546414d ("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: https://github.com/globalscaletechnologies/linux/issues/1

> Fixes: fee2d546414d ("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>

> [pali: Backported to 5.4 version]

> ---

> This patch is backported to 5.4 version. Tested on Turris Mox with Topaz switch.


What about a 5.10 version?

thanks,

greg k-h
Pali Rohár April 19, 2021, 12:08 p.m. UTC | #2
On Monday 19 April 2021 14:05:18 Greg KH wrote:
> On Sun, Apr 18, 2021 at 03:13:44PM +0200, Pali Rohár wrote:

> > commit 1fe976d308acb6374c899a4ee8025a0a016e453e upstream.

> > 

> > Since commit fee2d546414d ("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: https://github.com/globalscaletechnologies/linux/issues/1

> > Fixes: fee2d546414d ("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>

> > [pali: Backported to 5.4 version]

> > ---

> > This patch is backported to 5.4 version. Tested on Turris Mox with Topaz switch.

> 

> What about a 5.10 version?


Is manual backport required also for 5.10? I got email that automatic
backporting failed only for 4.19 and 5.4 versions.

> thanks,

> 

> greg k-h
Greg Kroah-Hartman April 19, 2021, 12:35 p.m. UTC | #3
On Mon, Apr 19, 2021 at 02:08:56PM +0200, Pali Rohár wrote:
> On Monday 19 April 2021 14:05:18 Greg KH wrote:

> > On Sun, Apr 18, 2021 at 03:13:44PM +0200, Pali Rohár wrote:

> > > commit 1fe976d308acb6374c899a4ee8025a0a016e453e upstream.

> > > 

> > > Since commit fee2d546414d ("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: https://github.com/globalscaletechnologies/linux/issues/1

> > > Fixes: fee2d546414d ("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>

> > > [pali: Backported to 5.4 version]

> > > ---

> > > This patch is backported to 5.4 version. Tested on Turris Mox with Topaz switch.

> > 

> > What about a 5.10 version?

> 

> Is manual backport required also for 5.10? I got email that automatic

> backporting failed only for 4.19 and 5.4 versions.


It also failed for 5.10.y, so yes, if you could provide a version for
that tree it would be most appreciated.

thanks,

greg k-h
Pali Rohár April 19, 2021, 12:47 p.m. UTC | #4
On Monday 19 April 2021 14:35:19 Greg KH wrote:
> On Mon, Apr 19, 2021 at 02:08:56PM +0200, Pali Rohár wrote:

> > On Monday 19 April 2021 14:05:18 Greg KH wrote:

> > > On Sun, Apr 18, 2021 at 03:13:44PM +0200, Pali Rohár wrote:

> > > > commit 1fe976d308acb6374c899a4ee8025a0a016e453e upstream.

> > > > 

> > > > Since commit fee2d546414d ("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: https://github.com/globalscaletechnologies/linux/issues/1

> > > > Fixes: fee2d546414d ("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>

> > > > [pali: Backported to 5.4 version]

> > > > ---

> > > > This patch is backported to 5.4 version. Tested on Turris Mox with Topaz switch.

> > > 

> > > What about a 5.10 version?

> > 

> > Is manual backport required also for 5.10? I got email that automatic

> > backporting failed only for 4.19 and 5.4 versions.

> 

> It also failed for 5.10.y, so yes, if you could provide a version for

> that tree it would be most appreciated.


Ok! I will prepare it, no problem. I just did not know that it failed
also for 5.10 as I have not received any email about it.

> thanks,

> 

> greg k-h
Greg Kroah-Hartman April 19, 2021, 12:56 p.m. UTC | #5
On Mon, Apr 19, 2021 at 02:47:11PM +0200, Pali Rohár wrote:
> On Monday 19 April 2021 14:35:19 Greg KH wrote:

> > On Mon, Apr 19, 2021 at 02:08:56PM +0200, Pali Rohár wrote:

> > > On Monday 19 April 2021 14:05:18 Greg KH wrote:

> > > > On Sun, Apr 18, 2021 at 03:13:44PM +0200, Pali Rohár wrote:

> > > > > commit 1fe976d308acb6374c899a4ee8025a0a016e453e upstream.

> > > > > 

> > > > > Since commit fee2d546414d ("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: https://github.com/globalscaletechnologies/linux/issues/1

> > > > > Fixes: fee2d546414d ("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>

> > > > > [pali: Backported to 5.4 version]

> > > > > ---

> > > > > This patch is backported to 5.4 version. Tested on Turris Mox with Topaz switch.

> > > > 

> > > > What about a 5.10 version?

> > > 

> > > Is manual backport required also for 5.10? I got email that automatic

> > > backporting failed only for 4.19 and 5.4 versions.

> > 

> > It also failed for 5.10.y, so yes, if you could provide a version for

> > that tree it would be most appreciated.

> 

> Ok! I will prepare it, no problem. I just did not know that it failed

> also for 5.10 as I have not received any email about it.


Odd, I must have forgotten to add that version to the command line
script I run to tell people that a patch failed, sorry about that.

greg k-h
Pali Rohár April 19, 2021, 1:49 p.m. UTC | #6
On Monday 19 April 2021 14:56:54 Greg KH wrote:
> On Mon, Apr 19, 2021 at 02:47:11PM +0200, Pali Rohár wrote:

> > On Monday 19 April 2021 14:35:19 Greg KH wrote:

> > > On Mon, Apr 19, 2021 at 02:08:56PM +0200, Pali Rohár wrote:

> > > > On Monday 19 April 2021 14:05:18 Greg KH wrote:

> > > > > On Sun, Apr 18, 2021 at 03:13:44PM +0200, Pali Rohár wrote:

> > > > > > commit 1fe976d308acb6374c899a4ee8025a0a016e453e upstream.

> > > > > > 

> > > > > > Since commit fee2d546414d ("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: https://github.com/globalscaletechnologies/linux/issues/1

> > > > > > Fixes: fee2d546414d ("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>

> > > > > > [pali: Backported to 5.4 version]

> > > > > > ---

> > > > > > This patch is backported to 5.4 version. Tested on Turris Mox with Topaz switch.

> > > > > 

> > > > > What about a 5.10 version?

> > > > 

> > > > Is manual backport required also for 5.10? I got email that automatic

> > > > backporting failed only for 4.19 and 5.4 versions.

> > > 

> > > It also failed for 5.10.y, so yes, if you could provide a version for

> > > that tree it would be most appreciated.

> > 

> > Ok! I will prepare it, no problem. I just did not know that it failed

> > also for 5.10 as I have not received any email about it.

> 

> Odd, I must have forgotten to add that version to the command line

> script I run to tell people that a patch failed, sorry about that.

> 

> greg k-h


Now I have sent version also for 5.10. Beware that patch for every
kernel version is slightly different.
Sasha Levin April 19, 2021, 2:31 p.m. UTC | #7
On Mon, Apr 19, 2021 at 02:56:54PM +0200, Greg KH wrote:
>On Mon, Apr 19, 2021 at 02:47:11PM +0200, Pali Rohár wrote:

>> Ok! I will prepare it, no problem. I just did not know that it failed

>> also for 5.10 as I have not received any email about it.

>

>Odd, I must have forgotten to add that version to the command line

>script I run to tell people that a patch failed, sorry about that.


Not sure what happened, but there are 2 "FAILED" mails for 5.4, one of
them must have been for 5.10 :)

-- 
Thanks,
Sasha
diff mbox series

Patch

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 1af09fd3fed1..446eb06e50b4 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -2766,10 +2766,17 @@  static int mv88e6xxx_setup(struct dsa_switch *ds)
 	return err;
 }
 
+/* prod_id for switch families which do not have a PHY model number */
+static const u16 family_prod_id_table[] = {
+	[MV88E6XXX_FAMILY_6341] = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
+	[MV88E6XXX_FAMILY_6390] = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
+};
+
 static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
 {
 	struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
 	struct mv88e6xxx_chip *chip = mdio_bus->chip;
+	u16 prod_id;
 	u16 val;
 	int err;
 
@@ -2780,23 +2787,12 @@  static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
 	err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
 	mv88e6xxx_reg_unlock(chip);
 
-	if (reg == MII_PHYSID2) {
-		/* Some internal PHYs don't have a model number. */
-		if (chip->info->family != MV88E6XXX_FAMILY_6165)
-			/* Then there is the 6165 family. It gets is
-			 * PHYs correct. But it can also have two
-			 * SERDES interfaces in the PHY address
-			 * space. And these don't have a model
-			 * number. But they are not PHYs, so we don't
-			 * want to give them something a PHY driver
-			 * will recognise.
-			 *
-			 * Use the mv88e6390 family model number
-			 * instead, for anything which really could be
-			 * a PHY,
-			 */
-			if (!(val & 0x3f0))
-				val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
+	/* Some internal PHYs don't have a model number. */
+	if (reg == MII_PHYSID2 && !(val & 0x3f0) &&
+	    chip->info->family < ARRAY_SIZE(family_prod_id_table)) {
+		prod_id = family_prod_id_table[chip->info->family];
+		if (prod_id)
+			val |= prod_id >> 4;
 	}
 
 	return err ? err : val;
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 91cf1d167263..9dbe625ad447 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -2401,9 +2401,31 @@  static struct phy_driver marvell_drivers[] = {
 		.get_stats = marvell_get_stats,
 	},
 	{
-		.phy_id = MARVELL_PHY_ID_88E6390,
+		.phy_id = MARVELL_PHY_ID_88E6341_FAMILY,
 		.phy_id_mask = MARVELL_PHY_ID_MASK,
-		.name = "Marvell 88E6390",
+		.name = "Marvell 88E6341 Family",
+		/* PHY_GBIT_FEATURES */
+		.probe = m88e1510_probe,
+		.config_init = &marvell_config_init,
+		.config_aneg = &m88e6390_config_aneg,
+		.read_status = &marvell_read_status,
+		.ack_interrupt = &marvell_ack_interrupt,
+		.config_intr = &marvell_config_intr,
+		.did_interrupt = &m88e1121_did_interrupt,
+		.resume = &genphy_resume,
+		.suspend = &genphy_suspend,
+		.read_page = marvell_read_page,
+		.write_page = marvell_write_page,
+		.get_sset_count = marvell_get_sset_count,
+		.get_strings = marvell_get_strings,
+		.get_stats = marvell_get_stats,
+		.get_tunable = m88e1540_get_tunable,
+		.set_tunable = m88e1540_set_tunable,
+	},
+	{
+		.phy_id = MARVELL_PHY_ID_88E6390_FAMILY,
+		.phy_id_mask = MARVELL_PHY_ID_MASK,
+		.name = "Marvell 88E6390 Family",
 		/* PHY_GBIT_FEATURES */
 		.probe = m88e6390_probe,
 		.config_init = &marvell_config_init,
@@ -2441,7 +2463,8 @@  static struct mdio_device_id __maybe_unused marvell_tbl[] = {
 	{ MARVELL_PHY_ID_88E1540, MARVELL_PHY_ID_MASK },
 	{ MARVELL_PHY_ID_88E1545, MARVELL_PHY_ID_MASK },
 	{ MARVELL_PHY_ID_88E3016, MARVELL_PHY_ID_MASK },
-	{ MARVELL_PHY_ID_88E6390, MARVELL_PHY_ID_MASK },
+	{ MARVELL_PHY_ID_88E6341_FAMILY, MARVELL_PHY_ID_MASK },
+	{ MARVELL_PHY_ID_88E6390_FAMILY, MARVELL_PHY_ID_MASK },
 	{ }
 };
 
diff --git a/include/linux/marvell_phy.h b/include/linux/marvell_phy.h
index af6b11d4d673..1847a0784243 100644
--- a/include/linux/marvell_phy.h
+++ b/include/linux/marvell_phy.h
@@ -23,11 +23,12 @@ 
 #define MARVELL_PHY_ID_88X3310		0x002b09a0
 #define MARVELL_PHY_ID_88E2110		0x002b09b0
 
-/* The MV88e6390 Ethernet switch contains embedded PHYs. These PHYs do
+/* These Ethernet switch families contain embedded PHYs, but they do
  * not have a model ID. So the switch driver traps reads to the ID2
  * register and returns the switch family ID
  */
-#define MARVELL_PHY_ID_88E6390		0x01410f90
+#define MARVELL_PHY_ID_88E6341_FAMILY	0x01410f41
+#define MARVELL_PHY_ID_88E6390_FAMILY	0x01410f90
 
 #define MARVELL_PHY_FAMILY_ID(id)	((id) >> 4)