Re: [PATCH net-next 2/5] net: ethernet: oa_tc6: Add support for MDIO indirect access

From: Alvin Šipraga

Date: Wed Nov 04 2026 - 09:17:02 EST


On Tue, Nov 03, 2026 at 06:09:15PM +0200, Iustin Stolniceanu wrote:
> From: Ciprian Regus <ciprian.regus@xxxxxxxxxx>
>
> The OPEN Alliance TC6 specification defines two ways for the SPI host
> to access the registers of the PHY integrated in a MAC-PHY: direct
> access, where the PHY registers are mapped into the MAC-PHY register
> space, and indirect access, through the MDIOACC registers. A MAC-PHY
> reports support for direct access through the DPRAC bit in the STDCAP
> register.
>
> The framework currently supports only direct access and fails to
> register the MDIO bus when DPRAC is not set.
>
> Read STDCAP when registering the MDIO bus and, if direct access is not
> supported, implement the Clause 22 and Clause 45 MDIO operations as
> indirect transactions through MDIOACC: for Clause 45, write the
> address command to MDIOACC0 and the read or write command to
> MDIOACC1; for Clause 22, write the command to MDIOACC1. Then poll
> for TRDONE.
>
> If TAERR (turnaround error) is set, no PHY answered at that address
> and the DATA field must be ignored. Return 0xffff in that case, as
> for an empty address on an MDIO bus, so that the PHY bus scan skips
> the address instead of failing. Return -EIO for a write.
>
> Signed-off-by: Ciprian Regus <ciprian.regus@xxxxxxxxxx>
> Signed-off-by: Iustin Stolniceanu <iustin.stolniceanu@xxxxxxxxxx>

Reviewed-by: Alvin Šipraga <alvin.sipraga@xxxxxxxxxx>

Just a small comment below.

> ---
> drivers/net/ethernet/oa_tc6.c | 171 +++++++++++++++++++++++++++++++---
> include/linux/oa_tc6.h | 15 +++
> 2 files changed, 171 insertions(+), 15 deletions(-)
>
[...]

> @@ -534,8 +674,16 @@ EXPORT_SYMBOL_GPL(oa_tc6_mdiobus_write_c45);
>
> static int oa_tc6_mdiobus_register(struct oa_tc6 *tc6)
> {
> + u32 regval;
> int ret;
>
> + ret = oa_tc6_read_register(tc6, OA_TC6_REG_STDCAP, &regval);
> + if (ret)
> + return ret;
> +
> + tc6->mdio_indirect_mode = !(OA_TC6_STDCAP_DIRECT_PHY_REG_ACCESS &
> + regval);

Maybe just if (xxx) tc6->mdio_indirect_mode = true?

Kind regards,
Alvin