Re: Advice on MFD-style probing of DSA switch SoCs

Andrew Lunn
2023-02-11T15:50:53Z

> Let's take an absolutely extreme (and hypothetical) example:
>
> +--------------------------------+
> | |
> | Host SoC running Linux |
> | |
> | +----------+ +----------+ |
> | | MDIO | | ETH | |
> | |controller| |controller| |
> | | | | (DSA | |
> | | | | master) | |
> +--+----------+---+----------+---+
> | |
> | |
> MDIO | | ETH
> | |
> v v
> +--------------------------------+
> | CPU port |-------
> | |-------
> | MDIO-controller |-------
> | +----------+ DSA switch #1 |------- External
> | | MDIO | |------- ETH
> | |controller| |------- ports
> | | | |-------
> | | | cascade port |-------
> +--+----------+------------------+
> | ^ |
> | | |
> MDIO | CLK | | ETH
> | | |
> v | v
> +--------------------------------+
> | cascade port |-------
> | |-------
> | |-------
> | MDIO-controlled |------- External
> | switch #2 |------- ETH
> | |------- ports
> | |-------
> | |-------
> +--------------------------------+
>
> where we have a DSA switch tree with 2 chips, both have their registers
> accessible over MDIO. But chip #1 is accessed through the host's MDIO
> controller, and chip #2 through chip #1's MDIO controller.
>
> These chips are also going to be used with PTP, and the PTP timers of
> the 2 switches don't feed off of individual oscillators as would be
> usual, but instead, there is a single oscillator feeding into one
> switch, and that switch forwards this as a clock to the other switch
> (because board designers heard it's more trendy this way). So switch #2
> provides a clock to switch #1.
>
>
> With the current mainline DSA code structure, assuming a monolithically
> written $vendor driver (as basically N-1 of them are), the above would
> not work under any circumstance.

I'm not sure that is true. The switches probe method should register
with the driver core any resources a switch provides. So switch #1
MDIO bus driver is registered during its probe, allowing the probe of
switch #2 to happen. When switch #2 probes, it should register its
clock with the common clock framework, etc.

However, the linking of resources together, the PTP clock in your
example, should happen in the switches setup() call, which only
happens once all the switches in the cluster have probed, so all the
needed resources should be available.

Because we have these two phases, i think the above setup would work.

Andrew