diff mbox series

[1/2] net: phy: micrel: Add KS8851 PHY support

Message ID 20201230125358.1023502-1-marex@denx.de (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [1/2] net: phy: micrel: Add KS8851 PHY support | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers warning 4 maintainers not CCed: linux@armlinux.org.uk kuba@kernel.org davem@davemloft.net Divya.Koppera@microchip.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 29 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Marek Vasut Dec. 30, 2020, 12:53 p.m. UTC
The KS8851 has a reduced internal PHY, which is accessible through its
registers at offset 0xe4. The PHY is compatible with KS886x PHY present
in Micrel switches, except the PHY ID Low/High registers are swapped.
Add PHY ID for this KS8851 PHY and use custom PHY ID mask due to the swap.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Lukas Wunner <lukas@wunner.de>
To: netdev@vger.kernel.org
---
 drivers/net/phy/micrel.c   | 9 +++++++++
 include/linux/micrel_phy.h | 2 ++
 2 files changed, 11 insertions(+)

Comments

Andrew Lunn Dec. 30, 2020, 3:43 p.m. UTC | #1
On Wed, Dec 30, 2020 at 01:53:57PM +0100, Marek Vasut wrote:
> The KS8851 has a reduced internal PHY, which is accessible through its
> registers at offset 0xe4. The PHY is compatible with KS886x PHY present
> in Micrel switches, except the PHY ID Low/High registers are swapped.

Can you intercept the reads in the KS8851 driver and swap them back
again? The mv88e6xxx driver does something similar. The mv88e6393
family of switches have PHYs with the Marvell OUI but no device ID. So
the code traps these reads and provides an ID.

    Andrew
Marek Vasut Jan. 3, 2021, 12:55 p.m. UTC | #2
On 12/30/20 4:43 PM, Andrew Lunn wrote:
> On Wed, Dec 30, 2020 at 01:53:57PM +0100, Marek Vasut wrote:
>> The KS8851 has a reduced internal PHY, which is accessible through its
>> registers at offset 0xe4. The PHY is compatible with KS886x PHY present
>> in Micrel switches, except the PHY ID Low/High registers are swapped.
> 
> Can you intercept the reads in the KS8851 driver and swap them back
> again? The mv88e6xxx driver does something similar. The mv88e6393
> family of switches have PHYs with the Marvell OUI but no device ID. So
> the code traps these reads and provides an ID.

I would prefer to keep this as-is, since then the PHY driver can match 
on these swapped IDs and discern the PHY from PHY present in the KS886x 
switch.
Andrew Lunn Jan. 3, 2021, 4:55 p.m. UTC | #3
On Sun, Jan 03, 2021 at 01:55:22PM +0100, Marek Vasut wrote:
> On 12/30/20 4:43 PM, Andrew Lunn wrote:
> > On Wed, Dec 30, 2020 at 01:53:57PM +0100, Marek Vasut wrote:
> > > The KS8851 has a reduced internal PHY, which is accessible through its
> > > registers at offset 0xe4. The PHY is compatible with KS886x PHY present
> > > in Micrel switches, except the PHY ID Low/High registers are swapped.
> > 
> > Can you intercept the reads in the KS8851 driver and swap them back
> > again? The mv88e6xxx driver does something similar. The mv88e6393
> > family of switches have PHYs with the Marvell OUI but no device ID. So
> > the code traps these reads and provides an ID.
> 
> I would prefer to keep this as-is, since then the PHY driver can match on
> these swapped IDs and discern the PHY from PHY present in the KS886x switch.

The problem is, this ID contains an OUI. Well, part of an OUI, the top
two bits of the OUI are removed, leaving 22 bits of a 24 bit
OUI. These OUIs are assigned to companies, well organisations. If you
look at the reversed PHY ID, what are the 4 possible OUIs? Who are
they assigned to? Are they ever likely to manufacture a PHY?

	 Andrew
Marek Vasut Jan. 3, 2021, 6:44 p.m. UTC | #4
On 1/3/21 5:55 PM, Andrew Lunn wrote:
> On Sun, Jan 03, 2021 at 01:55:22PM +0100, Marek Vasut wrote:
>> On 12/30/20 4:43 PM, Andrew Lunn wrote:
>>> On Wed, Dec 30, 2020 at 01:53:57PM +0100, Marek Vasut wrote:
>>>> The KS8851 has a reduced internal PHY, which is accessible through its
>>>> registers at offset 0xe4. The PHY is compatible with KS886x PHY present
>>>> in Micrel switches, except the PHY ID Low/High registers are swapped.
>>>
>>> Can you intercept the reads in the KS8851 driver and swap them back
>>> again? The mv88e6xxx driver does something similar. The mv88e6393
>>> family of switches have PHYs with the Marvell OUI but no device ID. So
>>> the code traps these reads and provides an ID.
>>
>> I would prefer to keep this as-is, since then the PHY driver can match on
>> these swapped IDs and discern the PHY from PHY present in the KS886x switch.
> 
> The problem is, this ID contains an OUI. Well, part of an OUI, the top
> two bits of the OUI are removed, leaving 22 bits of a 24 bit
> OUI. These OUIs are assigned to companies, well organisations. If you
> look at the reversed PHY ID, what are the 4 possible OUIs? Who are
> they assigned to? Are they ever likely to manufacture a PHY?

Are these OUIs used for anything else than identifying the PHY though ?
diff mbox series

Patch

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 54e0d75203da..ca6da128e37a 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -1386,6 +1386,14 @@  static struct phy_driver ksphy_driver[] = {
 	.read_status	= ksz8873mll_read_status,
 	.suspend	= genphy_suspend,
 	.resume		= genphy_resume,
+}, {
+	.phy_id		= PHY_ID_KSZ8851,
+	.phy_id_mask	= 0xfff000ff,
+	.name		= "Micrel KSZ8851 Ethernet MAC",
+	/* PHY_BASIC_FEATURES */
+	.config_init	= kszphy_config_init,
+	.suspend	= genphy_suspend,
+	.resume		= genphy_resume,
 }, {
 	.phy_id		= PHY_ID_KSZ886X,
 	.phy_id_mask	= MICREL_PHY_ID_MASK,
@@ -1432,6 +1440,7 @@  static struct mdio_device_id __maybe_unused micrel_tbl[] = {
 	{ PHY_ID_KSZ8061, MICREL_PHY_ID_MASK },
 	{ PHY_ID_KSZ8081, MICREL_PHY_ID_MASK },
 	{ PHY_ID_KSZ8873MLL, MICREL_PHY_ID_MASK },
+	{ PHY_ID_KSZ8851, 0xfff000ff },
 	{ PHY_ID_KSZ886X, MICREL_PHY_ID_MASK },
 	{ PHY_ID_LAN8814, MICREL_PHY_ID_MASK },
 	{ }
diff --git a/include/linux/micrel_phy.h b/include/linux/micrel_phy.h
index 416ee6dd2574..1c26e4ac0dc9 100644
--- a/include/linux/micrel_phy.h
+++ b/include/linux/micrel_phy.h
@@ -29,6 +29,8 @@ 
 #define PHY_ID_KSZ9131		0x00221640
 #define PHY_ID_LAN8814		0x00221660
 
+/* The PHY ID Low/High registers are swapped on KSZ8851 */
+#define PHY_ID_KSZ8851		0x14300022
 #define PHY_ID_KSZ886X		0x00221430
 #define PHY_ID_KSZ8863		0x00221435