pata_cs5520: remove dead VDMA support
[safe/jmp/linux-2.6] / drivers / ata / pata_ninja32.c
index 1c1b835..dd53a66 100644 (file)
@@ -1,7 +1,6 @@
 /*
  * pata_ninja32.c      - Ninja32 PATA for new ATA layer
  *                       (C) 2007 Red Hat Inc
- *                       Alan Cox <alan@redhat.com>
  *
  * Note: The controller like many controllers has shared timings for
  * PIO and DMA. We thus flip to the DMA timings in dma_start and flip back
@@ -17,6 +16,7 @@
  *     Base + 0x00 IRQ Status
  *     Base + 0x01 IRQ control
  *     Base + 0x02 Chipset control
+ *     Base + 0x03 Unknown
  *     Base + 0x04 VDMA and reset control + wait bits
  *     Base + 0x08 BMIMBA
  *     Base + 0x0C DMA Length
@@ -44,7 +44,7 @@
 #include <linux/libata.h>
 
 #define DRV_NAME "pata_ninja32"
-#define DRV_VERSION "0.0.1"
+#define DRV_VERSION "0.1.5"
 
 
 /**
@@ -72,62 +72,34 @@ static void ninja32_dev_select(struct ata_port *ap, unsigned int device)
        struct ata_device *adev = &ap->link.device[device];
        if (ap->private_data != adev) {
                iowrite8(0xd6, ap->ioaddr.bmdma_addr + 0x1f);
-               ata_std_dev_select(ap, device);
+               ata_sff_dev_select(ap, device);
                ninja32_set_piomode(ap, adev);
        }
 }
 
 static struct scsi_host_template ninja32_sht = {
-       .module                 = THIS_MODULE,
-       .name                   = DRV_NAME,
-       .ioctl                  = ata_scsi_ioctl,
-       .queuecommand           = ata_scsi_queuecmd,
-       .can_queue              = ATA_DEF_QUEUE,
-       .this_id                = ATA_SHT_THIS_ID,
-       .sg_tablesize           = LIBATA_MAX_PRD,
-       .cmd_per_lun            = ATA_SHT_CMD_PER_LUN,
-       .emulated               = ATA_SHT_EMULATED,
-       .use_clustering         = ATA_SHT_USE_CLUSTERING,
-       .proc_name              = DRV_NAME,
-       .dma_boundary           = ATA_DMA_BOUNDARY,
-       .slave_configure        = ata_scsi_slave_config,
-       .slave_destroy          = ata_scsi_slave_destroy,
-       .bios_param             = ata_std_bios_param,
+       ATA_BMDMA_SHT(DRV_NAME),
 };
 
 static struct ata_port_operations ninja32_port_ops = {
-       .set_piomode    = ninja32_set_piomode,
-       .mode_filter    = ata_pci_default_filter,
-
-       .tf_load        = ata_tf_load,
-       .tf_read        = ata_tf_read,
-       .check_status   = ata_check_status,
-       .exec_command   = ata_exec_command,
-       .dev_select     = ninja32_dev_select,
-
-       .freeze         = ata_bmdma_freeze,
-       .thaw           = ata_bmdma_thaw,
-       .error_handler  = ata_bmdma_error_handler,
-       .post_internal_cmd = ata_bmdma_post_internal_cmd,
+       .inherits       = &ata_bmdma_port_ops,
+       .sff_dev_select = ninja32_dev_select,
        .cable_detect   = ata_cable_40wire,
-
-       .bmdma_setup    = ata_bmdma_setup,
-       .bmdma_start    = ata_bmdma_start,
-       .bmdma_stop     = ata_bmdma_stop,
-       .bmdma_status   = ata_bmdma_status,
-
-       .qc_prep        = ata_qc_prep,
-       .qc_issue       = ata_qc_issue_prot,
-
-       .data_xfer      = ata_data_xfer,
-
-       .irq_handler    = ata_interrupt,
-       .irq_clear      = ata_bmdma_irq_clear,
-       .irq_on         = ata_irq_on,
-
-       .port_start     = ata_sff_port_start,
+       .set_piomode    = ninja32_set_piomode,
+       .sff_data_xfer  = ata_sff_data_xfer32
 };
 
+static void ninja32_program(void __iomem *base)
+{
+       iowrite8(0x05, base + 0x01);    /* Enable interrupt lines */
+       iowrite8(0xBE, base + 0x02);    /* Burst, ?? setup */
+       iowrite8(0x01, base + 0x03);    /* Unknown */
+       iowrite8(0x20, base + 0x04);    /* WAIT0 */
+       iowrite8(0x8f, base + 0x05);    /* Unknown */
+       iowrite8(0xa4, base + 0x1c);    /* Unknown */
+       iowrite8(0x83, base + 0x1d);    /* BMDMA control: WAIT0 */
+}
+
 static int ninja32_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
        struct ata_host *host;
@@ -159,31 +131,51 @@ static int ninja32_init_one(struct pci_dev *dev, const struct pci_device_id *id)
                return rc;
        pci_set_master(dev);
 
-       /* Set up the register mappings */
+       /* Set up the register mappings. We use the I/O mapping as only the
+          older chips also have MMIO on BAR 1 */
        base = host->iomap[0];
        if (!base)
                return -ENOMEM;
        ap->ops = &ninja32_port_ops;
-       ap->pio_mask = 0x1F;
+       ap->pio_mask = ATA_PIO4;
        ap->flags |= ATA_FLAG_SLAVE_POSS;
 
        ap->ioaddr.cmd_addr = base + 0x10;
        ap->ioaddr.ctl_addr = base + 0x1E;
        ap->ioaddr.altstatus_addr = base + 0x1E;
        ap->ioaddr.bmdma_addr = base;
-       ata_std_ports(&ap->ioaddr);
+       ata_sff_std_ports(&ap->ioaddr);
+       ap->pflags = ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE;
 
-       iowrite8(0x05, base + 0x01);    /* Enable interrupt lines */
-       iowrite8(0xB3, base + 0x02);    /* Burst, ?? setup */
-       iowrite8(0x00, base + 0x04);    /* WAIT0 ? */
+       ninja32_program(base);
        /* FIXME: Should we disable them at remove ? */
-       return ata_host_activate(host, dev->irq, ata_interrupt,
+       return ata_host_activate(host, dev->irq, ata_sff_interrupt,
                                 IRQF_SHARED, &ninja32_sht);
 }
 
+#ifdef CONFIG_PM
+
+static int ninja32_reinit_one(struct pci_dev *pdev)
+{
+       struct ata_host *host = dev_get_drvdata(&pdev->dev);
+       int rc;
+
+       rc = ata_pci_device_do_resume(pdev);
+       if (rc)
+               return rc;
+       ninja32_program(host->iomap[0]);
+       ata_host_resume(host);
+       return 0;                       
+}
+#endif
+
 static const struct pci_device_id ninja32[] = {
+       { 0x10FC, 0x0003, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+       { 0x1145, 0x8008, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+       { 0x1145, 0xf008, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
        { 0x1145, 0xf021, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
        { 0x1145, 0xf024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+       { 0x1145, 0xf02C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
        { },
 };
 
@@ -191,7 +183,11 @@ static struct pci_driver ninja32_pci_driver = {
        .name           = DRV_NAME,
        .id_table       = ninja32,
        .probe          = ninja32_init_one,
-       .remove         = ata_pci_remove_one
+       .remove         = ata_pci_remove_one,
+#ifdef CONFIG_PM
+       .suspend        = ata_pci_device_suspend,
+       .resume         = ninja32_reinit_one,
+#endif
 };
 
 static int __init ninja32_init(void)