Re: [PATCH net-next v14 10/13] net: mdio: realtek-rtl9300: Open up C22 and C45 space in parallel

Andrew Lunn <[email protected]>
Newsgroups org.kernel.vger.linux-devicetree,org.kernel.vger.netdev
Message-ID <[email protected]>
On Mon, Aug 17, 2026 at 06:26:29PM +0200, Markus Stockhausen wrote:
> Until now the MDIO driver supports either access to the C22 or to
> the C45 address space of the PHYs. This is due to the fact that
> the polling configuration favours one of the address spaces and
> limits access to the other space. E.g. when polling is set to
> C22 most of the C45 space can not be accessed.
> 
> There are however some exceptions from that. EEE register access
> is allowed independently from the polling mode [1]. As the
> downstream driver already allows parallel C22/C45 access [2] do
> this in upstream too.

Is this enough to actually use C45?

int __phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum)
{
	if (regnum > (u16)~0 || devad > 32)
		return -EINVAL;

	if (phydev->drv && phydev->drv->read_mmd)
		return phydev->drv->read_mmd(phydev, devad, regnum);

	return mmd_phy_read(phydev->mdio.bus, phydev->mdio.addr,
			    phydev->is_c45, devad, regnum);
}
EXPORT_SYMBOL(__phy_read_mmd);

int mmd_phy_read(struct mii_bus *bus, int phy_addr, bool is_c45,
		 int devad, u32 regnum)
{
	if (is_c45)
		return __mdiobus_c45_read(bus, phy_addr, devad, regnum);

	mmd_phy_indirect(bus, phy_addr, devad, regnum);
	/* Read the content of the MMD's selected register */
	return __mdiobus_read(bus, phy_addr, MII_MMD_DATA);
}

Is phydev->is_c45 true?

Some of the automotive PHYs have the same issue. Look at

commit aa63217916e1818a28b711384a9340d965ad073f
Author: Ciprian Regus <[email protected]>
Date:   Wed Jul 8 01:33:38 2026 +0300

    net: phy: add generic helpers for direct C45 MMD access
    
    Some PHYs support direct C45 register access but not C22 indirect MMD
    access (registers 0xD and 0xE). When discovered via C22, phylib routes
    MMD access through the indirect path, which won't work on these
    devices.
    
    Add genphy_read_mmd_c45() and genphy_write_mmd_c45() as read_mmd/
    write_mmd callbacks that bypass the C22 indirect path and use the bus
    C45 accessors directly.

And I really think you need to block C45 over C22, since we know it
will go horribly wrong.

   Andrew
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.