Re: [PATCH] net: ethernet: mtk_eth_soc: implement Clause 45 MDIO access

From: Russell King (Oracle)
Date: Sun Dec 26 2021 - 16:57:19 EST


On Sun, Dec 26, 2021 at 10:51:08PM +0100, Andrew Lunn wrote:
> > + if (phy_register & MII_ADDR_C45) {
> > + u8 dev_num = (phy_register >> 16) & 0x1f;
> > + u16 reg = (u16)(phy_register & 0xffff);
>
> Hi Daniel
>
> You can use the helpers
>
> mdio_phy_id_is_c45()
> mdio_phy_id_prtad()
> mdio_phy_id_devad()

Before someone makes a mistake with this... no, don't use these. These
are for the userspace MII ioctl API, not for drivers.

The MII ioctl API passes the prtad and devad via the PHY ID field, and
is decoded by the above macros.

The internal API passes the prtad as the PHY ID and merges the devad
into the register address.

The C45 register address can be extracted by masking with
MII_REGADDR_C45_MASK. The C45 devad can be extracted by shifting right
by MII_DEVADDR_C45_SHIFT and masking 5 bits. We don't have helpers for
this.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!