Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'qcom-phy-possible'

Robert Marko says:

====================
net: phy: qcom: qca808x: fill in possible_interfaces

QCA808x does not currently fill in the possible_interfaces.

This leads to Phylink not being aware that it supports 2500Base-X as well
so in cases where it is connected to a DSA switch like MV88E6393 it will
limit that port to phy-mode set in the DTS.

That means that if SGMII is used you are limited to 1G only while if
2500Base-X was set you are limited to 2.5G only.

Populating the possible_interfaces fixes this.

Changes in v2:
* Get rid of the if/else by Russels suggestion in the helper
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+24 -5
+24 -5
drivers/net/phy/qcom/qca808x.c
··· 156 156 return linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->supported); 157 157 } 158 158 159 + static bool qca808x_is_1g_only(struct phy_device *phydev) 160 + { 161 + int ret; 162 + 163 + ret = phy_read_mmd(phydev, MDIO_MMD_AN, QCA808X_PHY_MMD7_CHIP_TYPE); 164 + if (ret < 0) 165 + return true; 166 + 167 + return !!(QCA808X_PHY_CHIP_TYPE_1G & ret); 168 + } 169 + 170 + static void qca808x_fill_possible_interfaces(struct phy_device *phydev) 171 + { 172 + unsigned long *possible = phydev->possible_interfaces; 173 + 174 + __set_bit(PHY_INTERFACE_MODE_SGMII, possible); 175 + 176 + if (!qca808x_is_1g_only(phydev)) 177 + __set_bit(PHY_INTERFACE_MODE_2500BASEX, possible); 178 + } 179 + 159 180 static int qca808x_probe(struct phy_device *phydev) 160 181 { 161 182 struct device *dev = &phydev->mdio.dev; ··· 240 219 return ret; 241 220 } 242 221 } 222 + 223 + qca808x_fill_possible_interfaces(phydev); 243 224 244 225 /* Configure adc threshold as 100mv for the link 10M */ 245 226 return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_ADC_THRESHOLD, ··· 373 350 * existed in the bit0 of MMD1.21, we need to remove it manually if 374 351 * it is the qca8081 1G chip according to the bit0 of MMD7.0x901d. 375 352 */ 376 - ret = phy_read_mmd(phydev, MDIO_MMD_AN, QCA808X_PHY_MMD7_CHIP_TYPE); 377 - if (ret < 0) 378 - return ret; 379 - 380 - if (QCA808X_PHY_CHIP_TYPE_1G & ret) 353 + if (qca808x_is_1g_only(phydev)) 381 354 linkmode_clear_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->supported); 382 355 383 356 return 0;