Subject: Re: [PATCH net v4 1/5] net: phy: micrel: add Microchip KSZ 9897 Switch PHY support

From: Simon Horman <[email-masked]>
Date: Sat, 1 Jun 2024 18:13:40 +0100

On Fri, May 31, 2024 at 02:24:26PM +0000, Enguerrand de Ribaucourt wrote:
> There is a DSA driver for microchip,ksz9897 which can be controlled
> through SPI or I2C. This patch adds support for it's CPU ports PHYs to
> also allow network access to the switch's CPU port.
> 
> The CPU ports PHYs of the KSZ9897 are not documented in the datasheet.
> They weirdly use the same PHY ID as the KSZ8081, which is a different
> PHY and that driver isn't compatible with KSZ9897. Before this patch,
> the KSZ8081 driver was used for the CPU ports of the KSZ9897 but the
> link would never come up.
> 
> A new driver for the KSZ9897 is added, based on the compatible KSZ87XX.
> I could not test if Gigabit Ethernet works, but the link comes up and
> can successfully allow packets to be sent and received with DSA tags.
> 
> To resolve the KSZ8081/KSZ9897 phy_id conflicts, I could not find any
> stable register to distinguish them. Instead of a match_phy_device() ,
> I've declared a virtual phy_id with the highest value in Microchip's OUI
> range.
> 
> Example usage in the device tree:
> 	compatible = "ethernet-phy-id0022.17ff";
> 
> A discussion to find better alternatives had been opened with the
> Microchip team, with no response yet.
> 
> See https://lore.kernel.org/all/[email-masked]/
> 
> Fixes: b987e98e50ab ("dsa: add DSA switch driver for Microchip KSZ9477")
> Signed-off-by: Enguerrand de Ribaucourt <[email-masked]>

...

> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c

...

> @@ -5495,6 +5495,17 @@ static struct phy_driver ksphy_driver[] = {
>  	.suspend	= genphy_suspend,
>  	.resume		= genphy_resume,
>  	.get_features	= ksz9477_get_features,
> +}, {
> +	.phy_id		= PHY_ID_KSZ9897,
> +	.phy_id_mask	= MICREL_PHY_ID_MASK,
> +	.name		= "Microchip KSZ9897 Switch",
> +	/* PHY_BASIC_FEATURES */
> +	.config_init	= kszphy_config_init,
> +	.config_aneg	= ksz8873mll_config_aneg,
> +	.read_status	= ksz8873mll_read_status,
> +	/* No suspend/resume callbacks because of errata DS00002330D:
> +	 * Toggling PHY Powerdown can cause errors or link failures in adjacent PHYs
> +	 */

It looks like there will be another version of this patchset.
If so, please line-wrap the comment above so it is 80 columns wide or less,
as is preferred for Networking code.

Likewise in the following patch.

Flagged by checkpatch.pl --max-line-length=80

>  } };
>  
>  module_phy_driver(ksphy_driver);

...