Re: [RFC PATCH v1 5/9] net: phy: micrel: ksz886x add MDI-X support

From: Andrew Lunn
Date: Wed May 05 2021 - 08:37:48 EST


> +/* Device specific MII_BMCR (Reg 0) bits */
> +/* 1 = HP Auto MDI/MDI-X mode, 0 = Microchip Auto MDI/MDI-X mode */
> +#define KSZ886X_BMCR_HP_MDIX BIT(5)
> +/* 1 = Force MDI (transmit on RXP/RXM pins), 0 = Normal operation
> + * (transmit on TXP/TXM pins)
> + */
> +#define KSZ886X_BMCR_FORCE_MDI BIT(4)
> +/* 1 = Disable auto MDI-X */
> +#define KSZ886X_BMCR_DISABLE_AUTO_MDIX BIT(3)
> +#define KSZ886X_BMCR_DISABLE_FAR_END_FAULT BIT(2)
> +#define KSZ886X_BMCR_DISABLE_TRANSMIT BIT(1)
> +#define KSZ886X_BMCR_DISABLE_LED BIT(0)

Do these have the same values as what you added in patch 1?

> +static int ksz886x_config_mdix(struct phy_device *phydev, u8 ctrl)
> +{
> + u16 val;
> +
> + switch (ctrl) {
> + case ETH_TP_MDI:
> + val = KSZ886X_BMCR_DISABLE_AUTO_MDIX;
> + break;
> + case ETH_TP_MDI_X:
> + /* Note: The naming of the bit KSZ886X_BMCR_FORCE_MDI is bit
> + * counter intuitive, the "-X" in "1 = Force MDI" in the data
> + * sheet seems to be missing:
> + * 1 = Force MDI (sic!) (transmit on RX+/RX- pins)
> + * 0 = Normal operation (transmit on TX+/TX- pins)
> + */
> + val = KSZ886X_BMCR_DISABLE_AUTO_MDIX | KSZ886X_BMCR_FORCE_MDI;
> + break;
> + case ETH_TP_MDI_AUTO:
> + val = 0;
> + break;
> + default:
> + return 0;
> + }
> +
> + return phy_modify(phydev, MII_BMCR,
> + KSZ886X_BMCR_HP_MDIX | KSZ886X_BMCR_FORCE_MDI |
> + KSZ886X_BMCR_DISABLE_AUTO_MDIX,
> + KSZ886X_BMCR_HP_MDIX | val);
> +}

Maybe this will also work for the PHY driver embedded in ksz8795.c?
Maybe as another patchset, see if that PHY driver can be moved out of the DSA driver,
and share some code with this driver?

Andrew