]> git.sur5r.net Git - u-boot/blobdiff - drivers/net/phy/phy.c
net: phy: implements probe for Cortina phy
[u-boot] / drivers / net / phy / phy.c
index aac9aa33f839a47e9bce9ed2492f1b4886ef0f2b..17866a244b3a9d8dbcb38c1f703bfc626f5f2b74 100644 (file)
@@ -128,7 +128,7 @@ static int genphy_config_advert(struct phy_device *phydev)
 static int genphy_setup_forced(struct phy_device *phydev)
 {
        int err;
-       int ctl = 0;
+       int ctl = BMCR_ANRESTART;
 
        phydev->pause = phydev->asym_pause = 0;
 
@@ -235,7 +235,8 @@ int genphy_update_link(struct phy_device *phydev)
        if (phydev->link && mii_reg & BMSR_LSTATUS)
                return 0;
 
-       if ((mii_reg & BMSR_ANEGCAPABLE) && !(mii_reg & BMSR_ANEGCOMPLETE)) {
+       if ((phydev->autoneg == AUTONEG_ENABLE) &&
+           !(mii_reg & BMSR_ANEGCOMPLETE)) {
                int i = 0;
 
                printf("%s Waiting for PHY auto negotiation to complete",
@@ -291,7 +292,7 @@ int genphy_parse_link(struct phy_device *phydev)
        int mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);
 
        /* We're using autonegotiation */
-       if (phydev->supported & SUPPORTED_Autoneg) {
+       if (phydev->autoneg == AUTONEG_ENABLE) {
                u32 lpa = 0;
                int gblpa = 0;
                u32 estatus = 0;
@@ -382,8 +383,6 @@ int genphy_config(struct phy_device *phydev)
        int val;
        u32 features;
 
-       /* For now, I'll claim that the generic driver supports
-        * all possible port types */
        features = (SUPPORTED_TP | SUPPORTED_MII
                        | SUPPORTED_AUI | SUPPORTED_FIBRE |
                        SUPPORTED_BNC);
@@ -422,8 +421,8 @@ int genphy_config(struct phy_device *phydev)
                        features |= SUPPORTED_1000baseX_Half;
        }
 
-       phydev->supported = features;
-       phydev->advertising = features;
+       phydev->supported &= features;
+       phydev->advertising &= features;
 
        genphy_config_aneg(phydev);
 
@@ -447,7 +446,9 @@ static struct phy_driver genphy_driver = {
        .uid            = 0xffffffff,
        .mask           = 0xffffffff,
        .name           = "Generic PHY",
-       .features       = 0,
+       .features       = PHY_GBIT_FEATURES | SUPPORTED_MII |
+                         SUPPORTED_AUI | SUPPORTED_FIBRE |
+                         SUPPORTED_BNC,
        .config         = genphy_config,
        .startup        = genphy_startup,
        .shutdown       = genphy_shutdown,
@@ -528,6 +529,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;
@@ -718,6 +743,9 @@ int phy_reset(struct phy_device *phydev)
        int timeout = 500;
        int devad = MDIO_DEVAD_NONE;
 
+       if (phydev->flags & PHY_FLAG_BROKEN_RESET)
+               return 0;
+
 #ifdef CONFIG_PHYLIB_10G
        /* If it's 10G, we need to issue reset through one of the MMDs */
        if (is_10g_interface(phydev->interface)) {