Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzi...
[safe/jmp/linux-2.6] / drivers / ata / pata_sil680.c
index 0936f53..d3190d7 100644 (file)
@@ -1,7 +1,6 @@
 /*
  * pata_sil680.c       - SIL680 PATA for new ATA layer
  *                       (C) 2005 Red Hat Inc
- *                       Alan Cox <alan@redhat.com>
  *
  * based upon
  *
@@ -33,7 +32,7 @@
 #include <linux/libata.h>
 
 #define DRV_NAME "pata_sil680"
-#define DRV_VERSION "0.4.8"
+#define DRV_VERSION "0.4.9"
 
 #define SIL680_MMIO_BAR                5
 
@@ -191,15 +190,37 @@ static void sil680_set_dmamode(struct ata_port *ap, struct ata_device *adev)
        pci_write_config_word(pdev, ua, ultra);
 }
 
+/**
+ *     sil680_sff_exec_command - issue ATA command to host controller
+ *     @ap: port to which command is being issued
+ *     @tf: ATA taskfile register set
+ *
+ *     Issues ATA command, with proper synchronization with interrupt
+ *     handler / other threads. Use our MMIO space for PCI posting to avoid
+ *     a hideously slow cycle all the way to the device.
+ *
+ *     LOCKING:
+ *     spin_lock_irqsave(host lock)
+ */
+void sil680_sff_exec_command(struct ata_port *ap,
+                                       const struct ata_taskfile *tf)
+{
+       DPRINTK("ata%u: cmd 0x%X\n", ap->print_id, tf->command);
+       iowrite8(tf->command, ap->ioaddr.command_addr);
+       ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
+}
+
 static struct scsi_host_template sil680_sht = {
        ATA_BMDMA_SHT(DRV_NAME),
 };
 
+
 static struct ata_port_operations sil680_port_ops = {
-       .inherits       = &ata_bmdma_port_ops,
-       .cable_detect   = sil680_cable_detect,
-       .set_piomode    = sil680_set_piomode,
-       .set_dmamode    = sil680_set_dmamode,
+       .inherits               = &ata_bmdma32_port_ops,
+       .sff_exec_command       = sil680_sff_exec_command,
+       .cable_detect           = sil680_cable_detect,
+       .set_piomode            = sil680_set_piomode,
+       .set_dmamode            = sil680_set_dmamode,
 };
 
 /**
@@ -213,13 +234,11 @@ static struct ata_port_operations sil680_port_ops = {
 
 static u8 sil680_init_chip(struct pci_dev *pdev, int *try_mmio)
 {
-       u32 class_rev   = 0;
        u8 tmpbyte      = 0;
 
-        pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class_rev);
-        class_rev &= 0xff;
         /* FIXME: double check */
-       pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, (class_rev) ? 1 : 255);
+       pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE,
+                             pdev->revision ? 1 : 255);
 
        pci_write_config_byte(pdev, 0x80, 0x00);
        pci_write_config_byte(pdev, 0x84, 0x00);
@@ -230,7 +249,7 @@ static u8 sil680_init_chip(struct pci_dev *pdev, int *try_mmio)
                tmpbyte & 1, tmpbyte & 0x30);
 
        *try_mmio = 0;
-#ifdef CONFIG_PPC_MERGE
+#ifdef CONFIG_PPC
        if (machine_is(cell))
                *try_mmio = (tmpbyte & 1) || pci_resource_start(pdev, 5);
 #endif
@@ -282,18 +301,16 @@ static int __devinit sil680_init_one(struct pci_dev *pdev,
                                     const struct pci_device_id *id)
 {
        static const struct ata_port_info info = {
-               .sht = &sil680_sht,
                .flags = ATA_FLAG_SLAVE_POSS,
-               .pio_mask = 0x1f,
-               .mwdma_mask = 0x07,
+               .pio_mask = ATA_PIO4,
+               .mwdma_mask = ATA_MWDMA2,
                .udma_mask = ATA_UDMA6,
                .port_ops = &sil680_port_ops
        };
        static const struct ata_port_info info_slow = {
-               .sht = &sil680_sht,
                .flags = ATA_FLAG_SLAVE_POSS,
-               .pio_mask = 0x1f,
-               .mwdma_mask = 0x07,
+               .pio_mask = ATA_PIO4,
+               .mwdma_mask = ATA_MWDMA2,
                .udma_mask = ATA_UDMA5,
                .port_ops = &sil680_port_ops
        };
@@ -324,9 +341,6 @@ static int __devinit sil680_init_one(struct pci_dev *pdev,
        /* Try to acquire MMIO resources and fallback to PIO if
         * that fails
         */
-       rc = pcim_enable_device(pdev);
-       if (rc)
-               return rc;
        rc = pcim_iomap_regions(pdev, 1 << SIL680_MMIO_BAR, DRV_NAME);
        if (rc)
                goto use_ioports;
@@ -352,19 +366,19 @@ static int __devinit sil680_init_one(struct pci_dev *pdev,
        host->ports[0]->ioaddr.cmd_addr = mmio_base + 0x80;
        host->ports[0]->ioaddr.ctl_addr = mmio_base + 0x8a;
        host->ports[0]->ioaddr.altstatus_addr = mmio_base + 0x8a;
-       ata_std_ports(&host->ports[0]->ioaddr);
+       ata_sff_std_ports(&host->ports[0]->ioaddr);
        host->ports[1]->ioaddr.bmdma_addr = mmio_base + 0x08;
        host->ports[1]->ioaddr.cmd_addr = mmio_base + 0xc0;
        host->ports[1]->ioaddr.ctl_addr = mmio_base + 0xca;
        host->ports[1]->ioaddr.altstatus_addr = mmio_base + 0xca;
-       ata_std_ports(&host->ports[1]->ioaddr);
+       ata_sff_std_ports(&host->ports[1]->ioaddr);
 
        /* Register & activate */
-       return ata_host_activate(host, pdev->irq, ata_interrupt, IRQF_SHARED,
-                                &sil680_sht);
+       return ata_host_activate(host, pdev->irq, ata_bmdma_interrupt,
+                                IRQF_SHARED, &sil680_sht);
 
 use_ioports:
-       return ata_pci_init_one(pdev, ppi);
+       return ata_pci_bmdma_init_one(pdev, ppi, &sil680_sht, NULL, 0);
 }
 
 #ifdef CONFIG_PM