add support for Xilinx 1000BASE-X phy (GTX)
authorCharles Coldwell <coldwell@gmail.com>
Thu, 21 Feb 2013 13:25:52 +0000 (08:25 -0500)
committerJoe Hershberger <joe.hershberger@ni.com>
Tue, 25 Jun 2013 00:11:13 +0000 (19:11 -0500)
commit 39695029bc15041c809df3db4ba19bd729c447fa
Author: Charles Coldwell <coldwell@ll.mit.edu>
Date:   Tue Feb 19 08:27:33 2013 -0500

    Changes to support the Xilinx 1000BASE-X phy (GTX/MGT)

Signed-off-by: Charles Coldwell <coldwell@ll.mit.edu>
drivers/net/phy/phy.c
include/linux/ethtool.h
include/linux/mii.h

index 77d19c645df2afa3edcb5d2fdb02e2eac1bb47d9..7c0eaec5137f8def0cfbf92b67793f74f0dc7e60 100644 (file)
@@ -75,6 +75,10 @@ static int genphy_config_advert(struct phy_device *phydev)
                adv |= ADVERTISE_PAUSE_CAP;
        if (advertise & ADVERTISED_Asym_Pause)
                adv |= ADVERTISE_PAUSE_ASYM;
+       if (advertise & ADVERTISED_1000baseX_Half)
+               adv |= ADVERTISE_1000XHALF;
+       if (advertise & ADVERTISED_1000baseX_Full)
+               adv |= ADVERTISE_1000XFULL;
 
        if (adv != oldadv) {
                err = phy_write(phydev, MDIO_DEVAD_NONE, MII_ADVERTISE, adv);
@@ -288,6 +292,7 @@ int genphy_parse_link(struct phy_device *phydev)
        if (mii_reg & BMSR_ANEGCAPABLE) {
                u32 lpa = 0;
                u32 gblpa = 0;
+               u32 estatus = 0;
 
                /* Check for gigabit capability */
                if (mii_reg & BMSR_ERCAP) {
@@ -327,6 +332,18 @@ int genphy_parse_link(struct phy_device *phydev)
 
                } else if (lpa & LPA_10FULL)
                        phydev->duplex = DUPLEX_FULL;
+
+               if (mii_reg & BMSR_ESTATEN)
+                       estatus = phy_read(phydev, MDIO_DEVAD_NONE,
+                                          MII_ESTATUS);
+
+               if (estatus & (ESTATUS_1000_XFULL | ESTATUS_1000_XHALF |
+                               ESTATUS_1000_TFULL | ESTATUS_1000_THALF)) {
+                       phydev->speed = SPEED_1000;
+                       if (estatus & (ESTATUS_1000_XFULL | ESTATUS_1000_TFULL))
+                               phydev->duplex = DUPLEX_FULL;
+               }
+
        } else {
                u32 bmcr = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMCR);
 
@@ -384,6 +401,10 @@ int genphy_config(struct phy_device *phydev)
                        features |= SUPPORTED_1000baseT_Full;
                if (val & ESTATUS_1000_THALF)
                        features |= SUPPORTED_1000baseT_Half;
+               if (val & ESTATUS_1000_XFULL)
+                       features |= SUPPORTED_1000baseX_Full;
+               if (val & ESTATUS_1000_XHALF)
+                       features |= SUPPORTED_1000baseX_Full;
        }
 
        phydev->supported = features;
index fcb20fe1082f7047f9fe8037a514d3aea9c45742..f6dbdb096d34c220d12962fe627bc8eb3e401ea0 100644 (file)
@@ -580,6 +580,8 @@ enum ethtool_sfeatures_retval_bits {
 #define SUPPORTED_10000baseKX4_Full    (1 << 18)
 #define SUPPORTED_10000baseKR_Full     (1 << 19)
 #define SUPPORTED_10000baseR_FEC       (1 << 20)
+#define SUPPORTED_1000baseX_Half       (1 << 21)
+#define SUPPORTED_1000baseX_Full       (1 << 22)
 
 /* Indicates what features are advertised by the interface. */
 #define ADVERTISED_10baseT_Half                (1 << 0)
@@ -603,6 +605,8 @@ enum ethtool_sfeatures_retval_bits {
 #define ADVERTISED_10000baseKX4_Full   (1 << 18)
 #define ADVERTISED_10000baseKR_Full    (1 << 19)
 #define ADVERTISED_10000baseR_FEC      (1 << 20)
+#define ADVERTISED_1000baseX_Half      (1 << 21)
+#define ADVERTISED_1000baseX_Full      (1 << 22)
 
 /* The following are all involved in forcing a particular link
  * mode for the device for setting things.  When getting the
index 8b92692146d687db55c61e62c640f745176da509..66b83d83deb4fc5d285e8ad89ca27f0cab3acad4 100644 (file)
 #define EXPANSION_MFAULTS      0x0010  /* Multiple faults detected    */
 #define EXPANSION_RESV         0xffe0  /* Unused...                   */
 
+#define ESTATUS_1000_XFULL     0x8000  /* Can do 1000BX Full */
+#define ESTATUS_1000_XHALF     0x4000  /* Can do 1000BX Half */
 #define ESTATUS_1000_TFULL     0x2000  /* Can do 1000BT Full */
 #define ESTATUS_1000_THALF     0x1000  /* Can do 1000BT Half */