]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/net/ns9750_eth.c
DaVinci DM6467: Added ET1011C (LSI) PHY support
[karo-tx-uboot.git] / drivers / net / ns9750_eth.c
index 0559710ccf62d570ee2e08eb9531ef3210eb71b8..9899563c47f31d9615e61623985d0ffa35b2b165 100644 (file)
@@ -37,7 +37,7 @@
 
 #include "ns9750_eth.h"                /* for Ethernet and PHY */
 
-/* some definition to make transistion to linux easier */
+/* some definition to make transition to linux easier */
 
 #define NS9750_DRIVER_NAME     "eth"
 #define KERN_WARNING           "Warning:"
@@ -90,8 +90,8 @@ static int nDebugLvl = DEBUG_ERROR_CRIT;
 # define ASSERT(expr, func)
 #endif /* DEBUG */
 
-#define NS9750_MII_NEG_DELAY           (5*CFG_HZ) /* in s */
-#define TX_TIMEOUT                     (5*CFG_HZ) /* in s */
+#define NS9750_MII_NEG_DELAY           (5*CONFIG_SYS_HZ) /* in s */
+#define TX_TIMEOUT                     (5*CONFIG_SYS_HZ) /* in s */
 
 /* @TODO move it to eeprom.h */
 #define FS_EEPROM_AUTONEG_MASK         0x7
@@ -399,8 +399,8 @@ static int ns9750_eth_reset (void)
                ns9750_mii_get_clock_divisor (nPhyMaxMdioClock);
 
        /* reset PHY */
-       ns9750_mii_write (PHY_COMMON_CTRL, PHY_COMMON_CTRL_RESET);
-       ns9750_mii_write (PHY_COMMON_CTRL, 0);
+       ns9750_mii_write(MII_BMCR, BMCR_RESET);
+       ns9750_mii_write(MII_BMCR, 0);
 
        /* @TODO check time */
        udelay (3000);          /* [2] p.70 says at least 300us reset recovery time. But
@@ -455,26 +455,25 @@ static void ns9750_link_force (void)
 
        DEBUG_FN (DEBUG_LINK);
 
-       uiControl = ns9750_mii_read (PHY_COMMON_CTRL);
-       uiControl &= ~(PHY_COMMON_CTRL_SPD_MA |
-                      PHY_COMMON_CTRL_AUTO_NEG | PHY_COMMON_CTRL_DUPLEX);
+       uiControl = ns9750_mii_read(MII_BMCR);
+       uiControl &= ~(BMCR_SPEED1000 | BMCR_SPEED100 |
+                      BMCR_ANENABLE | BMCR_FULLDPLX);
 
        uiLastLinkStatus = 0;
 
        if ((ucLinkMode & FS_EEPROM_AUTONEG_SPEED_MASK) ==
            FS_EEPROM_AUTONEG_SPEED_100) {
-               uiControl |= PHY_COMMON_CTRL_SPD_100;
+               uiControl |= BMCR_SPEED100;
                uiLastLinkStatus |= PHY_LXT971_STAT2_100BTX;
-       } else
-               uiControl |= PHY_COMMON_CTRL_SPD_10;
+       }
 
        if ((ucLinkMode & FS_EEPROM_AUTONEG_DUPLEX_MASK) ==
            FS_EEPROM_AUTONEG_DUPLEX_FULL) {
-               uiControl |= PHY_COMMON_CTRL_DUPLEX;
+               uiControl |= BMCR_FULLDPLX;
                uiLastLinkStatus |= PHY_LXT971_STAT2_DUPLEX_MODE;
        }
 
-       ns9750_mii_write (PHY_COMMON_CTRL, uiControl);
+       ns9750_mii_write(MII_BMCR, uiControl);
 
        ns9750_link_print_changed ();
        ns9750_link_update_egcr ();
@@ -495,25 +494,23 @@ static void ns9750_link_auto_negotiate (void)
 
        /* run auto-negotation */
        /* define what we are capable of */
-       ns9750_mii_write (PHY_COMMON_AUTO_ADV,
-                         PHY_COMMON_AUTO_ADV_100BTXFD |
-                         PHY_COMMON_AUTO_ADV_100BTX |
-                         PHY_COMMON_AUTO_ADV_10BTFD |
-                         PHY_COMMON_AUTO_ADV_10BT |
-                         PHY_COMMON_AUTO_ADV_802_3);
+       ns9750_mii_write(MII_ADVERTISE,
+                        LPA_100FULL |
+                        LPA_100HALF |
+                        LPA_10FULL |
+                        LPA_10HALF |
+                        PHY_ANLPAR_PSB_802_3);
        /* start auto-negotiation */
-       ns9750_mii_write (PHY_COMMON_CTRL,
-                         PHY_COMMON_CTRL_AUTO_NEG |
-                         PHY_COMMON_CTRL_RES_AUTO);
+       ns9750_mii_write(MII_BMCR, BMCR_ANENABLE | BMCR_ANRESTART);
 
        /* wait for completion */
 
        ulStartJiffies = get_ticks ();
        while (get_ticks () < ulStartJiffies + NS9750_MII_NEG_DELAY) {
-               uiStatus = ns9750_mii_read (PHY_COMMON_STAT);
+               uiStatus = ns9750_mii_read(MII_BMSR);
                if ((uiStatus &
-                    (PHY_COMMON_STAT_AN_COMP | PHY_COMMON_STAT_LNK_STAT)) ==
-                   (PHY_COMMON_STAT_AN_COMP | PHY_COMMON_STAT_LNK_STAT)) {
+                    (BMSR_ANEGCOMPLETE | BMSR_LSTATUS)) ==
+                   (BMSR_ANEGCOMPLETE | BMSR_LSTATUS)) {
                        /* lucky we are, auto-negotiation succeeded */
                        ns9750_link_print_changed ();
                        ns9750_link_update_egcr ();
@@ -571,14 +568,13 @@ static void ns9750_link_print_changed (void)
 
        DEBUG_FN (DEBUG_LINK);
 
-       uiControl = ns9750_mii_read (PHY_COMMON_CTRL);
+       uiControl = ns9750_mii_read(MII_BMCR);
 
-       if ((uiControl & PHY_COMMON_CTRL_AUTO_NEG) ==
-           PHY_COMMON_CTRL_AUTO_NEG) {
-               /* PHY_COMMON_STAT_LNK_STAT is only set on autonegotiation */
-               uiStatus = ns9750_mii_read (PHY_COMMON_STAT);
+       if ((uiControl & BMCR_ANENABLE) == BMCR_ANENABLE) {
+               /* BMSR_LSTATUS is only set on autonegotiation */
+               uiStatus = ns9750_mii_read(MII_BMSR);
 
-               if (!(uiStatus & PHY_COMMON_STAT_LNK_STAT)) {
+               if (!(uiStatus & BMSR_LSTATUS)) {
                        printk (KERN_WARNING NS9750_DRIVER_NAME
                                ": link down\n");
                        /* @TODO Linux: carrier_off */
@@ -592,7 +588,7 @@ static void ns9750_link_print_changed (void)
 
                                /* mask out all uninteresting parts */
                        }
-                       /* other PHYs must store there link information in
+                       /* other PHYs must store their link information in
                           uiStatus as PHY_LXT971 */
                }
        } else {
@@ -637,12 +633,12 @@ static char ns9750_mii_identify_phy (void)
 
        DEBUG_FN (DEBUG_MII);
 
-       phyDetected = (PhyType) uiID1 = ns9750_mii_read (PHY_COMMON_ID1);
+       phyDetected = (PhyType) uiID1 = ns9750_mii_read(MII_PHYSID1);
 
        switch (phyDetected) {
        case PHY_LXT971A:
                szName = "LXT971A";
-               uiID2 = ns9750_mii_read (PHY_COMMON_ID2);
+               uiID2 = ns9750_mii_read(MII_PHYSID2);
                nPhyMaxMdioClock = PHY_LXT971_MDIO_MAX_CLK;
                cRes = 1;
                break;