]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - drivers/net/pcmcia/pcnet_cs.c
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[net-next-2.6.git] / drivers / net / pcmcia / pcnet_cs.c
index 49279b0ee526a54a534c6f8c04e7c48aa4aba0d0..c94311aed1ab6e999025165b4fee8514ff720e4c 100644 (file)
@@ -28,6 +28,8 @@
 
 ======================================================================*/
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -35,7 +37,6 @@
 #include <linux/string.h>
 #include <linux/timer.h>
 #include <linux/delay.h>
-#include <linux/ethtool.h>
 #include <linux/netdevice.h>
 #include <linux/log2.h>
 #include <linux/etherdevice.h>
@@ -100,7 +101,6 @@ static void pcnet_release(struct pcmcia_device *link);
 static int pcnet_open(struct net_device *dev);
 static int pcnet_close(struct net_device *dev);
 static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
-static const struct ethtool_ops netdev_ethtool_ops;
 static irqreturn_t ei_irq_wrapper(int irq, void *dev_id);
 static void ei_watchdog(u_long arg);
 static void pcnet_reset_8390(struct net_device *dev);
@@ -434,8 +434,6 @@ static hw_info_t *get_ax88190(struct pcmcia_device *link)
        dev->dev_addr[i] = j & 0xff;
        dev->dev_addr[i+1] = j >> 8;
     }
-    printk(KERN_NOTICE "pcnet_cs: this is an AX88190 card!\n");
-    printk(KERN_NOTICE "pcnet_cs: use axnet_cs instead.\n");
     return NULL;
 }
 
@@ -508,7 +506,8 @@ static int pcnet_confcheck(struct pcmcia_device *p_dev,
                           unsigned int vcc,
                           void *priv_data)
 {
-       int *has_shmem = priv_data;
+       int *priv = priv_data;
+       int try = (*priv & 0x1);
        int i;
        cistpl_io_t *io = &cfg->io;
 
@@ -525,77 +524,103 @@ static int pcnet_confcheck(struct pcmcia_device *p_dev,
                i = p_dev->resource[1]->end = 0;
        }
 
-       *has_shmem = ((cfg->mem.nwin == 1) &&
-                     (cfg->mem.win[0].len >= 0x4000));
+       *priv &= ((cfg->mem.nwin == 1) &&
+                 (cfg->mem.win[0].len >= 0x4000)) ? 0x10 : ~0x10;
+
        p_dev->resource[0]->start = io->win[i].base;
        p_dev->resource[0]->end = io->win[i].len;
-       p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
+       if (!try)
+               p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
+       else
+               p_dev->io_lines = 16;
        if (p_dev->resource[0]->end + p_dev->resource[1]->end >= 32)
                return try_io_port(p_dev);
 
-       return 0;
+       return -EINVAL;
+}
+
+static hw_info_t *pcnet_try_config(struct pcmcia_device *link,
+                                  int *has_shmem, int try)
+{
+       struct net_device *dev = link->priv;
+       hw_info_t *local_hw_info;
+       pcnet_dev_t *info = PRIV(dev);
+       int priv = try;
+       int ret;
+
+       ret = pcmcia_loop_config(link, pcnet_confcheck, &priv);
+       if (ret) {
+               dev_warn(&link->dev, "no useable port range found\n");
+               return NULL;
+       }
+       *has_shmem = (priv & 0x10);
+
+       if (!link->irq)
+               return NULL;
+
+       if (resource_size(link->resource[1]) == 8) {
+               link->conf.Attributes |= CONF_ENABLE_SPKR;
+               link->conf.Status = CCSR_AUDIO_ENA;
+       }
+       if ((link->manf_id == MANFID_IBM) &&
+           (link->card_id == PRODID_IBM_HOME_AND_AWAY))
+               link->conf.ConfigIndex |= 0x10;
+
+       ret = pcmcia_request_configuration(link, &link->conf);
+       if (ret)
+               return NULL;
+
+       dev->irq = link->irq;
+       dev->base_addr = link->resource[0]->start;
+
+       if (info->flags & HAS_MISC_REG) {
+               if ((if_port == 1) || (if_port == 2))
+                       dev->if_port = if_port;
+               else
+                       dev_notice(&link->dev, "invalid if_port requested\n");
+       } else
+               dev->if_port = 0;
+
+       if ((link->conf.ConfigBase == 0x03c0) &&
+           (link->manf_id == 0x149) && (link->card_id == 0xc1ab)) {
+               dev_info(&link->dev,
+                       "this is an AX88190 card - use axnet_cs instead.\n");
+               return NULL;
+       }
+
+       local_hw_info = get_hwinfo(link);
+       if (!local_hw_info)
+               local_hw_info = get_prom(link);
+       if (!local_hw_info)
+               local_hw_info = get_dl10019(link);
+       if (!local_hw_info)
+               local_hw_info = get_ax88190(link);
+       if (!local_hw_info)
+               local_hw_info = get_hwired(link);
+
+       return local_hw_info;
 }
 
 static int pcnet_config(struct pcmcia_device *link)
 {
     struct net_device *dev = link->priv;
     pcnet_dev_t *info = PRIV(dev);
-    int ret, start_pg, stop_pg, cm_offset;
+    int start_pg, stop_pg, cm_offset;
     int has_shmem = 0;
     hw_info_t *local_hw_info;
 
     dev_dbg(&link->dev, "pcnet_config\n");
 
-    ret = pcmcia_loop_config(link, pcnet_confcheck, &has_shmem);
-    if (ret)
-       goto failed;
-
-    if (!link->irq)
-           goto failed;
-
-    if (resource_size(link->resource[1]) == 8) {
-       link->conf.Attributes |= CONF_ENABLE_SPKR;
-       link->conf.Status = CCSR_AUDIO_ENA;
-    }
-    if ((link->manf_id == MANFID_IBM) &&
-       (link->card_id == PRODID_IBM_HOME_AND_AWAY))
-       link->conf.ConfigIndex |= 0x10;
-
-    ret = pcmcia_request_configuration(link, &link->conf);
-    if (ret)
-           goto failed;
-    dev->irq = link->irq;
-    dev->base_addr = link->resource[0]->start;
-    if (info->flags & HAS_MISC_REG) {
-       if ((if_port == 1) || (if_port == 2))
-           dev->if_port = if_port;
-       else
-           printk(KERN_NOTICE "pcnet_cs: invalid if_port requested\n");
-    } else {
-       dev->if_port = 0;
-    }
-
-    if ((link->conf.ConfigBase == 0x03c0) &&
-       (link->manf_id == 0x149) && (link->card_id == 0xc1ab)) {
-       printk(KERN_INFO "pcnet_cs: this is an AX88190 card!\n");
-       printk(KERN_INFO "pcnet_cs: use axnet_cs instead.\n");
-       goto failed;
-    }
-
-    local_hw_info = get_hwinfo(link);
-    if (local_hw_info == NULL)
-       local_hw_info = get_prom(link);
-    if (local_hw_info == NULL)
-       local_hw_info = get_dl10019(link);
-    if (local_hw_info == NULL)
-       local_hw_info = get_ax88190(link);
-    if (local_hw_info == NULL)
-       local_hw_info = get_hwired(link);
-
-    if (local_hw_info == NULL) {
-       printk(KERN_NOTICE "pcnet_cs: unable to read hardware net"
-              " address for io base %#3lx\n", dev->base_addr);
-       goto failed;
+    local_hw_info = pcnet_try_config(link, &has_shmem, 0);
+    if (!local_hw_info) {
+           /* check whether forcing io_lines to 16 helps... */
+           pcmcia_disable_device(link);
+           local_hw_info = pcnet_try_config(link, &has_shmem, 1);
+           if (local_hw_info == NULL) {
+                   dev_notice(&link->dev, "unable to read hardware net"
+                           " address for io base %#3lx\n", dev->base_addr);
+                   goto failed;
+           }
     }
 
     info->flags = local_hw_info->flags;
@@ -626,9 +651,7 @@ static int pcnet_config(struct pcmcia_device *link)
 
     ei_status.name = "NE2000";
     ei_status.word16 = 1;
-    ei_status.reset_8390 = &pcnet_reset_8390;
-
-    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
+    ei_status.reset_8390 = pcnet_reset_8390;
 
     if (info->flags & (IS_DL10019|IS_DL10022))
        mii_phy_probe(dev);
@@ -636,25 +659,25 @@ static int pcnet_config(struct pcmcia_device *link)
     SET_NETDEV_DEV(dev, &link->dev);
 
     if (register_netdev(dev) != 0) {
-       printk(KERN_NOTICE "pcnet_cs: register_netdev() failed\n");
+       pr_notice("register_netdev() failed\n");
        goto failed;
     }
 
     if (info->flags & (IS_DL10019|IS_DL10022)) {
        u_char id = inb(dev->base_addr + 0x1a);
-       printk(KERN_INFO "%s: NE2000 (DL100%d rev %02x): ",
-              dev->name, ((info->flags & IS_DL10022) ? 22 : 19), id);
+       netdev_info(dev, "NE2000 (DL100%d rev %02x): ",
+              (info->flags & IS_DL10022) ? 22 : 19, id);
        if (info->pna_phy)
-           printk("PNA, ");
+           pr_cont("PNA, ");
     } else {
-       printk(KERN_INFO "%s: NE2000 Compatible: ", dev->name);
+       netdev_info(dev, "NE2000 Compatible: ");
     }
-    printk("io %#3lx, irq %d,", dev->base_addr, dev->irq);
+    pr_cont("io %#3lx, irq %d,", dev->base_addr, dev->irq);
     if (info->flags & USE_SHMEM)
-       printk (" mem %#5lx,", dev->mem_start);
+       pr_cont(" mem %#5lx,", dev->mem_start);
     if (info->flags & HAS_MISC_REG)
-       printk(" %s xcvr,", if_names[dev->if_port]);
-    printk(" hw_addr %pM\n", dev->dev_addr);
+       pr_cont(" %s xcvr,", if_names[dev->if_port]);
+    pr_cont(" hw_addr %pM\n", dev->dev_addr);
     return 0;
 
 failed:
@@ -928,7 +951,7 @@ static void mii_phy_probe(struct net_device *dev)
        phyid = tmp << 16;
        phyid |= mdio_read(mii_addr, i, MII_PHYID_REG2);
        phyid &= MII_PHYID_REV_MASK;
-       pr_debug("%s: MII at %d is 0x%08x\n", dev->name, i, phyid);
+       netdev_dbg(dev, "MII at %d is 0x%08x\n", i, phyid);
        if (phyid == AM79C9XX_HOME_PHY) {
            info->pna_phy = i;
        } else if (phyid != AM79C9XX_ETH_PHY) {
@@ -961,7 +984,7 @@ static int pcnet_open(struct net_device *dev)
     info->phy_id = info->eth_phy;
     info->link_status = 0x00;
     init_timer(&info->watchdog);
-    info->watchdog.function = &ei_watchdog;
+    info->watchdog.function = ei_watchdog;
     info->watchdog.data = (u_long)dev;
     info->watchdog.expires = jiffies + HZ;
     add_timer(&info->watchdog);
@@ -1014,8 +1037,8 @@ static void pcnet_reset_8390(struct net_device *dev)
     outb_p(ENISR_RESET, nic_base + EN0_ISR); /* Ack intr. */
 
     if (i == 100)
-       printk(KERN_ERR "%s: pcnet_reset_8390() did not complete.\n",
-              dev->name);
+       netdev_err(dev, "pcnet_reset_8390() did not complete.\n");
+
     set_misc_reg(dev);
 
 } /* pcnet_reset_8390 */
@@ -1031,8 +1054,7 @@ static int set_config(struct net_device *dev, struct ifmap *map)
        else if ((map->port < 1) || (map->port > 2))
            return -EINVAL;
        dev->if_port = map->port;
-       printk(KERN_INFO "%s: switched to %s port\n",
-              dev->name, if_names[dev->if_port]);
+       netdev_info(dev, "switched to %s port\n", if_names[dev->if_port]);
        NS8390_init(dev, 1);
     }
     return 0;
@@ -1067,7 +1089,7 @@ static void ei_watchdog(u_long arg)
        this, we can limp along even if the interrupt is blocked */
     if (info->stale++ && (inb_p(nic_base + EN0_ISR) & ENISR_ALL)) {
        if (!info->fast_poll)
-           printk(KERN_INFO "%s: interrupt(s) dropped!\n", dev->name);
+           netdev_info(dev, "interrupt(s) dropped!\n");
        ei_irq_wrapper(dev->irq, dev);
        info->fast_poll = HZ;
     }
@@ -1087,7 +1109,7 @@ static void ei_watchdog(u_long arg)
        if (info->eth_phy) {
            info->phy_id = info->eth_phy = 0;
        } else {
-           printk(KERN_INFO "%s: MII is missing!\n", dev->name);
+           netdev_info(dev, "MII is missing!\n");
            info->flags &= ~HAS_MII;
        }
        goto reschedule;
@@ -1096,8 +1118,7 @@ static void ei_watchdog(u_long arg)
     link &= 0x0004;
     if (link != info->link_status) {
        u_short p = mdio_read(mii_addr, info->phy_id, 5);
-       printk(KERN_INFO "%s: %s link beat\n", dev->name,
-              (link) ? "found" : "lost");
+       netdev_info(dev, "%s link beat\n", link ? "found" : "lost");
        if (link && (info->flags & IS_DL10022)) {
            /* Disable collision detection on full duplex links */
            outb((p & 0x0140) ? 4 : 0, nic_base + DLINK_DIAG);
@@ -1108,13 +1129,12 @@ static void ei_watchdog(u_long arg)
        if (link) {
            if (info->phy_id == info->eth_phy) {
                if (p)
-                   printk(KERN_INFO "%s: autonegotiation complete: "
-                          "%sbaseT-%cD selected\n", dev->name,
+                   netdev_info(dev, "autonegotiation complete: "
+                          "%sbaseT-%cD selected\n",
                           ((p & 0x0180) ? "100" : "10"),
                           ((p & 0x0140) ? 'F' : 'H'));
                else
-                   printk(KERN_INFO "%s: link partner did not "
-                          "autonegotiate\n", dev->name);
+                   netdev_info(dev, "link partner did not autonegotiate\n");
            }
            NS8390_init(dev, 1);
        }
@@ -1127,7 +1147,7 @@ static void ei_watchdog(u_long arg)
            /* isolate this MII and try flipping to the other one */
            mdio_write(mii_addr, info->phy_id, 0, 0x0400);
            info->phy_id ^= info->pna_phy ^ info->eth_phy;
-           printk(KERN_INFO "%s: switched to %s transceiver\n", dev->name,
+           netdev_info(dev, "switched to %s transceiver\n",
                   (info->phy_id == info->eth_phy) ? "ethernet" : "PNA");
            mdio_write(mii_addr, info->phy_id, 0,
                       (info->phy_id == info->eth_phy) ? 0x1000 : 0);
@@ -1143,18 +1163,6 @@ reschedule:
 
 /*====================================================================*/
 
-static void netdev_get_drvinfo(struct net_device *dev,
-                              struct ethtool_drvinfo *info)
-{
-       strcpy(info->driver, "pcnet_cs");
-}
-
-static const struct ethtool_ops netdev_ethtool_ops = {
-       .get_drvinfo            = netdev_get_drvinfo,
-};
-
-/*====================================================================*/
-
 
 static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
@@ -1187,9 +1195,9 @@ static void dma_get_8390_hdr(struct net_device *dev,
     unsigned int nic_base = dev->base_addr;
 
     if (ei_status.dmaing) {
-       printk(KERN_NOTICE "%s: DMAing conflict in dma_block_input."
+       netdev_notice(dev, "DMAing conflict in dma_block_input."
               "[DMAstat:%1x][irqlock:%1x]\n",
-              dev->name, ei_status.dmaing, ei_status.irqlock);
+              ei_status.dmaing, ei_status.irqlock);
        return;
     }
 
@@ -1220,11 +1228,11 @@ static void dma_block_input(struct net_device *dev, int count,
     char *buf = skb->data;
 
     if ((ei_debug > 4) && (count != 4))
-       pr_debug("%s: [bi=%d]\n", dev->name, count+4);
+       netdev_dbg(dev, "[bi=%d]\n", count+4);
     if (ei_status.dmaing) {
-       printk(KERN_NOTICE "%s: DMAing conflict in dma_block_input."
+       netdev_notice(dev, "DMAing conflict in dma_block_input."
               "[DMAstat:%1x][irqlock:%1x]\n",
-              dev->name, ei_status.dmaing, ei_status.irqlock);
+              ei_status.dmaing, ei_status.irqlock);
        return;
     }
     ei_status.dmaing |= 0x01;
@@ -1254,9 +1262,9 @@ static void dma_block_input(struct net_device *dev, int count,
                break;
        } while (--tries > 0);
        if (tries <= 0)
-           printk(KERN_NOTICE "%s: RX transfer address mismatch,"
+           netdev_notice(dev, "RX transfer address mismatch,"
                   "%#4.4x (expected) vs. %#4.4x (actual).\n",
-                  dev->name, ring_offset + xfer_count, addr);
+                  ring_offset + xfer_count, addr);
     }
 #endif
     outb_p(ENISR_RDC, nic_base + EN0_ISR);     /* Ack intr. */
@@ -1277,7 +1285,7 @@ static void dma_block_output(struct net_device *dev, int count,
 
 #ifdef PCMCIA_DEBUG
     if (ei_debug > 4)
-       printk(KERN_DEBUG "%s: [bo=%d]\n", dev->name, count);
+       netdev_dbg(dev, "[bo=%d]\n", count);
 #endif
 
     /* Round the count up for word writes.  Do we need to do this?
@@ -1286,9 +1294,9 @@ static void dma_block_output(struct net_device *dev, int count,
     if (count & 0x01)
        count++;
     if (ei_status.dmaing) {
-       printk(KERN_NOTICE "%s: DMAing conflict in dma_block_output."
+       netdev_notice(dev, "DMAing conflict in dma_block_output."
               "[DMAstat:%1x][irqlock:%1x]\n",
-              dev->name, ei_status.dmaing, ei_status.irqlock);
+              ei_status.dmaing, ei_status.irqlock);
        return;
     }
     ei_status.dmaing |= 0x01;
@@ -1325,9 +1333,9 @@ static void dma_block_output(struct net_device *dev, int count,
                break;
        } while (--tries > 0);
        if (tries <= 0) {
-           printk(KERN_NOTICE "%s: Tx packet transfer address mismatch,"
+           netdev_notice(dev, "Tx packet transfer address mismatch,"
                   "%#4.4x (expected) vs. %#4.4x (actual).\n",
-                  dev->name, (start_page << 8) + count, addr);
+                  (start_page << 8) + count, addr);
            if (retries++ == 0)
                goto retry;
        }
@@ -1336,8 +1344,7 @@ static void dma_block_output(struct net_device *dev, int count,
 
     while ((inb_p(nic_base + EN0_ISR) & ENISR_RDC) == 0)
        if (time_after(jiffies, dma_start + PCNET_RDC_TIMEOUT)) {
-           printk(KERN_NOTICE "%s: timeout waiting for Tx RDC.\n",
-                  dev->name);
+           netdev_notice(dev, "timeout waiting for Tx RDC.\n");
            pcnet_reset_8390(dev);
            NS8390_init(dev, 1);
            break;
@@ -1361,9 +1368,9 @@ static int setup_dma_config(struct pcmcia_device *link, int start_pg,
     ei_status.stop_page = stop_pg;
 
     /* set up block i/o functions */
-    ei_status.get_8390_hdr = &dma_get_8390_hdr;
-    ei_status.block_input = &dma_block_input;
-    ei_status.block_output = &dma_block_output;
+    ei_status.get_8390_hdr = dma_get_8390_hdr;
+    ei_status.block_input = dma_block_input;
+    ei_status.block_output = dma_block_output;
 
     return 0;
 }
@@ -1509,9 +1516,9 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
     ei_status.stop_page = start_pg + ((req.Size - offset) >> 8);
 
     /* set up block i/o functions */
-    ei_status.get_8390_hdr = &shmem_get_8390_hdr;
-    ei_status.block_input = &shmem_block_input;
-    ei_status.block_output = &shmem_block_output;
+    ei_status.get_8390_hdr = shmem_get_8390_hdr;
+    ei_status.block_input = shmem_block_input;
+    ei_status.block_output = shmem_block_output;
 
     info->flags |= USE_SHMEM;
     return 0;