]> err.no Git - linux-2.6/blobdiff - drivers/net/dm9000.c
irda: replace __FUNCTION__ with __func__
[linux-2.6] / drivers / net / dm9000.c
index 7c38f6129b55a343b3a50c94a171177dede2bf07..0b0f1c407a7e87568c3f1f6f807208fe64ab4f46 100644 (file)
@@ -54,9 +54,6 @@
 #define writesb        outsb
 #define writesw        outsw
 #define writesl        outsl
-#define DEFAULT_TRIGGER IRQF_TRIGGER_HIGH
-#else
-#define DEFAULT_TRIGGER (0)
 #endif
 
 /*
@@ -343,6 +340,8 @@ static int dm9000_wait_eeprom(board_info_t *db)
                if ((status & EPCR_ERRE) == 0)
                        break;
 
+               msleep(1);
+
                if (timeout-- < 0) {
                        dev_dbg(db->dev, "timeout waiting EEPROM\n");
                        break;
@@ -552,15 +551,48 @@ static const struct ethtool_ops dm9000_ethtool_ops = {
        .set_eeprom             = dm9000_set_eeprom,
 };
 
+static void dm9000_show_carrier(board_info_t *db,
+                               unsigned carrier, unsigned nsr)
+{
+       struct net_device *ndev = db->ndev;
+       unsigned ncr = dm9000_read_locked(db, DM9000_NCR);
+
+       if (carrier)
+               dev_info(db->dev, "%s: link up, %dMbps, %s-duplex, no LPA\n",
+                        ndev->name, (nsr & NSR_SPEED) ? 10 : 100,
+                        (ncr & NCR_FDX) ? "full" : "half");
+       else
+               dev_info(db->dev, "%s: link down\n", ndev->name);
+}
+
 static void
 dm9000_poll_work(struct work_struct *w)
 {
        struct delayed_work *dw = container_of(w, struct delayed_work, work);
        board_info_t *db = container_of(dw, board_info_t, phy_poll);
+       struct net_device *ndev = db->ndev;
+
+       if (db->flags & DM9000_PLATF_SIMPLE_PHY &&
+           !(db->flags & DM9000_PLATF_EXT_PHY)) {
+               unsigned nsr = dm9000_read_locked(db, DM9000_NSR);
+               unsigned old_carrier = netif_carrier_ok(ndev) ? 1 : 0;
+               unsigned new_carrier;
+
+               new_carrier = (nsr & NSR_LINKST) ? 1 : 0;
 
-       mii_check_media(&db->mii, netif_msg_link(db), 0);
+               if (old_carrier != new_carrier) {
+                       if (netif_msg_link(db))
+                               dm9000_show_carrier(db, new_carrier, nsr);
+
+                       if (!new_carrier)
+                               netif_carrier_off(ndev);
+                       else
+                               netif_carrier_on(ndev);
+               }
+       } else
+               mii_check_media(&db->mii, netif_msg_link(db), 0);
        
-       if (netif_running(db->ndev))
+       if (netif_running(ndev))
                dm9000_schedule_poll(db);
 }
 
@@ -856,19 +888,22 @@ dm9000_rx(struct net_device *dev)
                        dev_dbg(db->dev, "RST: RX Len:%x\n", RxLen);
                }
 
-               if (rxhdr.RxStatus & 0xbf) {
+               /* rxhdr.RxStatus is identical to RSR register. */
+               if (rxhdr.RxStatus & (RSR_FOE | RSR_CE | RSR_AE |
+                                     RSR_PLE | RSR_RWTO |
+                                     RSR_LCS | RSR_RF)) {
                        GoodPacket = false;
-                       if (rxhdr.RxStatus & 0x01) {
+                       if (rxhdr.RxStatus & RSR_FOE) {
                                if (netif_msg_rx_err(db))
                                        dev_dbg(db->dev, "fifo error\n");
                                dev->stats.rx_fifo_errors++;
                        }
-                       if (rxhdr.RxStatus & 0x02) {
+                       if (rxhdr.RxStatus & RSR_CE) {
                                if (netif_msg_rx_err(db))
                                        dev_dbg(db->dev, "crc error\n");
                                dev->stats.rx_crc_errors++;
                        }
-                       if (rxhdr.RxStatus & 0x80) {
+                       if (rxhdr.RxStatus & RSR_RF) {
                                if (netif_msg_rx_err(db))
                                        dev_dbg(db->dev, "length error\n");
                                dev->stats.rx_length_errors++;
@@ -979,11 +1014,9 @@ dm9000_open(struct net_device *dev)
        /* If there is no IRQ type specified, default to something that
         * may work, and tell the user that this is a problem */
 
-       if (irqflags == IRQF_TRIGGER_NONE) {
+       if (irqflags == IRQF_TRIGGER_NONE)
                dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
-               irqflags = DEFAULT_TRIGGER;
-       }
-       
+
        irqflags |= IRQF_SHARED;
 
        if (request_irq(dev->irq, &dm9000_interrupt, irqflags, dev->name, dev))
@@ -1037,7 +1070,7 @@ dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg)
        /* Fill the phyxcer register into REG_0C */
        iow(db, DM9000_EPAR, DM9000_PHY | reg);
 
-       iow(db, DM9000_EPCR, 0xc);      /* Issue phyxcer read command */
+       iow(db, DM9000_EPCR, EPCR_ERPRR | EPCR_EPOS);   /* Issue phyxcer read command */
 
        writeb(reg_save, db->io_addr);
        spin_unlock_irqrestore(&db->lock,flags);
@@ -1088,7 +1121,7 @@ dm9000_phy_write(struct net_device *dev,
        iow(db, DM9000_EPDRL, value);
        iow(db, DM9000_EPDRH, value >> 8);
 
-       iow(db, DM9000_EPCR, 0xa);      /* Issue phyxcer write command */
+       iow(db, DM9000_EPCR, EPCR_EPOS | EPCR_ERPRW);   /* Issue phyxcer write command */
 
        writeb(reg_save, db->io_addr);
        spin_unlock_irqrestore(&db->lock, flags);
@@ -1267,6 +1300,10 @@ dm9000_probe(struct platform_device *pdev)
                db->flags = pdata->flags;
        }
 
+#ifdef CONFIG_DM9000_FORCE_SIMPLE_PHY_POLL
+       db->flags |= DM9000_PLATF_SIMPLE_PHY;
+#endif
+
        dm9000_reset(db);
 
        /* try multiple times, DM9000 sometimes gets the read wrong */