]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/net/pcmcia/smc91c92_cs.c
Merge branch 'master' into csb1725
[mv-sheeva.git] / drivers / net / pcmcia / smc91c92_cs.c
index 377367d03b419dd7907262bfaedaf3acc0d60aca..8a9ff53189236eff17bca6abd2afb8d5f9ac8809 100644 (file)
@@ -25,6 +25,8 @@
 
 ======================================================================*/
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -44,7 +46,6 @@
 #include <linux/jiffies.h>
 #include <linux/firmware.h>
 
-#include <pcmcia/cs.h>
 #include <pcmcia/cistpl.h>
 #include <pcmcia/cisreg.h>
 #include <pcmcia/ciscode.h>
@@ -294,20 +295,12 @@ static const struct net_device_ops smc_netdev_ops = {
        .ndo_tx_timeout         = smc_tx_timeout,
        .ndo_set_config         = s9k_config,
        .ndo_set_multicast_list = set_rx_mode,
-       .ndo_do_ioctl           = &smc_ioctl,
+       .ndo_do_ioctl           = smc_ioctl,
        .ndo_change_mtu         = eth_change_mtu,
        .ndo_set_mac_address    = eth_mac_addr,
        .ndo_validate_addr      = eth_validate_addr,
 };
 
-/*======================================================================
-
-  smc91c92_attach() creates an "instance" of the driver, allocating
-  local data structures for one device.  The device is registered
-  with Card Services.
-
-======================================================================*/
-
 static int smc91c92_probe(struct pcmcia_device *link)
 {
     struct smc_private *smc;
@@ -324,10 +317,6 @@ static int smc91c92_probe(struct pcmcia_device *link)
     link->priv = dev;
 
     spin_lock_init(&smc->lock);
-    link->resource[0]->end = 16;
-    link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
-    link->conf.Attributes = CONF_ENABLE_IRQ;
-    link->conf.IntType = INT_MEMORY_AND_IO;
 
     /* The SMC91c92-specific entries in the device structure. */
     dev->netdev_ops = &smc_netdev_ops;
@@ -343,15 +332,6 @@ static int smc91c92_probe(struct pcmcia_device *link)
     return smc91c92_config(link);
 } /* smc91c92_attach */
 
-/*======================================================================
-
-    This deletes a driver "instance".  The device is de-registered
-    with Card Services.  If it has been released, all local data
-    structures are freed.  Otherwise, the structures will be freed
-    when the device is released.
-
-======================================================================*/
-
 static void smc91c92_detach(struct pcmcia_device *link)
 {
     struct net_device *dev = link->priv;
@@ -412,26 +392,28 @@ static int mhz_3288_power(struct pcmcia_device *link)
     mdelay(200);
 
     /* Now read and write the COR... */
-    tmp = readb(smc->base + link->conf.ConfigBase + CISREG_COR);
+    tmp = readb(smc->base + link->config_base + CISREG_COR);
     udelay(5);
-    writeb(tmp, smc->base + link->conf.ConfigBase + CISREG_COR);
+    writeb(tmp, smc->base + link->config_base + CISREG_COR);
 
     return 0;
 }
 
-static int mhz_mfc_config_check(struct pcmcia_device *p_dev,
-                               cistpl_cftable_entry_t *cf,
-                               cistpl_cftable_entry_t *dflt,
-                               unsigned int vcc,
-                               void *priv_data)
+static int mhz_mfc_config_check(struct pcmcia_device *p_dev, void *priv_data)
 {
        int k;
-       p_dev->resource[1]->start = cf->io.win[0].base;
+       p_dev->io_lines = 16;
+       p_dev->resource[1]->start = p_dev->resource[0]->start;
+       p_dev->resource[1]->end = 8;
+       p_dev->resource[1]->flags &= ~IO_DATA_PATH_WIDTH;
+       p_dev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
+       p_dev->resource[0]->end = 16;
+       p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
+       p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
        for (k = 0; k < 0x400; k += 0x10) {
                if (k & 0x80)
                        continue;
                p_dev->resource[0]->start = k ^ 0x300;
-               p_dev->io_lines = 16;
                if (!pcmcia_request_io(p_dev))
                        return 0;
        }
@@ -442,14 +424,11 @@ static int mhz_mfc_config(struct pcmcia_device *link)
 {
     struct net_device *dev = link->priv;
     struct smc_private *smc = netdev_priv(dev);
-    win_req_t req;
     unsigned int offset;
     int i;
 
-    link->conf.Attributes |= CONF_ENABLE_SPKR;
-    link->conf.Status = CCSR_AUDIO_ENA;
-    link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
-    link->resource[1]->end = 8;
+    link->config_flags |= CONF_ENABLE_SPKR | CONF_ENABLE_IRQ |
+           CONF_AUTO_SET_IO;
 
     /* The Megahertz combo cards have modem-like CIS entries, so
        we have to explicitly try a bunch of port combinations. */
@@ -459,16 +438,16 @@ static int mhz_mfc_config(struct pcmcia_device *link)
     dev->base_addr = link->resource[0]->start;
 
     /* Allocate a memory window, for accessing the ISR */
-    req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
-    req.Base = req.Size = 0;
-    req.AccessSpeed = 0;
-    i = pcmcia_request_window(link, &req, &link->win);
+    link->resource[2]->flags = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
+    link->resource[2]->start = link->resource[2]->end = 0;
+    i = pcmcia_request_window(link, link->resource[2], 0);
     if (i != 0)
            return -ENODEV;
 
-    smc->base = ioremap(req.Base, req.Size);
-    offset = (smc->manfid == MANFID_MOTOROLA) ? link->conf.ConfigBase : 0;
-    i = pcmcia_map_mem_page(link, link->win, offset);
+    smc->base = ioremap(link->resource[2]->start,
+                   resource_size(link->resource[2]));
+    offset = (smc->manfid == MANFID_MOTOROLA) ? link->config_base : 0;
+    i = pcmcia_map_mem_page(link, link->resource[2], offset);
     if ((i == 0) &&
        (smc->manfid == MANFID_MEGAHERTZ) &&
        (smc->cardid == PRODID_MEGAHERTZ_EM3288))
@@ -591,14 +570,12 @@ static int mot_setup(struct pcmcia_device *link)
 
 /*====================================================================*/
 
-static int smc_configcheck(struct pcmcia_device *p_dev,
-                          cistpl_cftable_entry_t *cf,
-                          cistpl_cftable_entry_t *dflt,
-                          unsigned int vcc,
-                          void *priv_data)
+static int smc_configcheck(struct pcmcia_device *p_dev, void *priv_data)
 {
-       p_dev->resource[0]->start = cf->io.win[0].base;
-       p_dev->io_lines = cf->io.flags & CISTPL_IO_LINES_MASK;
+       p_dev->resource[0]->end = 16;
+       p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
+       p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
+
        return pcmcia_request_io(p_dev);
 }
 
@@ -607,7 +584,8 @@ static int smc_config(struct pcmcia_device *link)
     struct net_device *dev = link->priv;
     int i;
 
-    link->resource[0]->end = 16;
+    link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
+
     i = pcmcia_loop_config(link, smc_configcheck, NULL);
     if (!i)
            dev->base_addr = link->resource[0]->start;
@@ -640,15 +618,14 @@ static int osi_config(struct pcmcia_device *link)
     static const unsigned int com[4] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
     int i, j;
 
-    link->conf.Attributes |= CONF_ENABLE_SPKR;
-    link->conf.Status = CCSR_AUDIO_ENA;
+    link->config_flags |= CONF_ENABLE_SPKR | CONF_ENABLE_IRQ;
     link->resource[0]->end = 64;
     link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
     link->resource[1]->end = 8;
 
     /* Enable Hard Decode, LAN, Modem */
-    link->conf.ConfigIndex = 0x23;
     link->io_lines = 16;
+    link->config_index = 0x23;
 
     for (i = j = 0; j < 4; j++) {
        link->resource[1]->start = com[j];
@@ -658,7 +635,7 @@ static int osi_config(struct pcmcia_device *link)
     }
     if (i != 0) {
        /* Fallback: turn off hard decode */
-       link->conf.ConfigIndex = 0x03;
+       link->config_index = 0x03;
        link->resource[1]->end = 0;
        i = pcmcia_request_io(link);
     }
@@ -813,31 +790,20 @@ static int check_sig(struct pcmcia_device *link)
        ((s >> 8) != (s & 0xff))) {
        SMC_SELECT_BANK(3);
        s = inw(ioaddr + REVISION);
-       return (s & 0xff);
+       return s & 0xff;
     }
 
     if (width) {
-           modconf_t mod = {
-                   .Attributes = CONF_IO_CHANGE_WIDTH,
-           };
-           printk(KERN_INFO "smc91c92_cs: using 8-bit IO window.\n");
+           pr_info("using 8-bit IO window\n");
 
            smc91c92_suspend(link);
-           pcmcia_modify_configuration(link, &mod);
+           pcmcia_fixup_iowidth(link);
            smc91c92_resume(link);
            return check_sig(link);
     }
     return -ENODEV;
 }
 
-/*======================================================================
-
-    smc91c92_config() is scheduled to run after a CARD_INSERTION event
-    is received, to configure the PCMCIA socket, and to make the
-    ethernet device available to the system.
-
-======================================================================*/
-
 static int smc91c92_config(struct pcmcia_device *link)
 {
     struct net_device *dev = link->priv;
@@ -869,7 +835,7 @@ static int smc91c92_config(struct pcmcia_device *link)
     i = pcmcia_request_irq(link, smc_interrupt);
     if (i)
            goto config_failed;
-    i = pcmcia_request_configuration(link, &link->conf);
+    i = pcmcia_enable_device(link);
     if (i)
            goto config_failed;
 
@@ -881,7 +847,7 @@ static int smc91c92_config(struct pcmcia_device *link)
     if ((if_port >= 0) && (if_port <= 2))
        dev->if_port = if_port;
     else
-       printk(KERN_NOTICE "smc91c92_cs: invalid if_port requested\n");
+       dev_notice(&link->dev, "invalid if_port requested\n");
 
     switch (smc->manfid) {
     case MANFID_OSITECH:
@@ -899,7 +865,7 @@ static int smc91c92_config(struct pcmcia_device *link)
     }
 
     if (i != 0) {
-       printk(KERN_NOTICE "smc91c92_cs: Unable to find hardware address.\n");
+       dev_notice(&link->dev, "Unable to find hardware address.\n");
        goto config_failed;
     }
 
@@ -952,30 +918,28 @@ static int smc91c92_config(struct pcmcia_device *link)
     SET_NETDEV_DEV(dev, &link->dev);
 
     if (register_netdev(dev) != 0) {
-       printk(KERN_ERR "smc91c92_cs: register_netdev() failed\n");
+       dev_err(&link->dev, "register_netdev() failed\n");
        goto config_undo;
     }
 
-    printk(KERN_INFO "%s: smc91c%s rev %d: io %#3lx, irq %d, "
-          "hw_addr %pM\n",
-          dev->name, name, (rev & 0x0f), dev->base_addr, dev->irq,
-          dev->dev_addr);
+    netdev_info(dev, "smc91c%s rev %d: io %#3lx, irq %d, hw_addr %pM\n",
+               name, (rev & 0x0f), dev->base_addr, dev->irq, dev->dev_addr);
 
     if (rev > 0) {
        if (mir & 0x3ff)
-           printk(KERN_INFO "  %lu byte", mir);
+           netdev_info(dev, "  %lu byte", mir);
        else
-           printk(KERN_INFO "  %lu kb", mir>>10);
-       printk(" buffer, %s xcvr\n", (smc->cfg & CFG_MII_SELECT) ?
-              "MII" : if_names[dev->if_port]);
+           netdev_info(dev, "  %lu kb", mir>>10);
+       pr_cont(" buffer, %s xcvr\n",
+               (smc->cfg & CFG_MII_SELECT) ? "MII" : if_names[dev->if_port]);
     }
 
     if (smc->cfg & CFG_MII_SELECT) {
        if (smc->mii_if.phy_id != -1) {
-           dev_dbg(&link->dev, "  MII transceiver at index %d, status %x.\n",
-                 smc->mii_if.phy_id, j);
+           netdev_dbg(dev, "  MII transceiver at index %d, status %x\n",
+                      smc->mii_if.phy_id, j);
        } else {
-           printk(KERN_NOTICE "  No MII transceivers found!\n");
+           netdev_notice(dev, "  No MII transceivers found!\n");
        }
     }
     return 0;
@@ -988,18 +952,10 @@ config_failed:
     return -ENODEV;
 } /* smc91c92_config */
 
-/*======================================================================
-
-    After a card is removed, smc91c92_release() will unregister the net
-    device, and release the PCMCIA configuration.  If the device is
-    still open, this will be postponed until it is closed.
-
-======================================================================*/
-
 static void smc91c92_release(struct pcmcia_device *link)
 {
        dev_dbg(&link->dev, "smc91c92_release\n");
-       if (link->win) {
+       if (link->resource[2]->end) {
                struct net_device *dev = link->priv;
                struct smc_private *smc = netdev_priv(dev);
                iounmap(smc->base);
@@ -1081,10 +1037,10 @@ static void smc_dump(struct net_device *dev)
     save = inw(ioaddr + BANK_SELECT);
     for (w = 0; w < 4; w++) {
        SMC_SELECT_BANK(w);
-       printk(KERN_DEBUG "bank %d: ", w);
+       netdev_printk(KERN_DEBUG, dev, "bank %d: ", w);
        for (i = 0; i < 14; i += 2)
-           printk(" %04x", inw(ioaddr + i));
-       printk("\n");
+           pr_cont(" %04x", inw(ioaddr + i));
+       pr_cont("\n");
     }
     outw(save, ioaddr + BANK_SELECT);
 }
@@ -1106,7 +1062,7 @@ static int smc_open(struct net_device *dev)
        return -ENODEV;
     /* Physical device present signature. */
     if (check_sig(link) < 0) {
-       printk("smc91c92_cs: Yikes!  Bad chip signature!\n");
+       netdev_info(dev, "Yikes!  Bad chip signature!\n");
        return -ENODEV;
     }
     link->open++;
@@ -1117,7 +1073,7 @@ static int smc_open(struct net_device *dev)
 
     smc_reset(dev);
     init_timer(&smc->media);
-    smc->media.function = &media_check;
+    smc->media.function = media_check;
     smc->media.data = (u_long) dev;
     smc->media.expires = jiffies + HZ;
     add_timer(&smc->media);
@@ -1172,7 +1128,7 @@ static void smc_hardware_send_packet(struct net_device * dev)
     u_char packet_no;
 
     if (!skb) {
-       printk(KERN_ERR "%s: In XMIT with no packet to send.\n", dev->name);
+       netdev_err(dev, "In XMIT with no packet to send\n");
        return;
     }
 
@@ -1180,8 +1136,8 @@ static void smc_hardware_send_packet(struct net_device * dev)
     packet_no = inw(ioaddr + PNR_ARR) >> 8;
     if (packet_no & 0x80) {
        /* If not, there is a hardware problem!  Likely an ejected card. */
-       printk(KERN_WARNING "%s: 91c92 hardware Tx buffer allocation"
-              " failed, status %#2.2x.\n", dev->name, packet_no);
+       netdev_warn(dev, "hardware Tx buffer allocation failed, status %#2.2x\n",
+                   packet_no);
        dev_kfree_skb_irq(skb);
        smc->saved_skb = NULL;
        netif_start_queue(dev);
@@ -1200,8 +1156,7 @@ static void smc_hardware_send_packet(struct net_device * dev)
        u_char *buf = skb->data;
        u_int length = skb->len; /* The chip will pad to ethernet min. */
 
-       pr_debug("%s: Trying to xmit packet of length %d.\n",
-             dev->name, length);
+       netdev_dbg(dev, "Trying to xmit packet of length %d\n", length);
        
        /* send the packet length: +6 for status word, length, and ctl */
        outw(0, ioaddr + DATA_1);
@@ -1233,9 +1188,8 @@ static void smc_tx_timeout(struct net_device *dev)
     struct smc_private *smc = netdev_priv(dev);
     unsigned int ioaddr = dev->base_addr;
 
-    printk(KERN_NOTICE "%s: SMC91c92 transmit timed out, "
-          "Tx_status %2.2x status %4.4x.\n",
-          dev->name, inw(ioaddr)&0xff, inw(ioaddr + 2));
+    netdev_notice(dev, "transmit timed out, Tx_status %2.2x status %4.4x.\n",
+                 inw(ioaddr)&0xff, inw(ioaddr + 2));
     dev->stats.tx_errors++;
     smc_reset(dev);
     dev->trans_start = jiffies; /* prevent tx timeout */
@@ -1254,14 +1208,14 @@ static netdev_tx_t smc_start_xmit(struct sk_buff *skb,
 
     netif_stop_queue(dev);
 
-    pr_debug("%s: smc_start_xmit(length = %d) called,"
-         " status %4.4x.\n", dev->name, skb->len, inw(ioaddr + 2));
+    netdev_dbg(dev, "smc_start_xmit(length = %d) called, status %04x\n",
+              skb->len, inw(ioaddr + 2));
 
     if (smc->saved_skb) {
        /* THIS SHOULD NEVER HAPPEN. */
        dev->stats.tx_aborted_errors++;
-       printk(KERN_DEBUG "%s: Internal error -- sent packet while busy.\n",
-              dev->name);
+       netdev_printk(KERN_DEBUG, dev,
+                     "Internal error -- sent packet while busy\n");
        return NETDEV_TX_BUSY;
     }
     smc->saved_skb = skb;
@@ -1269,7 +1223,7 @@ static netdev_tx_t smc_start_xmit(struct sk_buff *skb,
     num_pages = skb->len >> 8;
 
     if (num_pages > 7) {
-       printk(KERN_ERR "%s: Far too big packet error.\n", dev->name);
+       netdev_err(dev, "Far too big packet error: %d pages\n", num_pages);
        dev_kfree_skb (skb);
        smc->saved_skb = NULL;
        dev->stats.tx_dropped++;
@@ -1339,8 +1293,7 @@ static void smc_tx_err(struct net_device * dev)
     }
 
     if (tx_status & TS_SUCCESS) {
-       printk(KERN_NOTICE "%s: Successful packet caused error "
-              "interrupt?\n", dev->name);
+       netdev_notice(dev, "Successful packet caused error interrupt?\n");
     }
     /* re-enable transmit */
     SMC_SELECT_BANK(0);
@@ -1530,8 +1483,7 @@ static void smc_rx(struct net_device *dev)
     /* Assertion: we are in Window 2. */
 
     if (inw(ioaddr + FIFO_PORTS) & FP_RXEMPTY) {
-       printk(KERN_ERR "%s: smc_rx() with nothing on Rx FIFO.\n",
-              dev->name);
+       netdev_err(dev, "smc_rx() with nothing on Rx FIFO\n");
        return;
     }
 
@@ -1646,8 +1598,7 @@ static int s9k_config(struct net_device *dev, struct ifmap *map)
        else if (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]);
        smc_reset(dev);
     }
     return 0;
@@ -1798,7 +1749,7 @@ static void media_check(u_long arg)
        this, we can limp along even if the interrupt is blocked */
     if (smc->watchdog++ && ((i>>8) & i)) {
        if (!smc->fast_poll)
-           printk(KERN_INFO "%s: interrupt(s) dropped!\n", dev->name);
+           netdev_info(dev, "interrupt(s) dropped!\n");
        local_irq_save(flags);
        smc_interrupt(dev->irq, dev);
        local_irq_restore(flags);
@@ -1822,7 +1773,7 @@ static void media_check(u_long arg)
        SMC_SELECT_BANK(3);
        link = mdio_read(dev, smc->mii_if.phy_id, 1);
        if (!link || (link == 0xffff)) {
-           printk(KERN_INFO "%s: MII is missing!\n", dev->name);
+           netdev_info(dev, "MII is missing!\n");
            smc->mii_if.phy_id = -1;
            goto reschedule;
        }
@@ -1830,15 +1781,13 @@ static void media_check(u_long arg)
        link &= 0x0004;
        if (link != smc->link_status) {
            u_short p = mdio_read(dev, smc->mii_if.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");
            smc->duplex = (((p & 0x0100) || ((p & 0x1c0) == 0x40))
                           ? TCR_FDUPLX : 0);
            if (link) {
-               printk(KERN_INFO "%s: autonegotiation complete: "
-                      "%sbaseT-%cD selected\n", dev->name,
-                      ((p & 0x0180) ? "100" : "10"),
-                      (smc->duplex ? 'F' : 'H'));
+               netdev_info(dev, "autonegotiation complete: "
+                           "%dbaseT-%cD selected\n",
+                           (p & 0x0180) ? 100 : 10, smc->duplex ? 'F' : 'H');
            }
            SMC_SELECT_BANK(0);
            outw(inw(ioaddr + TCR) | smc->duplex, ioaddr + TCR);
@@ -1857,25 +1806,23 @@ static void media_check(u_long arg)
     if (media != smc->media_status) {
        if ((media & smc->media_status & 1) &&
            ((smc->media_status ^ media) & EPH_LINK_OK))
-           printk(KERN_INFO "%s: %s link beat\n", dev->name,
-                  (smc->media_status & EPH_LINK_OK ? "lost" : "found"));
+           netdev_info(dev, "%s link beat\n",
+                       smc->media_status & EPH_LINK_OK ? "lost" : "found");
        else if ((media & smc->media_status & 2) &&
                 ((smc->media_status ^ media) & EPH_16COL))
-           printk(KERN_INFO "%s: coax cable %s\n", dev->name,
-                  (media & EPH_16COL ? "problem" : "ok"));
+           netdev_info(dev, "coax cable %s\n",
+                       media & EPH_16COL ? "problem" : "ok");
        if (dev->if_port == 0) {
            if (media & 1) {
                if (media & EPH_LINK_OK)
-                   printk(KERN_INFO "%s: flipped to 10baseT\n",
-                          dev->name);
+                   netdev_info(dev, "flipped to 10baseT\n");
                else
                    smc_set_xcvr(dev, 2);
            } else {
                if (media & EPH_16COL)
                    smc_set_xcvr(dev, 1);
                else
-                   printk(KERN_INFO "%s: flipped to 10base2\n",
-                          dev->name);
+                   netdev_info(dev, "flipped to 10base2\n");
            }
        }
        smc->media_status = media;
@@ -2101,9 +2048,7 @@ MODULE_DEVICE_TABLE(pcmcia, smc91c92_ids);
 
 static struct pcmcia_driver smc91c92_cs_driver = {
        .owner          = THIS_MODULE,
-       .drv            = {
-               .name   = "smc91c92_cs",
-       },
+       .name           = "smc91c92_cs",
        .probe          = smc91c92_probe,
        .remove         = smc91c92_detach,
        .id_table       = smc91c92_ids,