Replace PHY interface mode bitmap handling with comparison test to match
U-Boot PHY subsystem behavior. U-Boot currently implements only single PHY
interface mode for each PHY. Linux currently uses bitmap of PHY interface
modes for each PHY.
The reason why in Linux uses bitmap of supported interface modes is so
that Linux can select the best serdes mode switching behavior for the PHY.
For example if the host only supports 10gbase-r serdes mode, then the PHY
must always talk to the host in 10gbase-r mode, even if the RJ-45 copper
speed was autonegotiated to lower speed (i.e. 1Gbps).
If the host supports both 10gbase-r and sgmii serdes modes, we want the
PHY to switch to sgmii if the RJ-45 speed is 1000/100/10, and to switch
to 10gbase-r if the RJ-45 speed is 10000.
U-Boot does not implement this functionality yet, therefore remove modes
which cannot be currently supported and switch mv_test_bit() to plain
mode comparison.
Fixes: b6fcab0728cb ("net: phy: marvell10g: Adapt Marvell 10G PHY driver from
Linux")
Signed-off-by: Marek Vasut <[email protected]>
---
This is a follow up to this discussion thread:
https://lore.kernel.org/u-boot/bxuuwcj7jm33go7yj4jnafoowrttu2qvbxej7nvdn3pm5az4sj@6xpf3ym2s2ek/
Large chunk of the commit message is also adapted from the
aforementioned thread and explanation from Marek Behun, which
is excellent.
---
Cc: Jerome Forissier <[email protected]>
Cc: Joe Hershberger <[email protected]>
Cc: Marek Behun <[email protected]>
Cc: Ramon Fried <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
---
drivers/net/phy/marvell10g.c | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c
index 8c95bcbb9ad..d6115eea025 100644
--- a/drivers/net/phy/marvell10g.c
+++ b/drivers/net/phy/marvell10g.c
@@ -342,8 +342,7 @@ static int mv2110_select_mactype(struct phy_device *phydev)
{
if (phydev->interface == PHY_INTERFACE_MODE_USXGMII)
return MV_PMA_21X0_PORT_CTRL_MACTYPE_USXGMII;
- else if (phydev->interface == PHY_INTERFACE_MODE_SGMII &&
- !(phydev->interface == PHY_INTERFACE_MODE_10GBASER))
+ else if (phydev->interface == PHY_INTERFACE_MODE_SGMII)
return MV_PMA_21X0_PORT_CTRL_MACTYPE_5GBASER;
else if (phydev->interface == PHY_INTERFACE_MODE_10GBASER)
return MV_PMA_21X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH;
@@ -381,15 +380,6 @@ static int mv3310_select_mactype(struct phy_device *phydev)
{
if (phydev->interface == PHY_INTERFACE_MODE_USXGMII)
return MV_V2_33X0_PORT_CTRL_MACTYPE_USXGMII;
- else if (phydev->interface == PHY_INTERFACE_MODE_SGMII &&
- phydev->interface == PHY_INTERFACE_MODE_10GBASER)
- return MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER;
- else if (phydev->interface == PHY_INTERFACE_MODE_SGMII &&
- phydev->interface == PHY_INTERFACE_MODE_RXAUI)
- return MV_V2_33X0_PORT_CTRL_MACTYPE_RXAUI;
- else if (phydev->interface == PHY_INTERFACE_MODE_SGMII &&
- phydev->interface == PHY_INTERFACE_MODE_XAUI)
- return MV_V2_3310_PORT_CTRL_MACTYPE_XAUI;
else if (phydev->interface == PHY_INTERFACE_MODE_10GBASER)
return MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH;
else if (phydev->interface == PHY_INTERFACE_MODE_RXAUI)
@@ -542,7 +532,7 @@ static bool mv3310_has_downshift(struct phy_device *phydev)
}
#define mv_test_bit(iface, phydev) \
- ({ if ((phydev)->interface & (iface)) return 0; })
+ ({ if ((phydev)->interface == (iface)) return 0; })
static int mv3310_mv3340_test_supported_interfaces(struct phy_device *phydev)
{
--
2.51.0