ide: fix UDMA/MWDMA/SWDMA masks (v3)
[powerpc.git] / drivers / ide / pci / pdc202xx_new.c
index 236a031..a238534 100644 (file)
@@ -101,8 +101,8 @@ static u8 get_indexed_reg(ide_hwif_t *hwif, u8 index)
 {
        u8 value;
 
-       hwif->OUTB(index, hwif->dma_vendor1);
-       value = hwif->INB(hwif->dma_vendor3);
+       outb(index, hwif->dma_vendor1);
+       value = inb(hwif->dma_vendor3);
 
        DBG("index[%02X] value[%02X]\n", index, value);
        return value;
@@ -115,8 +115,8 @@ static u8 get_indexed_reg(ide_hwif_t *hwif, u8 index)
  */
 static void set_indexed_reg(ide_hwif_t *hwif, u8 index, u8 value)
 {
-       hwif->OUTB(index, hwif->dma_vendor1);
-       hwif->OUTB(value, hwif->dma_vendor3);
+       outb(index, hwif->dma_vendor1);
+       outb(value, hwif->dma_vendor3);
        DBG("index[%02X] value[%02X]\n", index, value);
 }
 
@@ -255,9 +255,6 @@ static int config_chipset_for_dma(ide_drive_t *drive)
                printk(KERN_WARNING "%s reduced to Ultra33 mode.\n", drive->name);
        }
 
-       if (drive->media != ide_disk)
-               return 0;
-
        if (id->capability & 4) {
                /*
                 * Set IORDY_EN & PREFETCH_EN (this seems to have
@@ -281,25 +278,15 @@ static int config_chipset_for_dma(ide_drive_t *drive)
 
 static int pdcnew_config_drive_xfer_rate(ide_drive_t *drive)
 {
-       ide_hwif_t *hwif        = HWIF(drive);
-       struct hd_driveid *id   = drive->id;
-
        drive->init_speed = 0;
 
-       if ((id->capability & 1) && drive->autodma) {
-
-               if (ide_use_dma(drive) && config_chipset_for_dma(drive))
-                       return hwif->ide_dma_on(drive);
+       if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+               return 0;
 
-               goto fast_ata_pio;
+       if (ide_use_fast_pio(drive))
+               pdcnew_tune_drive(drive, 255);
 
-       } else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
-               hwif->tuneproc(drive, 255);
-               return hwif->ide_dma_off_quietly(drive);
-       }
-       /* IORDY not supported */
-       return 0;
+       return -1;
 }
 
 static int pdcnew_quirkproc(ide_drive_t *drive)
@@ -408,7 +395,7 @@ static void __devinit apple_kiwi_init(struct pci_dev *pdev)
        unsigned int class_rev = 0;
        u8 conf;
 
-       if (np == NULL || !device_is_compatible(np, "kiwi-root"))
+       if (np == NULL || !of_device_is_compatible(np, "kiwi-root"))
                return;
 
        pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class_rev);
@@ -555,7 +542,9 @@ static void __devinit init_hwif_pdc202new(ide_hwif_t *hwif)
 
        hwif->drives[0].autotune = hwif->drives[1].autotune = 1;
 
-       hwif->ultra_mask = 0x7f;
+       hwif->atapi_dma  = 1;
+
+       hwif->ultra_mask = hwif->cds->udma_mask;
        hwif->mwdma_mask = 0x07;
 
        hwif->err_stops_fifo = 1;
@@ -631,6 +620,7 @@ static ide_pci_device_t pdcnew_chipsets[] __devinitdata = {
                .channels       = 2,
                .autodma        = AUTODMA,
                .bootable       = OFF_BOARD,
+               .udma_mask      = 0x3f, /* udma0-5 */
        },{     /* 1 */
                .name           = "PDC20269",
                .init_setup     = init_setup_pdcnew,
@@ -639,6 +629,7 @@ static ide_pci_device_t pdcnew_chipsets[] __devinitdata = {
                .channels       = 2,
                .autodma        = AUTODMA,
                .bootable       = OFF_BOARD,
+               .udma_mask      = 0x7f, /* udma0-6*/
        },{     /* 2 */
                .name           = "PDC20270",
                .init_setup     = init_setup_pdc20270,
@@ -647,6 +638,7 @@ static ide_pci_device_t pdcnew_chipsets[] __devinitdata = {
                .channels       = 2,
                .autodma        = AUTODMA,
                .bootable       = OFF_BOARD,
+               .udma_mask      = 0x3f, /* udma0-5 */
        },{     /* 3 */
                .name           = "PDC20271",
                .init_setup     = init_setup_pdcnew,
@@ -655,6 +647,7 @@ static ide_pci_device_t pdcnew_chipsets[] __devinitdata = {
                .channels       = 2,
                .autodma        = AUTODMA,
                .bootable       = OFF_BOARD,
+               .udma_mask      = 0x7f, /* udma0-6*/
        },{     /* 4 */
                .name           = "PDC20275",
                .init_setup     = init_setup_pdcnew,
@@ -663,6 +656,7 @@ static ide_pci_device_t pdcnew_chipsets[] __devinitdata = {
                .channels       = 2,
                .autodma        = AUTODMA,
                .bootable       = OFF_BOARD,
+               .udma_mask      = 0x7f, /* udma0-6*/
        },{     /* 5 */
                .name           = "PDC20276",
                .init_setup     = init_setup_pdc20276,
@@ -671,6 +665,7 @@ static ide_pci_device_t pdcnew_chipsets[] __devinitdata = {
                .channels       = 2,
                .autodma        = AUTODMA,
                .bootable       = OFF_BOARD,
+               .udma_mask      = 0x7f, /* udma0-6*/
        },{     /* 6 */
                .name           = "PDC20277",
                .init_setup     = init_setup_pdcnew,
@@ -679,6 +674,7 @@ static ide_pci_device_t pdcnew_chipsets[] __devinitdata = {
                .channels       = 2,
                .autodma        = AUTODMA,
                .bootable       = OFF_BOARD,
+               .udma_mask      = 0x7f, /* udma0-6*/
        }
 };