Re: [PATCH 2/2] net: mdio: Add BCM6368 MDIO mux bus controller
From: Andrew Lunn
Date: Wed Mar 17 2021 - 13:50:26 EST
> BCM6368 (and newer) SoCs have an integrated ethernet switch controller with dedicated internal phys, but it also supports connecting to external phys not integrated in the internal switch.
> Ports 0-3 are internal, ports 4-7 are external and can be connected to external switches or phys and port 8 is the CPU.
> This MDIO bus device is integrated in the BCM63xx switch registers, which corresponds to the same registers present in drivers/net/dsa/b53/b53_regs.h.
> As you can see in the source code, registers are the same for the internal and external bus. The only difference is that if MDIOC_EXT_MASK (bit 16) is set, the MDIO bus accessed will be the external, and on the contrary, if bit 16 isn’t set, the MDIO bus accessed will be the internal one.
> I don’t know if this answers your question, but I think that adding it as mdiomux is the way to go.
The Marvell mv88e6390 family of switches has a very similar setup. An
internal and an external MDIO bus, one bit difference in a
register. When i wrote the code for that, i decided it was not a mux
as such, but two MDIO busses. So i register two MDIO busses, and rely
on a higher level switch register mutex to prevent parallel operations
on the two busses.
The reason i decided it was not a mux, is that all the other mux
drivers are separate drivers which rely on another MDIO bus
driver. The mux driver gets a handle to the underlying MDIO bus
driver, and and builds on it. Here you have it all combined in one, so
it does not follow the pattern.
So if you want to use a max, please break this up into an MDIO driver,
and a mux driver. Or have one driver which registers two mdio busses,