net: dsa: mt7530-mdio: read PHY address of switch from device tree
authorArınç ÜNAL <arinc.unal@arinc9.com>
Thu, 18 Apr 2024 05:35:30 +0000 (08:35 +0300)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 23 Apr 2024 08:32:40 +0000 (10:32 +0200)
commit868ff5f4944aa90f649de59440abf48bf693680e
tree30092548a680cea23c17d895701b54fde8279ef1
parent077633afe07f4df8297e93332a4c07934c1f7b64
net: dsa: mt7530-mdio: read PHY address of switch from device tree

Read the PHY address the switch listens on from the reg property of the
switch node on the device tree. This change brings support for MT7530
switches on boards with such bootstrapping configuration where the switch
listens on a different PHY address than the hardcoded PHY address on the
driver, 31.

As described on the "MT7621 Programming Guide v0.4" document, the MT7530
switch and its PHYs can be configured to listen on the range of 7-12,
15-20, 23-28, and 31 and 0-4 PHY addresses.

There are operations where the switch PHY registers are used. For the PHY
address of the control PHY, transform the MT753X_CTRL_PHY_ADDR constant
into a macro and use it. The PHY address for the control PHY is 0 when the
switch listens on 31. In any other case, it is one greater than the PHY
address the switch listens on.

Reviewed-by: Daniel Golle <daniel@makrotopia.org>
Tested-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/dsa/mt7530-mdio.c
drivers/net/dsa/mt7530.c
drivers/net/dsa/mt7530.h