[PATCH] net: xgmac: Augment mdio read/write with cl-45 format support

Ng, Boon Khai boon.khai.ng at altera.com
Tue Aug 26 09:29:16 CEST 2025


Hi Nikunj

> > @@ -147,6 +147,7 @@ static int xgmac_mdio_read(struct mii_dev *bus, int
> mdio_addr, int mdio_devad,
> >   	u32 val;
> >   	u32 hw_addr;
> >   	int ret;
> > +	u32 c45 = 1;

Use Boolean instead. 
eg: bool is_c45 = (mdio_devad != MDIO_DEVAD_NONE);

> >
> >   	debug("%s(dev=%p, addr=0x%x, reg=%d):\n", __func__, xgmac->dev,
> mdio_addr,
> >   	      mdio_reg);
> > @@ -159,19 +160,34 @@ static int xgmac_mdio_read(struct mii_dev *bus,
> int mdio_addr, int mdio_devad,
> >   		return ret;
> >   	}
> >
> > -	/* Set clause 22 format */
> > -	val = BIT(mdio_addr);
> > -	writel(val, &xgmac->mac_regs->mdio_clause_22_port);
> > +	if (mdio_devad == MDIO_DEVAD_NONE) {
> > +		/* Set clause 22 format */
> > +		c45 = 0;
> > +		val = BIT(mdio_addr);
> > +		writel(val, &xgmac->mac_regs->mdio_clause_22_port);
> > +	} else {
> > +		val = readl(&xgmac->mac_regs->mdio_clause_22_port);
> > +		val &= ~BIT(mdio_addr);
> > +		writel(val, &xgmac->mac_regs->mdio_clause_22_port);
> > +	}

Check using the bool is_c45 and move the clause selection logic into a helper function
Eg: (xgmac_set_caluse())

> > +	if (c45) {
> > +		hw_addr = (mdio_addr <<
> XGMAC_MAC_MDIO_ADDRESS_PA_SHIFT) |
> > +			   (mdio_reg & 0xffff);

Please help to macro the 0xffff.

Same comments apply for xgmac_mdio_write function




More information about the U-Boot mailing list