linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, "Pali Rohár" <pali@kernel.org>,
	"Marek Behún" <kabel@kernel.org>, "Andrew Lunn" <andrew@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 4.19 42/57] net: phy: marvell: fix detection of PHY on Topaz switches
Date: Mon, 26 Apr 2021 09:29:39 +0200	[thread overview]
Message-ID: <20210426072821.988680984@linuxfoundation.org> (raw)
In-Reply-To: <20210426072820.568997499@linuxfoundation.org>

From: Pali Rohár <pali@kernel.org>

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/dsa/mv88e6xxx/chip.c |   30 +++++++++++++-----------------
 drivers/net/phy/marvell.c        |   28 +++++++++++++++++++++++++---
 include/linux/marvell_phy.h      |    5 +++--
 3 files changed, 41 insertions(+), 22 deletions(-)

--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -2634,10 +2634,17 @@ unlock:
 	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;
 
@@ -2648,23 +2655,12 @@ static int mv88e6xxx_mdio_read(struct mi
 	err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
 	mutex_unlock(&chip->reg_lock);
 
-	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;
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -2329,9 +2329,30 @@ 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",
+		.features = PHY_GBIT_FEATURES,
+		.flags = PHY_HAS_INTERRUPT,
+		.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,
+	},
+	{
+		.phy_id = MARVELL_PHY_ID_88E6390_FAMILY,
+		.phy_id_mask = MARVELL_PHY_ID_MASK,
+		.name = "Marvell 88E6390 Family",
 		.features = PHY_GBIT_FEATURES,
 		.flags = PHY_HAS_INTERRUPT,
 		.probe = m88e6390_probe,
@@ -2368,7 +2389,8 @@ static struct mdio_device_id __maybe_unu
 	{ 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 },
 	{ }
 };
 
--- a/include/linux/marvell_phy.h
+++ b/include/linux/marvell_phy.h
@@ -21,11 +21,12 @@
 #define MARVELL_PHY_ID_88E1545		0x01410ea0
 #define MARVELL_PHY_ID_88E3016		0x01410e60
 
-/* 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)
 



  parent reply	other threads:[~2021-04-26  7:45 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-26  7:28 [PATCH 4.19 00/57] 4.19.189-rc1 review Greg Kroah-Hartman
2021-04-26  7:28 ` [PATCH 4.19 01/57] net/sctp: fix race condition in sctp_destroy_sock Greg Kroah-Hartman
2021-04-26  7:28 ` [PATCH 4.19 02/57] Input: nspire-keypad - enable interrupts only when opened Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 03/57] gpio: sysfs: Obey valid_mask Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 04/57] dmaengine: dw: Make it dependent to HAS_IOMEM Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 05/57] ARM: dts: Drop duplicate sha2md5_fck to fix clk_disable race Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 06/57] ARM: dts: Fix moving mmc devices with aliases for omap4 & 5 Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 07/57] lockdep: Add a missing initialization hint to the "INFO: Trying to register non-static key" message Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 08/57] arc: kernel: Return -EFAULT if copy_to_user() fails Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 09/57] neighbour: Disregard DEAD dst in neigh_update Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 10/57] ARM: keystone: fix integer overflow warning Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 11/57] drm/msm: Fix a5xx/a6xx timestamps Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 12/57] ASoC: fsl_esai: Fix TDM slot setup for I2S mode Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 13/57] scsi: scsi_transport_srp: Dont block target in SRP_PORT_LOST state Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 14/57] net: ieee802154: stop dump llsec keys for monitors Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 15/57] net: ieee802154: stop dump llsec devs " Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 16/57] net: ieee802154: forbid monitor for add llsec dev Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 17/57] net: ieee802154: stop dump llsec devkeys for monitors Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 18/57] net: ieee802154: forbid monitor for add llsec devkey Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 19/57] net: ieee802154: stop dump llsec seclevels for monitors Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 20/57] net: ieee802154: forbid monitor for add llsec seclevel Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 21/57] pcnet32: Use pci_resource_len to validate PCI resource Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 22/57] mac80211: clear sta->fast_rx when STA removed from 4-addr VLAN Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 23/57] Input: s6sy761 - fix coordinate read bit shift Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 24/57] Input: i8042 - fix Pegatron C15B ID entry Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 25/57] HID: wacom: set EV_KEY and EV_ABS only for non-HID_GENERIC type of devices Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 26/57] dm verity fec: fix misaligned RS roots IO Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 27/57] readdir: make sure to verify directory entry for legacy interfaces too Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 28/57] arm64: fix inline asm in load_unaligned_zeropad() Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 29/57] arm64: alternatives: Move length validation in alternative_{insn, endif} Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 30/57] scsi: libsas: Reset num_scatter if libata marks qc as NODATA Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 31/57] netfilter: conntrack: do not print icmpv6 as unknown via /proc Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 32/57] netfilter: nft_limit: avoid possible divide error in nft_limit_init Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 33/57] net: davicom: Fix regulator not turned off on failed probe Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 34/57] net: sit: Unregister catch-all devices Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 35/57] net: ip6_tunnel: " Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 36/57] i40e: fix the panic when running bpf in xdpdrv mode Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 37/57] ibmvnic: avoid calling napi_disable() twice Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 38/57] ibmvnic: remove duplicate napi_schedule call in do_reset function Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 39/57] ibmvnic: remove duplicate napi_schedule call in open function Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 40/57] ARM: footbridge: fix PCI interrupt mapping Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 41/57] ARM: 9071/1: uprobes: Dont hook on thumb instructions Greg Kroah-Hartman
2021-04-26  7:29 ` Greg Kroah-Hartman [this message]
2021-04-26  7:29 ` [PATCH 4.19 43/57] gup: document and work around "COW can break either way" issue Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 44/57] pinctrl: lewisburg: Update number of pins in community Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 45/57] locking/qrwlock: Fix ordering in queued_write_lock_slowpath() Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 46/57] perf/x86/intel/uncore: Remove uncore extra PCI dev HSWEP_PCI_PCU_3 Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 47/57] HID: google: add don USB id Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 48/57] HID: alps: fix error return code in alps_input_configured() Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 49/57] HID: wacom: Assign boolean values to a bool variable Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 50/57] ARM: dts: Fix swapped mmc order for omap3 Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 51/57] net: geneve: check skb is large enough for IPv4/IPv6 header Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 52/57] s390/entry: save the caller of psw_idle Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 53/57] xen-netback: Check for hotplug-status existence before watching Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 54/57] cavium/liquidio: Fix duplicate argument Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 55/57] ia64: fix discontig.c section mismatches Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 56/57] ia64: tools: remove duplicate definition of ia64_mf() on ia64 Greg Kroah-Hartman
2021-04-26  7:29 ` [PATCH 4.19 57/57] x86/crash: Fix crash_setup_memmap_entries() out-of-bounds access Greg Kroah-Hartman
2021-04-26  9:53 ` [PATCH 4.19 00/57] 4.19.189-rc1 review Pavel Machek
2021-04-26 18:33 ` Guenter Roeck
2021-04-26 20:35 ` Sudip Mukherjee
2021-04-26 23:47 ` Shuah Khan
2021-04-27  6:44 ` Naresh Kamboju
2021-04-28  2:49 ` Samuel Zou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210426072821.988680984@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=kabel@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pali@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).