]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
drivers/net/phy: introduce phy_set_supported()
authorAlexey Brodkin <Alexey.Brodkin@synopsys.com>
Wed, 13 Jan 2016 13:59:34 +0000 (16:59 +0300)
committerJoe Hershberger <joe.hershberger@ni.com>
Thu, 28 Jan 2016 18:32:42 +0000 (12:32 -0600)
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.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
drivers/net/phy/phy.c
include/phy.h

index d25bec27f079994da3c42c21942d87acc3ecfb3d..e25d4e337d5ca0859fb3c63ad4aaccb16a4ff388 100644 (file)
@@ -528,6 +528,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;
index b793e9053275e982a5a8b4ecfa485d41ed4b7304..e030c9ff2e2436b1a620d4bf03227e5cf320b9d9 100644 (file)
@@ -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);