Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-mmc
[pandora-kernel.git] / drivers / net / sundance.c
index 5de0554..f13b2a1 100644 (file)
@@ -80,7 +80,7 @@
          I/O access could affect performance in ARM-based system
        - Add Linux software VLAN support
        
-       Version LK1.08 (D-Link):
+       Version LK1.08 (Philippe De Muyter phdm@macqel.be):
        - Fix bug of custom mac address 
        (StationAddr register only accept word write) 
 
        Version LK1.09a (ICPlus):
        - Add the delay time in reading the contents of EEPROM
 
+       Version LK1.10 (Philippe De Muyter phdm@macqel.be):
+       - Make 'unblock interface after Tx underrun' work
+
+       Version LK1.11 (Pedro Alejandro Lopez-Valencia palopezv at gmail.com):
+       - Add support for IC Plus Corporation IP100A chipset
 */
 
 #define DRV_NAME       "sundance"
-#define DRV_VERSION    "1.01+LK1.09a"
-#define DRV_RELDATE    "10-Jul-2003"
+#define DRV_VERSION    "1.01+LK1.11"
+#define DRV_RELDATE    "14-Jun-2006"
 
 
 /* The user-configurable values.
 static int debug = 1;                  /* 1 normal messages, 0 quiet .. 7 verbose. */
 /* Maximum number of multicast addresses to filter (vs. rx-all-multicast).
    Typical is a 64 element hash table based on the Ethernet CRC.  */
-static int multicast_filter_limit = 32;
+static const int multicast_filter_limit = 32;
 
 /* Set the copy breakpoint for the copy-only-tiny-frames scheme.
    Setting to > 1518 effectively disables this feature.
@@ -263,8 +268,10 @@ IV. Notes
 IVb. References
 
 The Sundance ST201 datasheet, preliminary version.
-http://cesdis.gsfc.nasa.gov/linux/misc/100mbps.html
-http://cesdis.gsfc.nasa.gov/linux/misc/NWay.html
+The Kendin KS8723 datasheet, preliminary version.
+The ICplus IP100 datasheet, preliminary version.
+http://www.scyld.com/expert/100mbps.html
+http://www.scyld.com/expert/NWay.html
 
 IVc. Errata
 
@@ -282,6 +289,7 @@ static struct pci_device_id sundance_pci_tbl[] = {
        {0x1186, 0x1002, 0x1186, 0x1040, 0, 0, 3},
        {0x1186, 0x1002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4},
        {0x13F0, 0x0201, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5},
+       {0x13F0, 0x0200, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6},
        {0,}
 };
 MODULE_DEVICE_TABLE(pci, sundance_pci_tbl);
@@ -293,13 +301,14 @@ enum {
 struct pci_id_info {
         const char *name;
 };
-static struct pci_id_info pci_id_tbl[] = {
+static const struct pci_id_info pci_id_tbl[] = {
        {"D-Link DFE-550TX FAST Ethernet Adapter"},
        {"D-Link DFE-550FX 100Mbps Fiber-optics Adapter"},
        {"D-Link DFE-580TX 4 port Server Adapter"},
        {"D-Link DFE-530TXS FAST Ethernet Adapter"},
        {"D-Link DL10050-based FAST Ethernet Adapter"},
        {"Sundance Technology Alta"},
+       {"IC Plus Corporation IP100A FAST Ethernet Adapter"},
        {NULL,},                        /* 0 terminated list. */
 };
 
@@ -500,6 +509,25 @@ static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 static int  netdev_close(struct net_device *dev);
 static struct ethtool_ops ethtool_ops;
 
+static void sundance_reset(struct net_device *dev, unsigned long reset_cmd)
+{
+       struct netdev_private *np = netdev_priv(dev);
+       void __iomem *ioaddr = np->base + ASICCtrl;
+       int countdown;
+
+       /* ST201 documentation states ASICCtrl is a 32bit register */
+       iowrite32 (reset_cmd | ioread32 (ioaddr), ioaddr);
+       /* ST201 documentation states reset can take up to 1 ms */
+       countdown = 10 + 1;
+       while (ioread32 (ioaddr) & (ResetBusy << 16)) {
+               if (--countdown == 0) {
+                       printk(KERN_WARNING "%s : reset not completed !!\n", dev->name);
+                       break;
+               }
+               udelay(100);
+       }
+}
+
 static int __devinit sundance_probe1 (struct pci_dev *pdev,
                                      const struct pci_device_id *ent)
 {
@@ -609,9 +637,13 @@ static int __devinit sundance_probe1 (struct pci_dev *pdev,
 
        np->phys[0] = 1;                /* Default setting */
        np->mii_preamble_required++;
+       /*
+        * It seems some phys doesn't deal well with address 0 being accessed
+        * first, so leave address zero to the end of the loop (32 & 31).
+        */
        for (phy = 1; phy <= 32 && phy_idx < MII_CNT; phy++) {
-               int mii_status = mdio_read(dev, phy, MII_BMSR);
                int phyx = phy & 0x1f;
+               int mii_status = mdio_read(dev, phyx, MII_BMSR);
                if (mii_status != 0xffff  &&  mii_status != 0x0000) {
                        np->phys[phy_idx++] = phyx;
                        np->mii_if.advertising = mdio_read(dev, phyx, MII_ADVERTISE);
@@ -1190,23 +1222,33 @@ static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs
                                            ("%s: Transmit status is %2.2x.\n",
                                        dev->name, tx_status);
                                if (tx_status & 0x1e) {
+                                       if (netif_msg_tx_err(np))
+                                               printk("%s: Transmit error status %4.4x.\n",
+                                                          dev->name, tx_status);
                                        np->stats.tx_errors++;
                                        if (tx_status & 0x10)
                                                np->stats.tx_fifo_errors++;
                                        if (tx_status & 0x08)
                                                np->stats.collisions++;
+                                       if (tx_status & 0x04)
+                                               np->stats.tx_fifo_errors++;
                                        if (tx_status & 0x02)
                                                np->stats.tx_window_errors++;
-                                       /* This reset has not been verified!. */
-                                       if (tx_status & 0x10) { /* Reset the Tx. */
-                                               np->stats.tx_fifo_errors++;
-                                               spin_lock(&np->lock);
-                                               reset_tx(dev);
-                                               spin_unlock(&np->lock);
+                                       /*
+                                       ** This reset has been verified on
+                                       ** DFE-580TX boards ! phdm@macqel.be.
+                                       */
+                                       if (tx_status & 0x10) { /* TxUnderrun */
+                                               unsigned short txthreshold;
+
+                                               txthreshold = ioread16 (ioaddr + TxStartThresh);
+                                               /* Restart Tx FIFO and transmitter */
+                                               sundance_reset(dev, (NetworkReset|FIFOReset|TxReset) << 16);
+                                               iowrite16 (txthreshold, ioaddr + TxStartThresh);
+                                               /* No need to reset the Tx pointer here */
                                        }
-                                       if (tx_status & 0x1e)   /* Restart the Tx. */
-                                               iowrite16 (TxEnable,
-                                                       ioaddr + MACCtrl1);
+                                       /* Restart the Tx. */
+                                       iowrite16 (TxEnable, ioaddr + MACCtrl1);
                                }
                                /* Yup, this is a documentation bug.  It cost me *hours*. */
                                iowrite16 (0, ioaddr + TxStatus);