]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - drivers/ide/ppc/pmac.c
ide: add IDE_HFLAG_ABUSE_SET_DMA_MODE host flag
[mirror_ubuntu-artful-kernel.git] / drivers / ide / ppc / pmac.c
index 1d25a3433008699dca36c172d610fff87d278033..3dce80092fff0e32cb539cffc151337f047d4f79 100644 (file)
@@ -438,13 +438,8 @@ pmac_ide_init_hwif_ports(hw_regs_t *hw,
                if (data_port == pmac_ide[ix].regbase)
                        break;
 
-       if (ix >= MAX_HWIFS) {
-               /* Probably a PCI interface... */
-               for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; ++i)
-                       hw->io_ports[i] = data_port + i - IDE_DATA_OFFSET;
-               hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
-               return;
-       }
+       if (ix >= MAX_HWIFS)
+               return;         /* not an IDE PMAC interface */
 
        for (i = 0; i < 8; ++i)
                hw->io_ports[i] = data_port + i * 0x10;
@@ -833,38 +828,20 @@ static void pmac_ide_set_dma_mode(ide_drive_t *drive, const u8 speed)
        tl[0] = *timings;
        tl[1] = *timings2;
 
-       switch(speed) {
 #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
-               case XFER_UDMA_6:
-               case XFER_UDMA_5:
-               case XFER_UDMA_4:
-               case XFER_UDMA_3:
-               case XFER_UDMA_2:
-               case XFER_UDMA_1:
-               case XFER_UDMA_0:
-                       if (pmif->kind == controller_kl_ata4)
-                               ret = set_timings_udma_ata4(&tl[0], speed);
-                       else if (pmif->kind == controller_un_ata6
-                                || pmif->kind == controller_k2_ata6)
-                               ret = set_timings_udma_ata6(&tl[0], &tl[1], speed);
-                       else if (pmif->kind == controller_sh_ata6)
-                               ret = set_timings_udma_shasta(&tl[0], &tl[1], speed);
-                       else
-                               ret = 1;
-                       break;
-               case XFER_MW_DMA_2:
-               case XFER_MW_DMA_1:
-               case XFER_MW_DMA_0:
-                       set_timings_mdma(drive, pmif->kind, &tl[0], &tl[1], speed);
-                       break;
-               case XFER_SW_DMA_2:
-               case XFER_SW_DMA_1:
-               case XFER_SW_DMA_0:
-                       return;
+       if (speed >= XFER_UDMA_0) {
+               if (pmif->kind == controller_kl_ata4)
+                       ret = set_timings_udma_ata4(&tl[0], speed);
+               else if (pmif->kind == controller_un_ata6
+                        || pmif->kind == controller_k2_ata6)
+                       ret = set_timings_udma_ata6(&tl[0], &tl[1], speed);
+               else if (pmif->kind == controller_sh_ata6)
+                       ret = set_timings_udma_shasta(&tl[0], &tl[1], speed);
+               else
+                       ret = -1;
+       } else
+               set_timings_mdma(drive, pmif->kind, &tl[0], &tl[1], speed);
 #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
-               default:
-                       ret = 1;
-       }
        if (ret)
                return;
 
@@ -1039,6 +1016,8 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
 {
        struct device_node *np = pmif->node;
        const int *bidp;
+       u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
+       hw_regs_t hw;
 
        pmif->cable_80 = 0;
        pmif->broken_dma = pmif->broken_dma_warn = 0;
@@ -1124,8 +1103,9 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
        /* Tell common code _not_ to mess with resources */
        hwif->mmio = 1;
        hwif->hwif_data = pmif;
-       pmac_ide_init_hwif_ports(&hwif->hw, pmif->regbase, 0, &hwif->irq);
-       memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports));
+       memset(&hw, 0, sizeof(hw));
+       pmac_ide_init_hwif_ports(&hw, pmif->regbase, 0, &hwif->irq);
+       memcpy(hwif->io_ports, hw.io_ports, sizeof(hwif->io_ports));
        hwif->chipset = ide_pmac;
        hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET] || pmif->mediabay;
        hwif->hold = pmif->mediabay;
@@ -1135,6 +1115,7 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
        hwif->drives[0].autotune = IDE_TUNE_AUTO;
        hwif->drives[1].autotune = IDE_TUNE_AUTO;
        hwif->host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA |
+                          IDE_HFLAG_PIO_NO_DOWNGRADE |
                           IDE_HFLAG_POST_SET_MODE;
        hwif->pio_mask = ATA_PIO4;
        hwif->set_pio_mode = pmac_ide_set_pio_mode;
@@ -1163,10 +1144,9 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
                pmac_ide_setup_dma(pmif, hwif);
 #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
 
-       /* We probe the hwif now */
-       probe_hwif_init(hwif);
+       idx[0] = hwif->index;
 
-       ide_proc_register_port(hwif);
+       ide_device_add(idx);
 
        return 0;
 }
@@ -1510,7 +1490,7 @@ pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq)
 
                if (pmif->broken_dma && cur_addr & (L1_CACHE_BYTES - 1)) {
                        if (pmif->broken_dma_warn == 0) {
-                               printk(KERN_WARNING "%s: DMA on non aligned address,"
+                               printk(KERN_WARNING "%s: DMA on non aligned address, "
                                       "switching to PIO on Ohare chipset\n", drive->name);
                                pmif->broken_dma_warn = 1;
                        }
@@ -1780,7 +1760,6 @@ pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
        hwif->dma_timeout = &ide_dma_timeout;
        hwif->dma_lost_irq = &pmac_ide_dma_lost_irq;
 
-       hwif->atapi_dma = 1;
        switch(pmif->kind) {
                case controller_sh_ata6:
                        hwif->ultra_mask = pmif->cable_80 ? 0x7f : 0x07;