net: dsa: sja1105: add support for SGMII
authorVladimir Oltean <vladimir.oltean@nxp.com>
Wed, 29 Sep 2021 15:04:42 +0000 (18:04 +0300)
committerRamon Fried <rfried.dev@gmail.com>
Tue, 23 Nov 2021 07:57:56 +0000 (09:57 +0200)
commit7f7e73eee3c652481cd45afe5b907cf0c3abb240
treec60b59259d77a0009491b36b17d40384e35f3234
parentf24b666b22048d30347666066ce08bad5720c6a6
net: dsa: sja1105: add support for SGMII

The list of ports which support SGMII depending on switch generation is
available here:
https://www.kernel.org/doc/html/latest/networking/dsa/sja1105.html#port-compatibility-matrix

SGMII can either be used to connect to an external PHY or to the host
port. In the first case, the use of in-band autoneg is expected, in the
last, in-band autoneg is expected to be turned off (fixed-link). So the
driver supports both cases.

SGMII support means configuring the PCS and PMA. The PCS is a Synopsys
Designware XPCS, in Linux this has a separate driver but here it is
embedded within the sja1105 driver. If needed it can be taken out later,
although we would need a UCLASS_PCS for it, which we don't have atm.

Nonetheless, I did go all the way to export an internal MDIO bus for PCS
access, because it is nice to be able to debug the PCS through commands
such as:

=> mdio read ethernet-switch@1-pcs 4 1f.0
Reading from bus ethernet-switch@1-pcs
PHY at address 4:
31.0 - 0x1140

The internal MDIO bus is not registered with DM because there is no
udevice on it, as mentioned. But the XPCS code can still be ripped out,
as needed.

I did not add support for 2500base-x because I do not expect this
interface type to be used as a boot source for anybody, it would just
add unnecessary bloat.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
drivers/net/sja1105.c