[PATCH net v3] net: dsa: mt7530: fix impossible MDIO address and issue warning
Arınç ÜNAL
arinc.unal at arinc9.com
Wed Jul 3 00:03:09 PDT 2024
On 03/07/2024 02:44, Daniel Golle wrote:
> The MDIO address of the MT7530 and MT7531 switch ICs can be configured
> using bootstrap pins. However, there are only 4 possible options for the
> switch itself: 7, 15, 23 and 31. As in MediaTek's SDK the address of the
> switch is wrongly stated in the device tree as 0 (while in reality it is
> 31), warn the user about such broken device tree and make a good guess
> what was actually intended.
>
> This is imporant also to not break compatibility with older Device Trees
> as with commit 868ff5f4944a ("net: dsa: mt7530-mdio: read PHY address of
> switch from device tree") the address in device tree will be taken into
> account, while before it was hard-coded to 0x1f.
>
> Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
> Signed-off-by: Daniel Golle <daniel at makrotopia.org>
> ---
> Only tested on BPi-R3 (with various deliberately broken DT) for now!
>
> Changes since v2 [2]:
> - use macros instead of magic numbers
> - introduce helper functions
> - register new device on MDIO bus instead of messing with the address
> and schedule delayed_work to unregister the "wrong" device.
> This is a slightly different approach than suggested by Russell, but
> imho makes things much easier than keeping the "wrong" device and
> having to deal with keeping the removal of both devices linked.
> - improve comments
>
> Changes since v1 [1]:
> - use FW_WARN as suggested.
> - fix build on net tree which doesn't have 'mdiodev' as member of the
> priv struct. Imho including this patch as fix makes sense to warn
> users about broken firmware, even if the change introducing the
> actual breakage is only present in net-next for now.
>
> [1]: https://patchwork.kernel.org/project/netdevbpf/patch/e615351aefba25e990215845e4812e6cb8153b28.1714433716.git.daniel@makrotopia.org/
> [2]: https://patchwork.kernel.org/project/netdevbpf/patch/11f5f127d0350e72569c36f9060b6e642dfaddbb.1714514208.git.daniel@makrotopia.org/
Works on standalone MT7530, MT7621's MCM MT7530, and MT7531. From MT7621's
MCM MT7530:
[ 1.357287] mt7530-mdio mdio-bus:1f: MT7530 adapts as multi-chip module
[ 1.364065] mt7530-mdio mdio-bus:00: [Firmware Warn]: impossible switch MDIO address in device tree, assuming 31
[ 1.374303] mt7530-mdio mdio-bus:00: probe with driver mt7530-mdio failed with error -14
[...]
[ 1.448370] mt7530-mdio mdio-bus:1f: MT7530 adapts as multi-chip module
[ 1.477676] mt7530-mdio mdio-bus:1f: configuring for fixed/rgmii link mode
[ 1.485687] mt7530-mdio mdio-bus:1f: Link is Up - 1Gbps/Full - flow control rx/tx
[ 1.493480] mt7530-mdio mdio-bus:1f: configuring for fixed/trgmii link mode
[ 1.502680] mt7530-mdio mdio-bus:1f lan1 (uninitialized): PHY [mt7530-0:00] driver [MediaTek MT7530 PHY] (irq=17)
[ 1.513620] mt7530-mdio mdio-bus:1f: Link is Up - 1Gbps/Full - flow control rx/tx
[ 1.519671] mt7530-mdio mdio-bus:1f lan2 (uninitialized): PHY [mt7530-0:01] driver [MediaTek MT7530 PHY] (irq=18)
[ 1.533072] mt7530-mdio mdio-bus:1f lan3 (uninitialized): PHY [mt7530-0:02] driver [MediaTek MT7530 PHY] (irq=19)
[ 1.545042] mt7530-mdio mdio-bus:1f lan4 (uninitialized): PHY [mt7530-0:03] driver [MediaTek MT7530 PHY] (irq=20)
[ 1.557031] mt7530-mdio mdio-bus:1f wan (uninitialized): PHY [mt7530-0:04] driver [MediaTek MT7530 PHY] (irq=21)
I'm not fond of the use of the non-standard term, MDIO address, instead of
"PHY Address" as described in 22.2.4.5.5 of IEEE Std 802.3-2022.
Regardless:
Tested-by: Arınç ÜNAL <arinc.unal at arinc9.com>
Reviewed-by: Arınç ÜNAL <arinc.unal at arinc9.com>
Arınç
More information about the linux-arm-kernel
mailing list