Skip to contentSkip to conversation

net: phy: micrel: Add KS8851 PHY support

PATCH Superseded Marek Vasut 4 participants 6 messages Jan 4, 2021 – Jan 5, 2021

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 net: phy: micrel: Add KS8851 PHY support

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, including the PHY ID Low/High registers swap, which is present both in the MAC and the switch.

Cc Andrew Lunn <[email protected]>
Cc Heiner Kallweit <[email protected]>
Cc Lukas Wunner <[email protected]>

To: [email protected]
---
V2: Merge the KSZ8851 and KS886X entries, as those PHYs cannot be discerned

---
 drivers/net/phy/micrel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/micrel.c +1 -1
index 54e0d75203da..39c7c786a912 100644
@@ -1389,7 +1389,7 @@ static struct phy_driver ksphy_driver[] = {
 }, {
 	.phy_id		= PHY_ID_KSZ886X,
 	.phy_id_mask	= MICREL_PHY_ID_MASK,
-	.name		= "Micrel KSZ886X Switch",
+	.name		= "Micrel KSZ8851 Ethernet MAC or KSZ886X Switch",
 	/* PHY_BASIC_FEATURES */
 	.config_init	= kszphy_config_init,
 	.suspend	= genphy_suspend,
Signature · 1 line
2.29.2
#1 lore raw

PATCH v2 2/2 net: ks8851: Register MDIO bus and the internal PHY

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. Register MDIO bus so this PHY can be detected and probed by phylib.

Cc Andrew Lunn <[email protected]>
Cc Heiner Kallweit <[email protected]>
Cc Lukas Wunner <[email protected]>

To: [email protected]
---
V2: - Cast the BIT(0) to u32 to avoid build warnings
- Swap PHY ID Hi/Lo registers for MDIO bus access (retain old behavior for MII bus access)
- Return -EOPNOTSUPP on read from nonexisting PHY registers

---
 drivers/net/ethernet/micrel/ks8851.h        |   1 +
 drivers/net/ethernet/micrel/ks8851_common.c | 113 +++++++++++++++++---
 2 files changed, 98 insertions(+), 16 deletions(-)
drivers/net/ethernet/micrel/ks8851.h +1 -0
index 2b319e451121..9bed9e024d81 100644
@@ -403,6 +403,7 @@ struct ks8851_net {
 	struct regulator	*vdd_reg;
 	struct regulator	*vdd_io;
 	int			gpio;
+	struct mii_bus		*mii_bus;
 
 	void			(*lock)(struct ks8851_net *ks,
 					unsigned long *flags);
drivers/net/ethernet/micrel/ks8851_common.c +97 -16

189 lines not on this page · raw message

Signature · 1 line
2.29.2
maintainer Reviewed-by on v2 2/2
#2 lore raw

Re: [PATCH V2 2/2] net: ks8851: Register MDIO bus and the internal PHY

Quoted 10 lines · Marek Vasut

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. Register MDIO bus so this PHY can be detected and probed by phylib.

Cc Andrew Lunn <[email protected]>
Cc Heiner Kallweit <[email protected]>
Cc Lukas Wunner <[email protected]>

To: [email protected]

Andrew

maintainer
#3 lore raw

Re: [PATCH V2 2/2] net: ks8851: Register MDIO bus and the internal PHY

In reply to Marek Vasut
Quoted 10 lines · On Mon, 4 Jan 2021 13:30:17 +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. Register MDIO bus so this PHY can be detected and probed by phylib.

Cc Andrew Lunn <[email protected]>
Cc Heiner Kallweit <[email protected]>
Cc Lukas Wunner <[email protected]>

To: [email protected]

Please put this creative To: tag under --- so maintainers don't have to stip it manually :)

There's a few warnings here:

drivers/net/ethernet/micrel/ks8851_common.c: In function ‘ks8851_mdio_read’:
drivers/net/ethernet/micrel/ks8851_common.c:1001:6: warning: unused variable ‘ret’ [-Wunused-variable]

 1001 |  int ret;
      |      ^~~

drivers/net/ethernet/micrel/ks8851.h:425: warning: Function parameter or member 'mii_bus' not described in 'ks8851_net'

#4 lore raw

Re: [PATCH V2 2/2] net: ks8851: Register MDIO bus and the internal PHY

In reply to Marek Vasut
I love your patch! Yet something to improve:

Hi Marek,

I love your patch! Yet something to improve:

[auto build test ERROR on net/master]
[also build test ERROR on ipvs/master net-next/master linus/master v5.11-rc2 next-20210104] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Marek-Vasut/net-phy-micrel-Add-KS8851-PHY-support/20210104-203217
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 4bfc4714849d005e6835bcffa3c29ebd6e5ee35d
config: i386-randconfig-a013-20210105 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/ab74850be61e7510a3304091c458b8aedfd51388
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Marek-Vasut/net-phy-micrel-Add-KS8851-PHY-support/20210104-203217
        git checkout ab74850be61e7510a3304091c458b8aedfd51388
        # save the attached .config to linux build tree
        make W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

ld: drivers/net/ethernet/micrel/ks8851_common.o: in function `ks8851_register_mdiobus':

>> drivers/net/ethernet/micrel/ks8851_common.c:1103: undefined reference to `__this_module'

vim +1103 drivers/net/ethernet/micrel/ks8851_common.c

1085
1086 static int ks8851_register_mdiobus(struct ks8851_net *ks, struct device *dev)
1087 {
1088 struct mii_bus *mii_bus;
1089 int ret;
1090
1091 mii_bus = mdiobus_alloc();
1092 if (!mii_bus)
1093 return -ENOMEM;
1094
1095 mii_bus->name = "ks8851_eth_mii";
1096 mii_bus->read = ks8851_mdio_read;
1097 mii_bus->write = ks8851_mdio_write;
1098 mii_bus->priv = ks;
1099 mii_bus->parent = dev;
1100 mii_bus->phy_mask = ~((u32)BIT(0));
1101 snprintf(mii_bus->id, MII_BUS_ID_SIZE, "%s", dev_name(dev));
1102

> 1103		ret = mdiobus_register(mii_bus);

1104 if (ret)
1105 goto err_mdiobus_register;
1106
1107 ks->mii_bus = mii_bus;
1108
1109 return 0;
1110
1111 err_mdiobus_register:
1112 mdiobus_free(mii_bus);
1113 return ret;
1114 }
1115

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

maintainer Reviewed-by on v2 1/2
#5 lore raw
In reply to Marek Vasut
Quoted 10 lines · Marek Vasut

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, including the PHY ID Low/High registers swap, which is present both in the MAC and the switch.

Cc Andrew Lunn <[email protected]>
Cc Heiner Kallweit <[email protected]>
Cc Lukas Wunner <[email protected]>

To: [email protected]

Hi Marek

Please always include a 0/X patch containing a cover letter. It gets used for the merge commit.

You should also indicate which tree this is for, by putting net-next in the [PATCH ...] part of the subject line.

See the netdev FAQ.

Andrew