Skip to contentSkip to conversation

drivers/net/phy: introduce phy_set_supported()

PATCH New Alexey Brodkin 1 participant 2 messages Dec 23, 2015 – Jan 11, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/net/phy: introduce phy_set_supported()

This new function will allow MAC drivers to override supported capabilities of the phy. It is required when MAC cannot handle all speeds supported by phy.

For example phy supports up-to 1Gb connections while MAC may only work in modes up to 100 or even 10 Mbit/sec.

---
 drivers/net/phy/phy.c | 24 ++++++++++++++++++++++++
 include/phy.h         |  1 +
 2 files changed, 25 insertions(+)
drivers/net/phy/phy.c +24 -0
index ec9be6b..4ad4e78 100644
@@ -526,6 +526,30 @@ int phy_register(struct phy_driver *drv)
 	return 0;
 }
 
+int phy_set_supported(struct phy_device *phydev, u32 max_speed)
+{
+	/* The default values for phydev->supported are provided by the PHY
+	 * driver "features" member, we want to reset to sane defaults first
+	 * before supporting higher speeds.
+	 */
+	phydev->supported &= PHY_DEFAULT_FEATURES;
+
+	switch (max_speed) {
+	default:
+		return -ENOTSUPP;
+	case SPEED_1000:
+		phydev->supported |= PHY_1000BT_FEATURES;
+		/* fall through */
+	case SPEED_100:
+		phydev->supported |= PHY_100BT_FEATURES;
+		/* fall through */
+	case SPEED_10:
+		phydev->supported |= PHY_10BT_FEATURES;
+	}
+
+	return 0;
+}
+
 static int phy_probe(struct phy_device *phydev)
 {
 	int err = 0;
include/phy.h +1 -0
index b793e90..e030c9f 100644
@@ -234,6 +234,7 @@ int phy_startup(struct phy_device *phydev);
 int phy_config(struct phy_device *phydev);
 int phy_shutdown(struct phy_device *phydev);
 int phy_register(struct phy_driver *drv);
+int phy_set_supported(struct phy_device *phydev, u32 max_speed);
 int genphy_config_aneg(struct phy_device *phydev);
 int genphy_restart_aneg(struct phy_device *phydev);
 int genphy_update_link(struct phy_device *phydev);
Signature · 1 line
2.4.3
#1 lore raw

PATCH 1/1 drivers/net/phy: introduce phy_set_supported()

Hi Joe,

Quoted 54 lines · Alexey Brodkin

This new function will allow MAC drivers to override supported capabilities of the phy. It is required when MAC cannot handle all speeds supported by phy.

For example phy supports up-to 1Gb connections while MAC may only work in modes up to 100 or even 10 Mbit/sec.

---
 drivers/net/phy/phy.c | 24 ++++++++++++++++++++++++
 include/phy.h         |  1 +
 2 files changed, 25 insertions(+)
drivers/net/phy/phy.c +24 -0
index ec9be6b..4ad4e78 100644
@@ -526,6 +526,30 @@ int phy_register(struct phy_driver *drv)
 	return 0;
 }
 
+int phy_set_supported(struct phy_device *phydev, u32 max_speed)
+{
+	/* The default values for phydev->supported are provided by the PHY
+	 * driver "features" member, we want to reset to sane defaults first
+	 * before supporting higher speeds.
+	 */
+	phydev->supported &= PHY_DEFAULT_FEATURES;
+
+	switch (max_speed) {
+	default:
+		return -ENOTSUPP;
+	case SPEED_1000:
+		phydev->supported |= PHY_1000BT_FEATURES;
+		/* fall through */
+	case SPEED_100:
+		phydev->supported |= PHY_100BT_FEATURES;
+		/* fall through */
+	case SPEED_10:
+		phydev->supported |= PHY_10BT_FEATURES;
+	}
+
+	return 0;
+}
+
 static int phy_probe(struct phy_device *phydev)
 {
 	int err = 0;
include/phy.h +0 -0
index b793e90..e030c9f 100644

include/phy.h int phy_startup(struct phy_device *phydev); · line 240

Quoted 7 lines
include/phy.h +1 -0
@@ -234,6 +234,7 @@ int phy_startup(struct phy_device *phydev);
 int phy_config(struct phy_device *phydev);
 int phy_shutdown(struct phy_device *phydev);
 int phy_register(struct phy_driver *drv);
+int phy_set_supported(struct phy_device *phydev, u32 max_speed);
 int genphy_config_aneg(struct phy_device *phydev);
 int genphy_restart_aneg(struct phy_device *phydev);
 int genphy_update_link(struct phy_device *phydev);

Any chance for this one to be applied?

-Alexey