fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / serial / serial_cs.c
index c3e6eb2..431433f 100644 (file)
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/timer.h>
-#include <linux/tty.h>
-#include <linux/serial.h>
 #include <linux/serial_core.h>
+#include <linux/delay.h>
 #include <linux/major.h>
 #include <asm/io.h>
 #include <asm/system.h>
 
-#include <pcmcia/version.h>
 #include <pcmcia/cs_types.h>
 #include <pcmcia/cs.h>
 #include <pcmcia/cistpl.h>
@@ -59,7 +57,7 @@
 
 #ifdef PCMCIA_DEBUG
 static int pc_debug = PCMCIA_DEBUG;
-MODULE_PARM(pc_debug, "i");
+module_param(pc_debug, int, 0644);
 #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
 static char *version = "serial_cs.c 1.134 2002/05/04 05:48:53 (David Hinds)";
 #else
@@ -70,18 +68,11 @@ static char *version = "serial_cs.c 1.134 2002/05/04 05:48:53 (David Hinds)";
 
 /* Parameters that can be set with 'insmod' */
 
-/* Bit map of interrupts to choose from */
-static u_int irq_mask = 0xdeb8;
-static int irq_list[4];
-static unsigned int irq_list_count;
-
 /* Enable the speaker? */
 static int do_sound = 1;
 /* Skip strict UART tests? */
 static int buggy_uart;
 
-module_param(irq_mask, uint, 0444);
-module_param_array(irq_list, int, irq_list_count, 0444);
 module_param(do_sound, int, 0444);
 module_param(buggy_uart, int, 0444);
 
@@ -89,43 +80,193 @@ module_param(buggy_uart, int, 0444);
 
 /* Table of multi-port card ID's */
 
-struct multi_id {
-       u_short manfid;
-       u_short prodid;
+struct serial_quirk {
+       unsigned int manfid;
+       unsigned int prodid;
        int multi;              /* 1 = multifunction, > 1 = # ports */
+       void (*config)(struct pcmcia_device *);
+       void (*setup)(struct pcmcia_device *, struct uart_port *);
+       void (*wakeup)(struct pcmcia_device *);
+       int (*post)(struct pcmcia_device *);
 };
 
-static struct multi_id multi_id[] = {
-       { MANFID_OMEGA,   PRODID_OMEGA_QSP_100,         4 },
-       { MANFID_QUATECH, PRODID_QUATECH_DUAL_RS232,    2 },
-       { MANFID_QUATECH, PRODID_QUATECH_DUAL_RS232_D1, 2 },
-       { MANFID_QUATECH, PRODID_QUATECH_QUAD_RS232,    4 },
-       { MANFID_SOCKET,  PRODID_SOCKET_DUAL_RS232,     2 },
-       { MANFID_INTEL,   PRODID_INTEL_DUAL_RS232,      2 },
-       { MANFID_NATINST, PRODID_NATINST_QUAD_RS232,    4 }
-};
-#define MULTI_COUNT (sizeof(multi_id)/sizeof(struct multi_id))
-
 struct serial_info {
-       dev_link_t              link;
+       struct pcmcia_device    *p_dev;
        int                     ndev;
        int                     multi;
        int                     slave;
        int                     manfid;
+       int                     prodid;
+       int                     c950ctrl;
        dev_node_t              node[4];
        int                     line[4];
+       const struct serial_quirk *quirk;
+};
+
+struct serial_cfg_mem {
+       tuple_t tuple;
+       cisparse_t parse;
+       u_char buf[256];
 };
 
-static void serial_config(dev_link_t * link);
-static int serial_event(event_t event, int priority,
-                       event_callback_args_t * args);
+/*
+ * vers_1 5.0, "Brain Boxes", "2-Port RS232 card", "r6"
+ * manfid 0x0160, 0x0104
+ * This card appears to have a 14.7456MHz clock.
+ */
+static void quirk_setup_brainboxes_0104(struct pcmcia_device *link, struct uart_port *port)
+{
+       port->uartclk = 14745600;
+}
+
+static int quirk_post_ibm(struct pcmcia_device *link)
+{
+       conf_reg_t reg = { 0, CS_READ, 0x800, 0 };
+       int last_ret, last_fn;
+
+       last_ret = pcmcia_access_configuration_register(link, &reg);
+       if (last_ret) {
+               last_fn = AccessConfigurationRegister;
+               goto cs_failed;
+       }
+       reg.Action = CS_WRITE;
+       reg.Value = reg.Value | 1;
+       last_ret = pcmcia_access_configuration_register(link, &reg);
+       if (last_ret) {
+               last_fn = AccessConfigurationRegister;
+               goto cs_failed;
+       }
+       return 0;
+
+ cs_failed:
+       cs_error(link, last_fn, last_ret);
+       return -ENODEV;
+}
+
+/*
+ * Nokia cards are not really multiport cards.  Shouldn't this
+ * be handled by setting the quirk entry .multi = 0 | 1 ?
+ */
+static void quirk_config_nokia(struct pcmcia_device *link)
+{
+       struct serial_info *info = link->priv;
 
-static dev_info_t dev_info = "serial_cs";
+       if (info->multi > 1)
+               info->multi = 1;
+}
 
-static dev_link_t *serial_attach(void);
-static void serial_detach(dev_link_t *);
+static void quirk_wakeup_oxsemi(struct pcmcia_device *link)
+{
+       struct serial_info *info = link->priv;
+
+       outb(12, info->c950ctrl + 1);
+}
+
+/* request_region? oxsemi branch does no request_region too... */
+/*
+ * This sequence is needed to properly initialize MC45 attached to OXCF950.
+ * I tried decreasing these msleep()s, but it worked properly (survived
+ * 1000 stop/start operations) with these timeouts (or bigger).
+ */
+static void quirk_wakeup_possio_gcc(struct pcmcia_device *link)
+{
+       struct serial_info *info = link->priv;
+       unsigned int ctrl = info->c950ctrl;
+
+       outb(0xA, ctrl + 1);
+       msleep(100);
+       outb(0xE, ctrl + 1);
+       msleep(300);
+       outb(0xC, ctrl + 1);
+       msleep(100);
+       outb(0xE, ctrl + 1);
+       msleep(200);
+       outb(0xF, ctrl + 1);
+       msleep(100);
+       outb(0xE, ctrl + 1);
+       msleep(100);
+       outb(0xC, ctrl + 1);
+}
+
+/*
+ * Socket Dual IO: this enables irq's for second port
+ */
+static void quirk_config_socket(struct pcmcia_device *link)
+{
+       struct serial_info *info = link->priv;
+
+       if (info->multi) {
+               link->conf.Present |= PRESENT_EXT_STATUS;
+               link->conf.ExtStatus = ESR_REQ_ATTN_ENA;
+       }
+}
+
+static const struct serial_quirk quirks[] = {
+       {
+               .manfid = 0x0160,
+               .prodid = 0x0104,
+               .multi  = -1,
+               .setup  = quirk_setup_brainboxes_0104,
+       }, {
+               .manfid = MANFID_IBM,
+               .prodid = ~0,
+               .multi  = -1,
+               .post   = quirk_post_ibm,
+       }, {
+               .manfid = MANFID_INTEL,
+               .prodid = PRODID_INTEL_DUAL_RS232,
+               .multi  = 2,
+       }, {
+               .manfid = MANFID_NATINST,
+               .prodid = PRODID_NATINST_QUAD_RS232,
+               .multi  = 4,
+       }, {
+               .manfid = MANFID_NOKIA,
+               .prodid = ~0,
+               .multi  = -1,
+               .config = quirk_config_nokia,
+       }, {
+               .manfid = MANFID_OMEGA,
+               .prodid = PRODID_OMEGA_QSP_100,
+               .multi  = 4,
+       }, {
+               .manfid = MANFID_OXSEMI,
+               .prodid = ~0,
+               .multi  = -1,
+               .wakeup = quirk_wakeup_oxsemi,
+       }, {
+               .manfid = MANFID_POSSIO,
+               .prodid = PRODID_POSSIO_GCC,
+               .multi  = -1,
+               .wakeup = quirk_wakeup_possio_gcc,
+       }, {
+               .manfid = MANFID_QUATECH,
+               .prodid = PRODID_QUATECH_DUAL_RS232,
+               .multi  = 2,
+       }, {
+               .manfid = MANFID_QUATECH,
+               .prodid = PRODID_QUATECH_DUAL_RS232_D1,
+               .multi  = 2,
+       }, {
+               .manfid = MANFID_QUATECH,
+               .prodid = PRODID_QUATECH_QUAD_RS232,
+               .multi  = 4,
+       }, {
+               .manfid = MANFID_SOCKET,
+               .prodid = PRODID_SOCKET_DUAL_RS232,
+               .multi  = 2,
+               .config = quirk_config_socket,
+       }, {
+               .manfid = MANFID_SOCKET,
+               .prodid = ~0,
+               .multi  = -1,
+               .config = quirk_config_socket,
+       }
+};
+
+
+static int serial_config(struct pcmcia_device * link);
 
-static dev_link_t *dev_list = NULL;
 
 /*======================================================================
 
@@ -134,64 +275,48 @@ static dev_link_t *dev_list = NULL;
     
 ======================================================================*/
 
-static void serial_remove(dev_link_t *link)
+static void serial_remove(struct pcmcia_device *link)
 {
        struct serial_info *info = link->priv;
        int i;
 
-       link->state &= ~DEV_PRESENT;
-
        DEBUG(0, "serial_release(0x%p)\n", link);
 
        /*
         * Recheck to see if the device is still configured.
         */
-       if (info->link.state & DEV_CONFIG) {
-               for (i = 0; i < info->ndev; i++)
-                       unregister_serial(info->line[i]);
+       for (i = 0; i < info->ndev; i++)
+               serial8250_unregister_port(info->line[i]);
 
-               info->link.dev = NULL;
+       info->p_dev->dev_node = NULL;
 
-               if (!info->slave) {
-                       pcmcia_release_configuration(info->link.handle);
-                       pcmcia_release_io(info->link.handle, &info->link.io);
-                       pcmcia_release_irq(info->link.handle, &info->link.irq);
-               }
-
-               info->link.state &= ~DEV_CONFIG;
-       }
+       if (!info->slave)
+               pcmcia_disable_device(link);
 }
 
-static void serial_suspend(dev_link_t *link)
+static int serial_suspend(struct pcmcia_device *link)
 {
-       link->state |= DEV_SUSPEND;
-
-       if (link->state & DEV_CONFIG) {
-               struct serial_info *info = link->priv;
-               int i;
+       struct serial_info *info = link->priv;
+       int i;
 
-               for (i = 0; i < info->ndev; i++)
-                       serial8250_suspend_port(info->line[i]);
+       for (i = 0; i < info->ndev; i++)
+               serial8250_suspend_port(info->line[i]);
 
-               if (!info->slave)
-                       pcmcia_release_configuration(link->handle);
-       }
+       return 0;
 }
 
-static void serial_resume(dev_link_t *link)
+static int serial_resume(struct pcmcia_device *link)
 {
-       link->state &= ~DEV_SUSPEND;
+       struct serial_info *info = link->priv;
+       int i;
 
-       if (DEV_OK(link)) {
-               struct serial_info *info = link->priv;
-               int i;
+       for (i = 0; i < info->ndev; i++)
+               serial8250_resume_port(info->line[i]);
 
-               if (!info->slave)
-                       pcmcia_request_configuration(link->handle, &link->conf);
+       if (info->quirk && info->quirk->wakeup)
+               info->quirk->wakeup(link);
 
-               for (i = 0; i < info->ndev; i++)
-                       serial8250_resume_port(info->line[i]);
-       }
+       return 0;
 }
 
 /*======================================================================
@@ -202,32 +327,24 @@ static void serial_resume(dev_link_t *link)
 
 ======================================================================*/
 
-static dev_link_t *serial_attach(void)
+static int serial_probe(struct pcmcia_device *link)
 {
        struct serial_info *info;
-       client_reg_t client_reg;
-       dev_link_t *link;
-       int i, ret;
 
        DEBUG(0, "serial_attach()\n");
 
        /* Create new serial device */
        info = kmalloc(sizeof (*info), GFP_KERNEL);
        if (!info)
-               return NULL;
+               return -ENOMEM;
        memset(info, 0, sizeof (*info));
-       link = &info->link;
+       info->p_dev = link;
        link->priv = info;
 
        link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
        link->io.NumPorts1 = 8;
        link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
-       link->irq.IRQInfo1 = IRQ_INFO2_VALID | IRQ_LEVEL_ID;
-       if (irq_list_count == 0)
-               link->irq.IRQInfo2 = irq_mask;
-       else
-               for (i = 0; i < irq_list_count; i++)
-                       link->irq.IRQInfo2 |= 1 << irq_list[i];
+       link->irq.IRQInfo1 = IRQ_LEVEL_ID;
        link->conf.Attributes = CONF_ENABLE_IRQ;
        if (do_sound) {
                link->conf.Attributes |= CONF_ENABLE_SPKR;
@@ -235,26 +352,7 @@ static dev_link_t *serial_attach(void)
        }
        link->conf.IntType = INT_MEMORY_AND_IO;
 
-       /* Register with Card Services */
-       link->next = dev_list;
-       dev_list = link;
-       client_reg.dev_info = &dev_info;
-       client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE;
-       client_reg.EventMask =
-           CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
-           CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
-           CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
-       client_reg.event_handler = &serial_event;
-       client_reg.Version = 0x0210;
-       client_reg.event_callback_args.client_data = link;
-       ret = pcmcia_register_client(&link->handle, &client_reg);
-       if (ret != CS_SUCCESS) {
-               cs_error(link->handle, RegisterClient, ret);
-               serial_detach(link);
-               return NULL;
-       }
-
-       return link;
+       return serial_config(link);
 }
 
 /*======================================================================
@@ -266,21 +364,12 @@ static dev_link_t *serial_attach(void)
 
 ======================================================================*/
 
-static void serial_detach(dev_link_t * link)
+static void serial_detach(struct pcmcia_device *link)
 {
        struct serial_info *info = link->priv;
-       dev_link_t **linkp;
-       int ret;
 
        DEBUG(0, "serial_detach(0x%p)\n", link);
 
-       /* Locate device structure */
-       for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
-               if (*linkp == link)
-                       break;
-       if (*linkp == NULL)
-               return;
-
        /*
         * Ensure any outstanding scheduled tasks are completed.
         */
@@ -291,34 +380,34 @@ static void serial_detach(dev_link_t * link)
         */
        serial_remove(link);
 
-       if (link->handle) {
-               ret = pcmcia_deregister_client(link->handle);
-               if (ret != CS_SUCCESS)
-                       cs_error(link->handle, DeregisterClient, ret);
-       }
-
-       /* Unlink device structure, free bits */
-       *linkp = link->next;
+       /* free bits */
        kfree(info);
 }
 
 /*====================================================================*/
 
-static int setup_serial(struct serial_info * info, ioaddr_t port, int irq)
+static int setup_serial(struct pcmcia_device *handle, struct serial_info * info,
+                       kio_addr_t iobase, int irq)
 {
-       struct serial_struct serial;
+       struct uart_port port;
        int line;
 
-       memset(&serial, 0, sizeof (serial));
-       serial.port = port;
-       serial.irq = irq;
-       serial.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ;
+       memset(&port, 0, sizeof (struct uart_port));
+       port.iobase = iobase;
+       port.irq = irq;
+       port.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_SHARE_IRQ;
+       port.uartclk = 1843200;
+       port.dev = &handle_to_dev(handle);
        if (buggy_uart)
-               serial.flags |= UPF_BUGGY_UART;
-       line = register_serial(&serial);
+               port.flags |= UPF_BUGGY_UART;
+
+       if (info->quirk && info->quirk->setup)
+               info->quirk->setup(handle, &port);
+
+       line = serial8250_register_port(&port);
        if (line < 0) {
-               printk(KERN_NOTICE "serial_cs: register_serial() at 0x%04lx,"
-                      " irq %d failed\n", (u_long) serial.port, serial.irq);
+               printk(KERN_NOTICE "serial_cs: serial8250_register_port() at "
+                      "0x%04lx, irq %d failed\n", (u_long)iobase, irq);
                return -EINVAL;
        }
 
@@ -336,7 +425,7 @@ static int setup_serial(struct serial_info * info, ioaddr_t port, int irq)
 /*====================================================================*/
 
 static int
-first_tuple(client_handle_t handle, tuple_t * tuple, cisparse_t * parse)
+first_tuple(struct pcmcia_device *handle, tuple_t * tuple, cisparse_t * parse)
 {
        int i;
        i = pcmcia_get_first_tuple(handle, tuple);
@@ -349,7 +438,7 @@ first_tuple(client_handle_t handle, tuple_t * tuple, cisparse_t * parse)
 }
 
 static int
-next_tuple(client_handle_t handle, tuple_t * tuple, cisparse_t * parse)
+next_tuple(struct pcmcia_device *handle, tuple_t * tuple, cisparse_t * parse)
 {
        int i;
        i = pcmcia_get_next_tuple(handle, tuple);
@@ -363,22 +452,33 @@ next_tuple(client_handle_t handle, tuple_t * tuple, cisparse_t * parse)
 
 /*====================================================================*/
 
-static int simple_config(dev_link_t * link)
+static int simple_config(struct pcmcia_device *link)
 {
-       static ioaddr_t base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
-       client_handle_t handle = link->handle;
+       static const kio_addr_t base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
+       static const int size_table[2] = { 8, 16 };
        struct serial_info *info = link->priv;
-       tuple_t tuple;
-       u_char buf[256];
-       cisparse_t parse;
-       cistpl_cftable_entry_t *cf = &parse.cftable_entry;
+       struct serial_cfg_mem *cfg_mem;
+       tuple_t *tuple;
+       u_char *buf;
+       cisparse_t *parse;
+       cistpl_cftable_entry_t *cf;
        config_info_t config;
        int i, j, try;
+       int s;
+
+       cfg_mem = kmalloc(sizeof(struct serial_cfg_mem), GFP_KERNEL);
+       if (!cfg_mem)
+               return -1;
+
+       tuple = &cfg_mem->tuple;
+       parse = &cfg_mem->parse;
+       cf = &parse->cftable_entry;
+       buf = cfg_mem->buf;
 
        /* If the card is already configured, look up the port and irq */
-       i = pcmcia_get_configuration_info(handle, &config);
+       i = pcmcia_get_configuration_info(link, &config);
        if ((i == CS_SUCCESS) && (config.Attributes & CONF_VALID_CLIENT)) {
-               ioaddr_t port = 0;
+               kio_addr_t port = 0;
                if ((config.BasePort2 != 0) && (config.NumPorts2 == 8)) {
                        port = config.BasePort2;
                        info->slave = 1;
@@ -387,45 +487,47 @@ static int simple_config(dev_link_t * link)
                        port = config.BasePort1 + 0x28;
                        info->slave = 1;
                }
-               if (info->slave)
-                       return setup_serial(info, port, config.AssignedIRQ);
+               if (info->slave) {
+                       kfree(cfg_mem);
+                       return setup_serial(link, info, port, config.AssignedIRQ);
+               }
        }
-       link->conf.Vcc = config.Vcc;
 
        /* First pass: look for a config entry that looks normal. */
-       tuple.TupleData = (cisdata_t *) buf;
-       tuple.TupleOffset = 0;
-       tuple.TupleDataMax = 255;
-       tuple.Attributes = 0;
-       tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
+       tuple->TupleData = (cisdata_t *) buf;
+       tuple->TupleOffset = 0;
+       tuple->TupleDataMax = 255;
+       tuple->Attributes = 0;
+       tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
        /* Two tries: without IO aliases, then with aliases */
-       for (try = 0; try < 2; try++) {
-               i = first_tuple(handle, &tuple, &parse);
-               while (i != CS_NO_MORE_ITEMS) {
-                       if (i != CS_SUCCESS)
-                               goto next_entry;
-                       if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM))
-                               link->conf.Vpp1 = link->conf.Vpp2 =
-                                   cf->vpp1.param[CISTPL_POWER_VNOM] / 10000;
-                       if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) &&
-                           (cf->io.win[0].base != 0)) {
-                               link->conf.ConfigIndex = cf->index;
-                               link->io.BasePort1 = cf->io.win[0].base;
-                               link->io.IOAddrLines = (try == 0) ?
-                                   16 : cf->io.flags & CISTPL_IO_LINES_MASK;
-                               i = pcmcia_request_io(link->handle, &link->io);
-                               if (i == CS_SUCCESS)
-                                       goto found_port;
+       for (s = 0; s < 2; s++) {
+               for (try = 0; try < 2; try++) {
+                       i = first_tuple(link, tuple, parse);
+                       while (i != CS_NO_MORE_ITEMS) {
+                               if (i != CS_SUCCESS)
+                                       goto next_entry;
+                               if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM))
+                                       link->conf.Vpp =
+                                           cf->vpp1.param[CISTPL_POWER_VNOM] / 10000;
+                               if ((cf->io.nwin > 0) && (cf->io.win[0].len == size_table[s]) &&
+                                           (cf->io.win[0].base != 0)) {
+                                       link->conf.ConfigIndex = cf->index;
+                                       link->io.BasePort1 = cf->io.win[0].base;
+                                       link->io.IOAddrLines = (try == 0) ?
+                                           16 : cf->io.flags & CISTPL_IO_LINES_MASK;
+                                       i = pcmcia_request_io(link, &link->io);
+                                       if (i == CS_SUCCESS)
+                                               goto found_port;
+                               }
+next_entry:
+                               i = next_tuple(link, tuple, parse);
                        }
-                     next_entry:
-                       i = next_tuple(handle, &tuple, &parse);
                }
        }
-
        /* Second pass: try to find an entry that isn't picky about
           its base address, then try to grab any standard serial port
           address, and finally try to get any free port. */
-       i = first_tuple(handle, &tuple, &parse);
+       i = first_tuple(link, tuple, parse);
        while (i != CS_NO_MORE_ITEMS) {
                if ((i == CS_SUCCESS) && (cf->io.nwin > 0) &&
                    ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) {
@@ -433,65 +535,74 @@ static int simple_config(dev_link_t * link)
                        for (j = 0; j < 5; j++) {
                                link->io.BasePort1 = base[j];
                                link->io.IOAddrLines = base[j] ? 16 : 3;
-                               i = pcmcia_request_io(link->handle, &link->io);
+                               i = pcmcia_request_io(link, &link->io);
                                if (i == CS_SUCCESS)
                                        goto found_port;
                        }
                }
-               i = next_tuple(handle, &tuple, &parse);
+               i = next_tuple(link, tuple, parse);
        }
 
       found_port:
        if (i != CS_SUCCESS) {
                printk(KERN_NOTICE
                       "serial_cs: no usable port range found, giving up\n");
-               cs_error(link->handle, RequestIO, i);
+               cs_error(link, RequestIO, i);
+               kfree(cfg_mem);
                return -1;
        }
 
-       i = pcmcia_request_irq(link->handle, &link->irq);
+       i = pcmcia_request_irq(link, &link->irq);
        if (i != CS_SUCCESS) {
-               cs_error(link->handle, RequestIRQ, i);
+               cs_error(link, RequestIRQ, i);
                link->irq.AssignedIRQ = 0;
        }
        if (info->multi && (info->manfid == MANFID_3COM))
                link->conf.ConfigIndex &= ~(0x08);
-       i = pcmcia_request_configuration(link->handle, &link->conf);
+
+       /*
+        * Apply any configuration quirks.
+        */
+       if (info->quirk && info->quirk->config)
+               info->quirk->config(link);
+
+       i = pcmcia_request_configuration(link, &link->conf);
        if (i != CS_SUCCESS) {
-               cs_error(link->handle, RequestConfiguration, i);
+               cs_error(link, RequestConfiguration, i);
+               kfree(cfg_mem);
                return -1;
        }
-
-       return setup_serial(info, link->io.BasePort1, link->irq.AssignedIRQ);
+       kfree(cfg_mem);
+       return setup_serial(link, info, link->io.BasePort1, link->irq.AssignedIRQ);
 }
 
-static int multi_config(dev_link_t * link)
+static int multi_config(struct pcmcia_device * link)
 {
-       client_handle_t handle = link->handle;
        struct serial_info *info = link->priv;
-       tuple_t tuple;
-       u_char buf[256];
-       cisparse_t parse;
-       cistpl_cftable_entry_t *cf = &parse.cftable_entry;
-       config_info_t config;
-       int i, base2 = 0;
-
-       i = pcmcia_get_configuration_info(handle, &config);
-       if (i != CS_SUCCESS) {
-               cs_error(handle, GetConfigurationInfo, i);
+       struct serial_cfg_mem *cfg_mem;
+       tuple_t *tuple;
+       u_char *buf;
+       cisparse_t *parse;
+       cistpl_cftable_entry_t *cf;
+       int i, rc, base2 = 0;
+
+       cfg_mem = kmalloc(sizeof(struct serial_cfg_mem), GFP_KERNEL);
+       if (!cfg_mem)
                return -1;
-       }
-       link->conf.Vcc = config.Vcc;
+       tuple = &cfg_mem->tuple;
+       parse = &cfg_mem->parse;
+       cf = &parse->cftable_entry;
+       buf = cfg_mem->buf;
 
-       tuple.TupleData = (cisdata_t *) buf;
-       tuple.TupleOffset = 0;
-       tuple.TupleDataMax = 255;
-       tuple.Attributes = 0;
-       tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
+       tuple->TupleData = (cisdata_t *) buf;
+       tuple->TupleOffset = 0;
+       tuple->TupleDataMax = 255;
+       tuple->Attributes = 0;
+       tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
 
        /* First, look for a generic full-sized window */
        link->io.NumPorts1 = info->multi * 8;
-       i = first_tuple(handle, &tuple, &parse);
+       i = first_tuple(link, tuple, parse);
        while (i != CS_NO_MORE_ITEMS) {
                /* The quad port cards have bad CIS's, so just look for a
                   window larger than 8 ports and assume it will be right */
@@ -501,19 +612,19 @@ static int multi_config(dev_link_t * link)
                        link->io.BasePort1 = cf->io.win[0].base;
                        link->io.IOAddrLines =
                            cf->io.flags & CISTPL_IO_LINES_MASK;
-                       i = pcmcia_request_io(link->handle, &link->io);
+                       i = pcmcia_request_io(link, &link->io);
                        base2 = link->io.BasePort1 + 8;
                        if (i == CS_SUCCESS)
                                break;
                }
-               i = next_tuple(handle, &tuple, &parse);
+               i = next_tuple(link, tuple, parse);
        }
 
        /* If that didn't work, look for two windows */
        if (i != CS_SUCCESS) {
                link->io.NumPorts1 = link->io.NumPorts2 = 8;
                info->multi = 2;
-               i = first_tuple(handle, &tuple, &parse);
+               i = first_tuple(link, tuple, parse);
                while (i != CS_NO_MORE_ITEMS) {
                        if ((i == CS_SUCCESS) && (cf->io.nwin == 2)) {
                                link->conf.ConfigIndex = cf->index;
@@ -521,59 +632,79 @@ static int multi_config(dev_link_t * link)
                                link->io.BasePort2 = cf->io.win[1].base;
                                link->io.IOAddrLines =
                                    cf->io.flags & CISTPL_IO_LINES_MASK;
-                               i = pcmcia_request_io(link->handle, &link->io);
+                               i = pcmcia_request_io(link, &link->io);
                                base2 = link->io.BasePort2;
                                if (i == CS_SUCCESS)
                                        break;
                        }
-                       i = next_tuple(handle, &tuple, &parse);
+                       i = next_tuple(link, tuple, parse);
                }
        }
 
        if (i != CS_SUCCESS) {
-               cs_error(link->handle, RequestIO, i);
-               return -1;
+               cs_error(link, RequestIO, i);
+               rc = -1;
+               goto free_cfg_mem;
        }
 
-       i = pcmcia_request_irq(link->handle, &link->irq);
+       i = pcmcia_request_irq(link, &link->irq);
        if (i != CS_SUCCESS) {
                printk(KERN_NOTICE
                       "serial_cs: no usable port range found, giving up\n");
-               cs_error(link->handle, RequestIRQ, i);
+               cs_error(link, RequestIRQ, i);
                link->irq.AssignedIRQ = 0;
        }
-       /* Socket Dual IO: this enables irq's for second port */
-       if (info->multi && (info->manfid == MANFID_SOCKET)) {
-               link->conf.Present |= PRESENT_EXT_STATUS;
-               link->conf.ExtStatus = ESR_REQ_ATTN_ENA;
-       }
-       i = pcmcia_request_configuration(link->handle, &link->conf);
+
+       /*
+        * Apply any configuration quirks.
+        */
+       if (info->quirk && info->quirk->config)
+               info->quirk->config(link);
+
+       i = pcmcia_request_configuration(link, &link->conf);
        if (i != CS_SUCCESS) {
-               cs_error(link->handle, RequestConfiguration, i);
-               return -1;
+               cs_error(link, RequestConfiguration, i);
+               rc = -1;
+               goto free_cfg_mem;
        }
 
        /* The Oxford Semiconductor OXCF950 cards are in fact single-port:
-          8 registers are for the UART, the others are extra registers */
-       if (info->manfid == MANFID_OXSEMI) {
+        * 8 registers are for the UART, the others are extra registers.
+        * Siemen's MC45 PCMCIA (Possio's GCC) is OXCF950 based too.
+        */
+       if (info->manfid == MANFID_OXSEMI || (info->manfid == MANFID_POSSIO &&
+                               info->prodid == PRODID_POSSIO_GCC)) {
+               int err;
+
                if (cf->index == 1 || cf->index == 3) {
-                       setup_serial(info, base2, link->irq.AssignedIRQ);
-                       outb(12, link->io.BasePort1 + 1);
+                       err = setup_serial(link, info, base2,
+                                       link->irq.AssignedIRQ);
+                       base2 = link->io.BasePort1;
                } else {
-                       setup_serial(info, link->io.BasePort1, link->irq.AssignedIRQ);
-                       outb(12, base2 + 1);
+                       err = setup_serial(link, info, link->io.BasePort1,
+                                       link->irq.AssignedIRQ);
                }
-               return 0;
+               info->c950ctrl = base2;
+
+               /*
+                * FIXME: We really should wake up the port prior to
+                * handing it over to the serial layer.
+                */
+               if (info->quirk && info->quirk->wakeup)
+                       info->quirk->wakeup(link);
+
+               rc = 0;
+               goto free_cfg_mem;
        }
 
-       setup_serial(info, link->io.BasePort1, link->irq.AssignedIRQ);
-       /* The Nokia cards are not really multiport cards */
-       if (info->manfid == MANFID_NOKIA)
-               return 0;
+       setup_serial(link, info, link->io.BasePort1, link->irq.AssignedIRQ);
        for (i = 0; i < info->multi - 1; i++)
-               setup_serial(info, base2 + (8 * i), link->irq.AssignedIRQ);
-
-       return 0;
+               setup_serial(link, info, base2 + (8 * i),
+                               link->irq.AssignedIRQ);
+       rc = 0;
+free_cfg_mem:
+       kfree(cfg_mem);
+       return rc;
 }
 
 /*======================================================================
@@ -584,61 +715,60 @@ static int multi_config(dev_link_t * link)
 
 ======================================================================*/
 
-void serial_config(dev_link_t * link)
+static int serial_config(struct pcmcia_device * link)
 {
-       client_handle_t handle = link->handle;
        struct serial_info *info = link->priv;
-       tuple_t tuple;
-       u_short buf[128];
-       cisparse_t parse;
-       cistpl_cftable_entry_t *cf = &parse.cftable_entry;
-       int i, last_ret, last_fn;
+       struct serial_cfg_mem *cfg_mem;
+       tuple_t *tuple;
+       u_char *buf;
+       cisparse_t *parse;
+       cistpl_cftable_entry_t *cf;
+       int i;
 
        DEBUG(0, "serial_config(0x%p)\n", link);
 
-       tuple.TupleData = (cisdata_t *) buf;
-       tuple.TupleOffset = 0;
-       tuple.TupleDataMax = 255;
-       tuple.Attributes = 0;
-       /* Get configuration register information */
-       tuple.DesiredTuple = CISTPL_CONFIG;
-       last_ret = first_tuple(handle, &tuple, &parse);
-       if (last_ret != CS_SUCCESS) {
-               last_fn = ParseTuple;
-               goto cs_failed;
-       }
-       link->conf.ConfigBase = parse.config.base;
-       link->conf.Present = parse.config.rmask[0];
+       cfg_mem = kmalloc(sizeof(struct serial_cfg_mem), GFP_KERNEL);
+       if (!cfg_mem)
+               goto failed;
+
+       tuple = &cfg_mem->tuple;
+       parse = &cfg_mem->parse;
+       cf = &parse->cftable_entry;
+       buf = cfg_mem->buf;
 
-       /* Configure card */
-       link->state |= DEV_CONFIG;
+       tuple->TupleData = (cisdata_t *) buf;
+       tuple->TupleOffset = 0;
+       tuple->TupleDataMax = 255;
+       tuple->Attributes = 0;
 
        /* Is this a compliant multifunction card? */
-       tuple.DesiredTuple = CISTPL_LONGLINK_MFC;
-       tuple.Attributes = TUPLE_RETURN_COMMON | TUPLE_RETURN_LINK;
-       info->multi = (first_tuple(handle, &tuple, &parse) == CS_SUCCESS);
+       tuple->DesiredTuple = CISTPL_LONGLINK_MFC;
+       tuple->Attributes = TUPLE_RETURN_COMMON | TUPLE_RETURN_LINK;
+       info->multi = (first_tuple(link, tuple, parse) == CS_SUCCESS);
 
        /* Is this a multiport card? */
-       tuple.DesiredTuple = CISTPL_MANFID;
-       if (first_tuple(handle, &tuple, &parse) == CS_SUCCESS) {
-               info->manfid = le16_to_cpu(buf[0]);
-               for (i = 0; i < MULTI_COUNT; i++)
-                       if ((info->manfid == multi_id[i].manfid) &&
-                           (le16_to_cpu(buf[1]) == multi_id[i].prodid))
-                               break;
-               if (i < MULTI_COUNT)
-                       info->multi = multi_id[i].multi;
-       }
+       tuple->DesiredTuple = CISTPL_MANFID;
+       info->manfid = link->manf_id;
+       info->prodid = link->card_id;
+
+       for (i = 0; i < ARRAY_SIZE(quirks); i++)
+               if ((quirks[i].manfid == ~0 ||
+                    quirks[i].manfid == info->manfid) &&
+                   (quirks[i].prodid == ~0 ||
+                    quirks[i].prodid == info->prodid)) {
+                       info->quirk = &quirks[i];
+                       break;
+               }
 
        /* Another check for dual-serial cards: look for either serial or
           multifunction cards that ask for appropriate IO port ranges */
-       tuple.DesiredTuple = CISTPL_FUNCID;
+       tuple->DesiredTuple = CISTPL_FUNCID;
        if ((info->multi == 0) &&
-           ((first_tuple(handle, &tuple, &parse) != CS_SUCCESS) ||
-            (parse.funcid.func == CISTPL_FUNCID_MULTI) ||
-            (parse.funcid.func == CISTPL_FUNCID_SERIAL))) {
-               tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
-               if (first_tuple(handle, &tuple, &parse) == CS_SUCCESS) {
+           (link->has_func_id) &&
+           ((link->func_id == CISTPL_FUNCID_MULTI) ||
+            (link->func_id == CISTPL_FUNCID_SERIAL))) {
+               tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
+               if (first_tuple(link, tuple, parse) == CS_SUCCESS) {
                        if ((cf->io.nwin == 1) && (cf->io.win[0].len % 8 == 0))
                                info->multi = cf->io.win[0].len >> 3;
                        if ((cf->io.nwin == 2) && (cf->io.win[0].len == 8) &&
@@ -647,6 +777,12 @@ void serial_config(dev_link_t * link)
                }
        }
 
+       /*
+        * Apply any multi-port quirk.
+        */
+       if (info->quirk && info->quirk->multi != -1)
+               info->multi = info->quirk->multi;
+
        if (info->multi > 1)
                multi_config(link);
        else
@@ -655,88 +791,169 @@ void serial_config(dev_link_t * link)
        if (info->ndev == 0)
                goto failed;
 
-       if (info->manfid == MANFID_IBM) {
-               conf_reg_t reg = { 0, CS_READ, 0x800, 0 };
-               last_ret = pcmcia_access_configuration_register(link->handle, &reg);
-               if (last_ret) {
-                       last_fn = AccessConfigurationRegister;
-                       goto cs_failed;
-               }
-               reg.Action = CS_WRITE;
-               reg.Value = reg.Value | 1;
-               last_ret = pcmcia_access_configuration_register(link->handle, &reg);
-               if (last_ret) {
-                       last_fn = AccessConfigurationRegister;
-                       goto cs_failed;
-               }
-       }
+       /*
+        * Apply any post-init quirk.  FIXME: This should really happen
+        * before we register the port, since it might already be in use.
+        */
+       if (info->quirk && info->quirk->post)
+               if (info->quirk->post(link))
+                       goto failed;
 
-       link->dev = &info->node[0];
-       link->state &= ~DEV_CONFIG_PENDING;
-       return;
+       link->dev_node = &info->node[0];
+       kfree(cfg_mem);
+       return 0;
 
- cs_failed:
-       cs_error(link->handle, last_fn, last_ret);
  failed:
        serial_remove(link);
-       link->state &= ~DEV_CONFIG_PENDING;
+       kfree(cfg_mem);
+       return -ENODEV;
 }
 
-/*======================================================================
-
-    The card status event handler.  Mostly, this schedules other
-    stuff to run after an event is received.  A CARD_REMOVAL event
-    also sets some flags to discourage the serial drivers from
-    talking to the ports.
-    
-======================================================================*/
-
-static int
-serial_event(event_t event, int priority, event_callback_args_t * args)
-{
-       dev_link_t *link = args->client_data;
-       struct serial_info *info = link->priv;
-
-       DEBUG(1, "serial_event(0x%06x)\n", event);
-
-       switch (event) {
-       case CS_EVENT_CARD_REMOVAL:
-               serial_remove(link);
-               break;
-
-       case CS_EVENT_CARD_INSERTION:
-               link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
-               serial_config(link);
-               break;
-
-       case CS_EVENT_PM_SUSPEND:
-               serial_suspend(link);
-               break;
-
-       case CS_EVENT_RESET_PHYSICAL:
-               if ((link->state & DEV_CONFIG) && !info->slave)
-                       pcmcia_release_configuration(link->handle);
-               break;
-
-       case CS_EVENT_PM_RESUME:
-               serial_resume(link);
-               break;
-
-       case CS_EVENT_CARD_RESET:
-               if (DEV_OK(link) && !info->slave)
-                       pcmcia_request_configuration(link->handle, &link->conf);
-               break;
-       }
-       return 0;
-}
+static struct pcmcia_device_id serial_ids[] = {
+       PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0057, 0x0021),
+       PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0089, 0x110a),
+       PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0104, 0x000a),
+       PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0105, 0xea15),
+       PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0109, 0x0501),
+       PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0138, 0x110a),
+       PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0140, 0x000a),
+       PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0143, 0x3341),
+       PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0143, 0xc0ab),
+       PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x016c, 0x0081),
+       PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x021b, 0x0101),
+       PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x08a1, 0xc0ab),
+       PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0105, 0x0d0a),
+       PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0105, 0x0e0a),
+       PCMCIA_PFC_DEVICE_PROD_ID123(1, "MEGAHERTZ", "CC/XJEM3288", "DATA/FAX/CELL ETHERNET MODEM", 0xf510db04, 0x04cd2988, 0x46a52d63),
+       PCMCIA_PFC_DEVICE_PROD_ID123(1, "MEGAHERTZ", "CC/XJEM3336", "DATA/FAX/CELL ETHERNET MODEM", 0xf510db04, 0x0143b773, 0x46a52d63),
+       PCMCIA_PFC_DEVICE_PROD_ID123(1, "MEGAHERTZ", "EM1144T", "PCMCIA MODEM", 0xf510db04, 0x856d66c8, 0xbd6c43ef),
+       PCMCIA_PFC_DEVICE_PROD_ID123(1, "MEGAHERTZ", "XJEM1144/CCEM1144", "PCMCIA MODEM", 0xf510db04, 0x52d21e1e, 0xbd6c43ef),
+       PCMCIA_PFC_DEVICE_PROD_ID13(1, "Xircom", "CEM28", 0x2e3ee845, 0x0ea978ea),
+       PCMCIA_PFC_DEVICE_PROD_ID13(1, "Xircom", "CEM33", 0x2e3ee845, 0x80609023),
+       PCMCIA_PFC_DEVICE_PROD_ID13(1, "Xircom", "CEM56", 0x2e3ee845, 0xa650c32a),
+       PCMCIA_PFC_DEVICE_PROD_ID13(1, "Xircom", "REM10", 0x2e3ee845, 0x76df1d29),
+       PCMCIA_PFC_DEVICE_PROD_ID13(1, "Xircom", "XEM5600", 0x2e3ee845, 0xf1403719),
+       PCMCIA_PFC_DEVICE_PROD_ID12(1, "AnyCom", "Fast Ethernet + 56K COMBO", 0x578ba6e7, 0xb0ac62c4),
+       PCMCIA_PFC_DEVICE_PROD_ID12(1, "D-Link", "DME336T", 0x1a424a1c, 0xb23897ff),
+       PCMCIA_PFC_DEVICE_PROD_ID12(1, "Gateway 2000", "XJEM3336", 0xdd9989be, 0x662c394c),
+       PCMCIA_PFC_DEVICE_PROD_ID12(1, "Grey Cell", "GCS3000", 0x2a151fac, 0x48b932ae),
+       PCMCIA_PFC_DEVICE_PROD_ID12(1, "Linksys", "EtherFast 10&100 + 56K PC Card (PCMLM56)", 0x0733cc81, 0xb3765033),
+       PCMCIA_PFC_DEVICE_PROD_ID12(1, "LINKSYS", "PCMLM336", 0xf7cb0b07, 0x7a821b58),
+       PCMCIA_PFC_DEVICE_PROD_ID12(1, "MEGAHERTZ", "XJEM1144/CCEM1144", 0xf510db04, 0x52d21e1e),
+       PCMCIA_PFC_DEVICE_PROD_ID12(1, "Ositech", "Trumpcard:Jack of Diamonds Modem+Ethernet", 0xc2f80cd, 0x656947b9),
+       PCMCIA_PFC_DEVICE_PROD_ID12(1, "Ositech", "Trumpcard:Jack of Hearts Modem+Ethernet", 0xc2f80cd, 0xdc9ba5ed),
+       PCMCIA_PFC_DEVICE_PROD_ID12(1, "PCMCIAs", "ComboCard", 0xdcfe12d3, 0xcd8906cc),
+       PCMCIA_PFC_DEVICE_PROD_ID12(1, "PCMCIAs", "LanModem", 0xdcfe12d3, 0xc67c648f),
+       PCMCIA_PFC_DEVICE_PROD_ID12(1, "TDK", "GlobalNetworker 3410/3412", 0x1eae9475, 0xd9a93bed),
+       PCMCIA_PFC_DEVICE_PROD_ID12(1, "Xircom", "CreditCard Ethernet+Modem II", 0x2e3ee845, 0xeca401bf),
+       PCMCIA_MFC_DEVICE_MANF_CARD(0, 0x0104, 0x0070),
+       PCMCIA_MFC_DEVICE_MANF_CARD(1, 0x0101, 0x0562),
+       PCMCIA_MFC_DEVICE_MANF_CARD(1, 0x0104, 0x0070),
+       PCMCIA_MFC_DEVICE_MANF_CARD(1, 0x016c, 0x0020),
+       PCMCIA_MFC_DEVICE_PROD_ID123(1, "APEX DATA", "MULTICARD", "ETHERNET-MODEM", 0x11c2da09, 0x7289dc5d, 0xaad95e1f),
+       PCMCIA_MFC_DEVICE_PROD_ID12(1, "IBM", "Home and Away 28.8 PC Card       ", 0xb569a6e5, 0x5bd4ff2c),
+       PCMCIA_MFC_DEVICE_PROD_ID12(1, "IBM", "Home and Away Credit Card Adapter", 0xb569a6e5, 0x4bdf15c3),
+       PCMCIA_MFC_DEVICE_PROD_ID12(1, "IBM", "w95 Home and Away Credit Card ", 0xb569a6e5, 0xae911c15),
+       PCMCIA_MFC_DEVICE_PROD_ID1(1, "Motorola MARQUIS", 0xf03e4e77),
+       PCMCIA_MFC_DEVICE_PROD_ID2(1, "FAX/Modem/Ethernet Combo Card ", 0x1ed59302),
+       PCMCIA_DEVICE_MANF_CARD(0x0089, 0x0301),
+       PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x0276),
+       PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0039),
+       PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0006),
+       PCMCIA_DEVICE_MANF_CARD(0x0105, 0x410a),
+       PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0d50),
+       PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0d51),
+       PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0d52),
+       PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0d53),
+       PCMCIA_DEVICE_MANF_CARD(0x010b, 0xd180),
+       PCMCIA_DEVICE_MANF_CARD(0x0137, 0x000e),
+       PCMCIA_DEVICE_MANF_CARD(0x0137, 0x001b),
+       PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0025),
+       PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0045),
+       PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0052),
+       PCMCIA_DEVICE_PROD_ID134("ADV", "TECH", "COMpad-32/85", 0x67459937, 0x916d02ba, 0x8fbe92ae),
+       PCMCIA_DEVICE_PROD_ID124("GATEWAY2000", "CC3144", "PCMCIA MODEM", 0x506bccae, 0xcb3685f1, 0xbd6c43ef),
+       PCMCIA_DEVICE_PROD_ID14("MEGAHERTZ", "PCMCIA MODEM", 0xf510db04, 0xbd6c43ef),
+       PCMCIA_DEVICE_PROD_ID124("TOSHIBA", "T144PF", "PCMCIA MODEM", 0xb4585a1a, 0x7271409c, 0xbd6c43ef),
+       PCMCIA_DEVICE_PROD_ID123("FUJITSU", "FC14F ", "MBH10213", 0x6ee5a3d8, 0x30ead12b, 0xb00f05a0),
+       PCMCIA_DEVICE_PROD_ID123("Novatel Wireless", "Merlin UMTS Modem", "U630", 0x32607776, 0xd9e73b13, 0xe87332e),
+       PCMCIA_DEVICE_PROD_ID13("MEGAHERTZ", "V.34 PCMCIA MODEM", 0xf510db04, 0xbb2cce4a),
+       PCMCIA_DEVICE_PROD_ID12("Brain Boxes", "Bluetooth PC Card", 0xee138382, 0xd4ce9b02),
+       PCMCIA_DEVICE_PROD_ID12("CIRRUS LOGIC", "FAX MODEM", 0xe625f451, 0xcecd6dfa),
+       PCMCIA_DEVICE_PROD_ID12("COMPAQ", "PCMCIA 28800 FAX/DATA MODEM", 0xa3a3062c, 0x8cbd7c76),
+       PCMCIA_DEVICE_PROD_ID12("COMPAQ", "PCMCIA 33600 FAX/DATA MODEM", 0xa3a3062c, 0x5a00ce95),
+       PCMCIA_DEVICE_PROD_ID12("Computerboards, Inc.", "PCM-COM422", 0xd0b78f51, 0x7e2d49ed),
+       PCMCIA_DEVICE_PROD_ID12("Dr. Neuhaus", "FURY CARD 14K4", 0x76942813, 0x8b96ce65),
+       PCMCIA_DEVICE_PROD_ID12("Intelligent", "ANGIA FAX/MODEM", 0xb496e65e, 0xf31602a6),
+       PCMCIA_DEVICE_PROD_ID12("Intel", "MODEM 2400+", 0x816cc815, 0x412729fb),
+       PCMCIA_DEVICE_PROD_ID12("IOTech Inc ", "PCMCIA Dual RS-232 Serial Port Card", 0x3bd2d898, 0x92abc92f),
+       PCMCIA_DEVICE_PROD_ID12("MACRONIX", "FAX/MODEM", 0x668388b3, 0x3f9bdf2f),
+       PCMCIA_DEVICE_PROD_ID12("Multi-Tech", "MT1432LT", 0x5f73be51, 0x0b3e2383),
+       PCMCIA_DEVICE_PROD_ID12("Multi-Tech", "MT2834LT", 0x5f73be51, 0x4cd7c09e),
+       PCMCIA_DEVICE_PROD_ID12("OEM      ", "C288MX     ", 0xb572d360, 0xd2385b7a),
+       PCMCIA_DEVICE_PROD_ID12("PCMCIA   ", "C336MX     ", 0x99bcafe9, 0xaa25bcab),
+       PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "PCMCIA Dual RS-232 Serial Port Card", 0xc4420b35, 0x92abc92f),
+       PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "EN2218-LAN/MODEM", 0x281f1c5d, 0x570f348e, "PCMLM28.cis"),
+       PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "UE2218-LAN/MODEM", 0x281f1c5d, 0x6fdcacee, "PCMLM28.cis"),
+       PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "PCMLM28.cis"),
+       PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "Psion Dacom", "Gold Card V34 Ethernet GSM", 0xf5f025c2, 0x4ae85d35, "PCMLM28.cis"),
+       PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "LINKSYS", "PCMLM28", 0xf7cb0b07, 0x66881874, "PCMLM28.cis"),
+       PCMCIA_MFC_DEVICE_CIS_PROD_ID12(1, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "DP83903.cis"),
+       PCMCIA_MFC_DEVICE_CIS_PROD_ID4(1, "NSC MF LAN/Modem", 0x58fc6056, "DP83903.cis"),
+       PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x0556, "3CCFEM556.cis"),
+       PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0175, 0x0000, "DP83903.cis"),
+       PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x0035, "3CXEM556.cis"),
+       PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x003d, "3CXEM556.cis"),
+       PCMCIA_DEVICE_CIS_MANF_CARD(0x0192, 0x0710, "SW_7xx_SER.cis"),  /* Sierra Wireless AC710/AC750 GPRS Network Adapter R1 */
+       PCMCIA_DEVICE_CIS_MANF_CARD(0x0192, 0xa555, "SW_555_SER.cis"),  /* Sierra Aircard 555 CDMA 1xrtt Modem -- pre update */
+       PCMCIA_DEVICE_CIS_MANF_CARD(0x013f, 0xa555, "SW_555_SER.cis"),  /* Sierra Aircard 555 CDMA 1xrtt Modem -- post update */
+       PCMCIA_DEVICE_CIS_PROD_ID12("MultiTech", "PCMCIA 56K DataFax", 0x842047ee, 0xc2efcf03, "MT5634ZLX.cis"),
+       PCMCIA_DEVICE_CIS_PROD_ID12("ADVANTECH", "COMpad-32/85B-4", 0x96913a85, 0xcec8f102, "COMpad4.cis"),
+       PCMCIA_DEVICE_CIS_PROD_ID123("ADVANTECH", "COMpad-32/85", "1.0", 0x96913a85, 0x8fbe92ae, 0x0877b627, "COMpad2.cis"),
+       PCMCIA_DEVICE_CIS_PROD_ID2("RS-COM 2P", 0xad20b156, "RS-COM-2P.cis"),
+       PCMCIA_DEVICE_CIS_MANF_CARD(0x0013, 0x0000, "GLOBETROTTER.cis"),
+       PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.","SERIAL CARD: SL100  1.00.",0x19ca78af,0xf964f42b),
+       PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.","SERIAL CARD: SL100",0x19ca78af,0x71d98e83),
+       PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.","SERIAL CARD: SL232  1.00.",0x19ca78af,0x69fb7490),
+       PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.","SERIAL CARD: SL232",0x19ca78af,0xb6bc0235),
+       PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c2000.","SERIAL CARD: CF232",0x63f2e0bd,0xb9e175d3),
+       PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c2000.","SERIAL CARD: CF232-5",0x63f2e0bd,0xfce33442),
+       PCMCIA_DEVICE_PROD_ID12("Elan","Serial Port: CF232",0x3beb8cf2,0x171e7190),
+       PCMCIA_DEVICE_PROD_ID12("Elan","Serial Port: CF232-5",0x3beb8cf2,0x20da4262),
+       PCMCIA_DEVICE_PROD_ID12("Elan","Serial Port: CF428",0x3beb8cf2,0xea5dd57d),
+       PCMCIA_DEVICE_PROD_ID12("Elan","Serial Port: CF500",0x3beb8cf2,0xd77255fa),
+       PCMCIA_DEVICE_PROD_ID12("Elan","Serial Port: IC232",0x3beb8cf2,0x6a709903),
+       PCMCIA_DEVICE_PROD_ID12("Elan","Serial Port: SL232",0x3beb8cf2,0x18430676),
+       PCMCIA_DEVICE_PROD_ID12("Elan","Serial Port: XL232",0x3beb8cf2,0x6f933767),
+       PCMCIA_MFC_DEVICE_PROD_ID12(0,"Elan","Serial Port: CF332",0x3beb8cf2,0x16dc1ba7),
+       PCMCIA_MFC_DEVICE_PROD_ID12(0,"Elan","Serial Port: SL332",0x3beb8cf2,0x19816c41),
+       PCMCIA_MFC_DEVICE_PROD_ID12(0,"Elan","Serial Port: SL385",0x3beb8cf2,0x64112029),
+       PCMCIA_MFC_DEVICE_PROD_ID12(0,"Elan","Serial Port: SL432",0x3beb8cf2,0x1cce7ac4),
+       PCMCIA_MFC_DEVICE_PROD_ID12(0,"Elan","Serial+Parallel Port: SP230",0x3beb8cf2,0xdb9e58bc),
+       PCMCIA_MFC_DEVICE_PROD_ID12(1,"Elan","Serial Port: CF332",0x3beb8cf2,0x16dc1ba7),
+       PCMCIA_MFC_DEVICE_PROD_ID12(1,"Elan","Serial Port: SL332",0x3beb8cf2,0x19816c41),
+       PCMCIA_MFC_DEVICE_PROD_ID12(1,"Elan","Serial Port: SL385",0x3beb8cf2,0x64112029),
+       PCMCIA_MFC_DEVICE_PROD_ID12(1,"Elan","Serial Port: SL432",0x3beb8cf2,0x1cce7ac4),
+       PCMCIA_MFC_DEVICE_PROD_ID12(2,"Elan","Serial Port: SL432",0x3beb8cf2,0x1cce7ac4),
+       PCMCIA_MFC_DEVICE_PROD_ID12(3,"Elan","Serial Port: SL432",0x3beb8cf2,0x1cce7ac4),
+       /* too generic */
+       /* PCMCIA_MFC_DEVICE_MANF_CARD(0, 0x0160, 0x0002), */
+       /* PCMCIA_MFC_DEVICE_MANF_CARD(1, 0x0160, 0x0002), */
+       PCMCIA_DEVICE_FUNC_ID(2),
+       PCMCIA_DEVICE_NULL,
+};
+MODULE_DEVICE_TABLE(pcmcia, serial_ids);
 
 static struct pcmcia_driver serial_cs_driver = {
        .owner          = THIS_MODULE,
        .drv            = {
                .name   = "serial_cs",
        },
-       .attach         = serial_attach,
-       .detach         = serial_detach,
+       .probe          = serial_probe,
+       .remove         = serial_detach,
+       .id_table       = serial_ids,
+       .suspend        = serial_suspend,
+       .resume         = serial_resume,
 };
 
 static int __init init_serial_cs(void)
@@ -747,10 +964,6 @@ static int __init init_serial_cs(void)
 static void __exit exit_serial_cs(void)
 {
        pcmcia_unregister_driver(&serial_cs_driver);
-
-       /* XXX: this really needs to move into generic code.. */
-       while (dev_list != NULL)
-               serial_detach(dev_list);
 }
 
 module_init(init_serial_cs);