linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / scsi / pcmcia / sym53c500_cs.c
index 84d0634..3a4dd6f 100644 (file)
@@ -92,19 +92,6 @@ static char *version =
 
 /* ================================================================== */
 
-/* Parameters that can be set with 'insmod' */
-
-/* Bit map of interrupts to choose from */
-static unsigned int irq_mask = 0xdeb8; /* 3-5, 7, 9-12, 14, 15 */
-static int irq_list[4] = { -1 };
-
-module_param(irq_mask, int, 0);
-MODULE_PARM_DESC(irq_mask, "IRQ mask bits (default: 0xdeb8)");
-module_param_array(irq_list, int, NULL, 0);
-MODULE_PARM_DESC(irq_list, "Comma-separated list of up to 4 IRQs to try (default: auto select).");
-
-/* ================================================================== */
-
 #define SYNC_MODE 0            /* Synchronous transfer mode */
 
 /* Default configuration */
@@ -241,15 +228,6 @@ enum Phase {
 
 /* ================================================================== */
 
-/*
-*  Global (within this module) variables other than
-*  sym53c500_driver_template (the scsi_host_template).
-*/
-static dev_link_t *dev_list;
-static dev_info_t dev_info = "sym53c500_cs";
-
-/* ================================================================== */
-
 static void
 chip_init(int io_port)
 {
@@ -623,7 +601,7 @@ SYM53C500_queue(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
 
        /* We are locked here already by the mid layer */
        REG0(port_base);
-       outb(SCpnt->device->id, port_base + DEST_ID);   /* set destination */
+       outb(scmd_id(SCpnt), port_base + DEST_ID);      /* set destination */
        outb(FLUSH_FIFO, port_base + CMD_REG);  /* reset the fifos */
 
        for (i = 0; i < SCpnt->cmd_len; i++) {
@@ -640,7 +618,9 @@ SYM53C500_host_reset(struct scsi_cmnd *SCpnt)
        int port_base = SCpnt->device->host->io_port;
 
        DEB(printk("SYM53C500_host_reset called\n"));
+       spin_lock_irq(SCpnt->device->host->host_lock);
        SYM53C500_int_host_reset(port_base);
+       spin_unlock_irq(SCpnt->device->host->host_lock);
 
        return SUCCESS;
 }
@@ -883,96 +863,70 @@ cs_failed:
        return;
 } /* SYM53C500_config */
 
-static int
-SYM53C500_event(event_t event, int priority, event_callback_args_t *args)
+static int sym53c500_suspend(struct pcmcia_device *dev)
 {
-       dev_link_t *link = args->client_data;
-       struct scsi_info_t *info = link->priv;
+       dev_link_t *link = dev_to_instance(dev);
 
-       DEBUG(1, "SYM53C500_event(0x%06x)\n", event);
+       link->state |= DEV_SUSPEND;
+       if (link->state & DEV_CONFIG)
+               pcmcia_release_configuration(link->handle);
 
-       switch (event) {
-       case CS_EVENT_CARD_REMOVAL:
-               link->state &= ~DEV_PRESENT;
-               if (link->state & DEV_CONFIG)
-                       SYM53C500_release(link);
-               break;
-       case CS_EVENT_CARD_INSERTION:
-               link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
-               SYM53C500_config(link);
-               break;
-       case CS_EVENT_PM_SUSPEND:
-               link->state |= DEV_SUSPEND;
-               /* Fall through... */
-       case CS_EVENT_RESET_PHYSICAL:
-               if (link->state & DEV_CONFIG)
-                       pcmcia_release_configuration(link->handle);
-               break;
-       case CS_EVENT_PM_RESUME:
-               link->state &= ~DEV_SUSPEND;
-               /* Fall through... */
-       case CS_EVENT_CARD_RESET:
-               if (link->state & DEV_CONFIG) {
-                       pcmcia_request_configuration(link->handle, &link->conf);
-                       /* See earlier comment about manufacturer IDs. */
-                       if ((info->manf_id == MANFID_MACNICA) ||
-                           (info->manf_id == MANFID_PIONEER) ||
-                           (info->manf_id == 0x0098)) {
-                               outb(0x80, link->io.BasePort1 + 0xd);
-                               outb(0x24, link->io.BasePort1 + 0x9);
-                               outb(0x04, link->io.BasePort1 + 0xd);
-                       }
-                       /*
-                       *  If things don't work after a "resume",
-                       *  this is a good place to start looking.
-                       */
-                       SYM53C500_int_host_reset(link->io.BasePort1);
+       return 0;
+}
+
+static int sym53c500_resume(struct pcmcia_device *dev)
+{
+       dev_link_t *link = dev_to_instance(dev);
+       struct scsi_info_t *info = link->priv;
+
+       link->state &= ~DEV_SUSPEND;
+       if (link->state & DEV_CONFIG) {
+               pcmcia_request_configuration(link->handle, &link->conf);
+
+               /* See earlier comment about manufacturer IDs. */
+               if ((info->manf_id == MANFID_MACNICA) ||
+                   (info->manf_id == MANFID_PIONEER) ||
+                   (info->manf_id == 0x0098)) {
+                       outb(0x80, link->io.BasePort1 + 0xd);
+                       outb(0x24, link->io.BasePort1 + 0x9);
+                       outb(0x04, link->io.BasePort1 + 0xd);
                }
-               break;
+               /*
+                *  If things don't work after a "resume",
+                *  this is a good place to start looking.
+                */
+               SYM53C500_int_host_reset(link->io.BasePort1);
        }
+
        return 0;
-} /* SYM53C500_event */
+}
 
 static void
-SYM53C500_detach(dev_link_t *link)
+SYM53C500_detach(struct pcmcia_device *p_dev)
 {
-       dev_link_t **linkp;
+       dev_link_t *link = dev_to_instance(p_dev);
 
        DEBUG(0, "SYM53C500_detach(0x%p)\n", link);
 
-       /* Locate device structure */
-       for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
-               if (*linkp == link)
-                       break;
-       if (*linkp == NULL)
-               return;
-
        if (link->state & DEV_CONFIG)
                SYM53C500_release(link);
 
-       if (link->handle)
-               pcmcia_deregister_client(link->handle);
-
-       /* Unlink device structure, free bits. */
-       *linkp = link->next;
        kfree(link->priv);
        link->priv = NULL;
 } /* SYM53C500_detach */
 
-static dev_link_t *
-SYM53C500_attach(void)
+static int
+SYM53C500_attach(struct pcmcia_device *p_dev)
 {
        struct scsi_info_t *info;
-       client_reg_t client_reg;
        dev_link_t *link;
-       int i, ret;
 
        DEBUG(0, "SYM53C500_attach()\n");
 
        /* Create new SCSI device */
        info = kmalloc(sizeof(*info), GFP_KERNEL);
        if (!info)
-               return NULL;
+               return -ENOMEM;
        memset(info, 0, sizeof(*info));
        link = &info->link;
        link->priv = info;
@@ -980,49 +934,43 @@ SYM53C500_attach(void)
        link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
        link->io.IOAddrLines = 10;
        link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
-       link->irq.IRQInfo1 = IRQ_INFO2_VALID | IRQ_LEVEL_ID;
-       if (irq_list[0] == -1)
-               link->irq.IRQInfo2 = irq_mask;
-       else
-               for (i = 0; i < 4; i++)
-                       link->irq.IRQInfo2 |= 1 << irq_list[i];
+       link->irq.IRQInfo1 = IRQ_LEVEL_ID;
        link->conf.Attributes = CONF_ENABLE_IRQ;
        link->conf.Vcc = 50;
        link->conf.IntType = INT_MEMORY_AND_IO;
        link->conf.Present = PRESENT_OPTION;
 
-       /* 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.event_handler = &SYM53C500_event;
-       client_reg.EventMask = CS_EVENT_RESET_REQUEST | CS_EVENT_CARD_RESET |
-           CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
-           CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
-       client_reg.Version = 0x0210;
-       client_reg.event_callback_args.client_data = link;
-       ret = pcmcia_register_client(&link->handle, &client_reg);
-       if (ret != 0) {
-               cs_error(link->handle, RegisterClient, ret);
-               SYM53C500_detach(link);
-               return NULL;
-       }
+       link->handle = p_dev;
+       p_dev->instance = link;
 
-       return link;
+       link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
+       SYM53C500_config(link);
+
+       return 0;
 } /* SYM53C500_attach */
 
 MODULE_AUTHOR("Bob Tracy <rct@frus.com>");
 MODULE_DESCRIPTION("SYM53C500 PCMCIA SCSI driver");
 MODULE_LICENSE("GPL");
 
+static struct pcmcia_device_id sym53c500_ids[] = {
+       PCMCIA_DEVICE_PROD_ID12("BASICS by New Media Corporation", "SCSI Sym53C500", 0x23c78a9d, 0x0099e7f7),
+       PCMCIA_DEVICE_PROD_ID12("New Media Corporation", "SCSI Bus Toaster Sym53C500", 0x085a850b, 0x45432eb8),
+       PCMCIA_DEVICE_PROD_ID2("SCSI9000", 0x21648f44),
+       PCMCIA_DEVICE_NULL,
+};
+MODULE_DEVICE_TABLE(pcmcia, sym53c500_ids);
+
 static struct pcmcia_driver sym53c500_cs_driver = {
        .owner          = THIS_MODULE,
        .drv            = {
                .name   = "sym53c500_cs",
        },
-       .attach         = SYM53C500_attach,
-       .detach         = SYM53C500_detach,
+       .probe          = SYM53C500_attach,
+       .remove         = SYM53C500_detach,
+       .id_table       = sym53c500_ids,
+       .suspend        = sym53c500_suspend,
+       .resume         = sym53c500_resume,
 };
 
 static int __init