pata_via: Blacklist some combinations of Transcend Flash and via
[safe/jmp/linux-2.6] / drivers / ata / pata_pdc2027x.c
index 3d3f155..ca5cad0 100644 (file)
@@ -39,7 +39,7 @@
 #undef PDC_DEBUG
 
 #ifdef PDC_DEBUG
-#define PDPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args)
+#define PDPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
 #else
 #define PDPRINTK(fmt, args...)
 #endif
@@ -63,7 +63,7 @@ enum {
 };
 
 static int pdc2027x_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
-static void pdc2027x_error_handler(struct ata_port *ap);
+static int pdc2027x_prereset(struct ata_link *link, unsigned long deadline);
 static void pdc2027x_set_piomode(struct ata_port *ap, struct ata_device *adev);
 static void pdc2027x_set_dmamode(struct ata_port *ap, struct ata_device *adev);
 static int pdc2027x_check_atapi_dma(struct ata_queued_cmd *qc);
@@ -129,84 +129,22 @@ static struct pci_driver pdc2027x_pci_driver = {
 };
 
 static struct scsi_host_template pdc2027x_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 pdc2027x_pata100_ops = {
-       .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             = ata_std_dev_select,
-
+       .inherits               = &ata_bmdma_port_ops,
        .check_atapi_dma        = pdc2027x_check_atapi_dma,
-       .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,
-
-       .freeze                 = ata_bmdma_freeze,
-       .thaw                   = ata_bmdma_thaw,
-       .error_handler          = pdc2027x_error_handler,
-       .post_internal_cmd      = ata_bmdma_post_internal_cmd,
        .cable_detect           = pdc2027x_cable_detect,
-
-       .irq_clear              = ata_bmdma_irq_clear,
-       .irq_on                 = ata_irq_on,
-
-       .port_start             = ata_sff_port_start,
+       .prereset               = pdc2027x_prereset,
 };
 
 static struct ata_port_operations pdc2027x_pata133_ops = {
+       .inherits               = &pdc2027x_pata100_ops,
+       .mode_filter            = pdc2027x_mode_filter,
        .set_piomode            = pdc2027x_set_piomode,
        .set_dmamode            = pdc2027x_set_dmamode,
        .set_mode               = pdc2027x_set_mode,
-       .mode_filter            = pdc2027x_mode_filter,
-
-       .tf_load                = ata_tf_load,
-       .tf_read                = ata_tf_read,
-       .check_status           = ata_check_status,
-       .exec_command           = ata_exec_command,
-       .dev_select             = ata_std_dev_select,
-
-       .check_atapi_dma        = pdc2027x_check_atapi_dma,
-       .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,
-
-       .freeze                 = ata_bmdma_freeze,
-       .thaw                   = ata_bmdma_thaw,
-       .error_handler          = pdc2027x_error_handler,
-       .post_internal_cmd      = ata_bmdma_post_internal_cmd,
-       .cable_detect           = pdc2027x_cable_detect,
-
-       .irq_clear              = ata_bmdma_irq_clear,
-       .irq_on                 = ata_irq_on,
-
-       .port_start             = ata_sff_port_start,
 };
 
 static struct ata_port_info pdc2027x_port_info[] = {
@@ -214,18 +152,18 @@ static struct ata_port_info pdc2027x_port_info[] = {
        {
                .flags          = ATA_FLAG_NO_LEGACY | ATA_FLAG_SLAVE_POSS |
                                  ATA_FLAG_MMIO,
-               .pio_mask       = 0x1f, /* pio0-4 */
-               .mwdma_mask     = 0x07, /* mwdma0-2 */
-               .udma_mask      = ATA_UDMA5, /* udma0-5 */
+               .pio_mask       = ATA_PIO4,
+               .mwdma_mask     = ATA_MWDMA2,
+               .udma_mask      = ATA_UDMA5,
                .port_ops       = &pdc2027x_pata100_ops,
        },
        /* PDC_UDMA_133 */
        {
                .flags          = ATA_FLAG_NO_LEGACY | ATA_FLAG_SLAVE_POSS |
                                  ATA_FLAG_MMIO,
-               .pio_mask       = 0x1f, /* pio0-4 */
-               .mwdma_mask     = 0x07, /* mwdma0-2 */
-               .udma_mask      = ATA_UDMA6, /* udma0-6 */
+               .pio_mask       = ATA_PIO4,
+               .mwdma_mask     = ATA_MWDMA2,
+               .udma_mask      = ATA_UDMA6,
                .port_ops       = &pdc2027x_pata133_ops,
        },
 };
@@ -310,22 +248,7 @@ static int pdc2027x_prereset(struct ata_link *link, unsigned long deadline)
        /* Check whether port enabled */
        if (!pdc2027x_port_enabled(link->ap))
                return -ENOENT;
-       return ata_std_prereset(link, deadline);
-}
-
-/**
- *     pdc2027x_error_handler - Perform reset on PATA port and classify
- *     @ap: Port to reset
- *
- *     Reset PATA phy and classify attached devices.
- *
- *     LOCKING:
- *     None (inherited from caller).
- */
-
-static void pdc2027x_error_handler(struct ata_port *ap)
-{
-       ata_bmdma_drive_eh(ap, pdc2027x_prereset, ata_std_softreset, NULL, ata_std_postreset);
+       return ata_sff_prereset(link, deadline);
 }
 
 /**
@@ -342,23 +265,22 @@ static unsigned long pdc2027x_mode_filter(struct ata_device *adev, unsigned long
        struct ata_device *pair = ata_dev_pair(adev);
 
        if (adev->class != ATA_DEV_ATA || adev->devno == 0 || pair == NULL)
-               return ata_pci_default_filter(adev, mask);
+               return ata_bmdma_mode_filter(adev, mask);
 
        /* Check for slave of a Maxtor at UDMA6 */
        ata_id_c_string(pair->id, model_num, ATA_ID_PROD,
                          ATA_ID_PROD_LEN + 1);
        /* If the master is a maxtor in UDMA6 then the slave should not use UDMA 6 */
-       if(strstr(model_num, "Maxtor") == 0 && pair->dma_mode == XFER_UDMA_6)
+       if (strstr(model_num, "Maxtor") == NULL && pair->dma_mode == XFER_UDMA_6)
                mask &= ~ (1 << (6 + ATA_SHIFT_UDMA));
 
-       return ata_pci_default_filter(adev, mask);
+       return ata_bmdma_mode_filter(adev, mask);
 }
 
 /**
  *     pdc2027x_set_piomode - Initialize host controller PATA PIO timings
  *     @ap: Port to configure
  *     @adev: um
- *     @pio: PIO mode, 0 - 4
  *
  *     Set PIO mode for device.
  *
@@ -403,7 +325,6 @@ static void pdc2027x_set_piomode(struct ata_port *ap, struct ata_device *adev)
  *     pdc2027x_set_dmamode - Initialize host controller PATA UDMA timings
  *     @ap: Port to configure
  *     @adev: um
- *     @udma: udma mode, XFER_UDMA_0 to XFER_UDMA_6
  *
  *     Set UDMA mode for device.
  *
@@ -483,23 +404,20 @@ static int pdc2027x_set_mode(struct ata_link *link, struct ata_device **r_failed
        if (rc < 0)
                return rc;
 
-       ata_link_for_each_dev(dev, link) {
-               if (ata_dev_enabled(dev)) {
+       ata_for_each_dev(dev, link, ENABLED) {
+               pdc2027x_set_piomode(ap, dev);
 
-                       pdc2027x_set_piomode(ap, dev);
+               /*
+                * Enable prefetch if the device support PIO only.
+                */
+               if (dev->xfer_shift == ATA_SHIFT_PIO) {
+                       u32 ctcr1 = ioread32(dev_mmio(ap, dev, PDC_CTCR1));
+                       ctcr1 |= (1 << 25);
+                       iowrite32(ctcr1, dev_mmio(ap, dev, PDC_CTCR1));
 
-                       /*
-                        * Enable prefetch if the device support PIO only.
-                        */
-                       if (dev->xfer_shift == ATA_SHIFT_PIO) {
-                               u32 ctcr1 = ioread32(dev_mmio(ap, dev, PDC_CTCR1));
-                               ctcr1 |= (1 << 25);
-                               iowrite32(ctcr1, dev_mmio(ap, dev, PDC_CTCR1));
-
-                               PDPRINTK("Turn on prefetch\n");
-                       } else {
-                               pdc2027x_set_dmamode(ap, dev);
-                       }
+                       PDPRINTK("Turn on prefetch\n");
+               } else {
+                       pdc2027x_set_dmamode(ap, dev);
                }
        }
        return 0;
@@ -836,8 +754,8 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de
                return -EIO;
 
        pci_set_master(pdev);
-       return ata_host_activate(host, pdev->irq, ata_interrupt, IRQF_SHARED,
-                                &pdc2027x_sht);
+       return ata_host_activate(host, pdev->irq, ata_sff_interrupt,
+                                IRQF_SHARED, &pdc2027x_sht);
 }
 
 /**