palm_bk3710: add warm-plug support
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / ide / arm / palm_bk3710.c
index 666df779a5f46a119c1c2ff875eca5fb3d58e610..d024ac8fad14c95d2ac734f1c2f5d5549e5eda20 100644 (file)
@@ -317,17 +317,32 @@ static u8 __devinit palm_bk3710_cable_detect(ide_hwif_t *hwif)
        return ATA_CBL_PATA80;
 }
 
-static void __devinit palm_bk3710_init_hwif(ide_hwif_t *hwif)
+static int __devinit palm_bk3710_init_dma(ide_hwif_t *hwif,
+                                         const struct ide_port_info *d)
 {
-       hwif->set_pio_mode = palm_bk3710_set_pio_mode;
-       hwif->set_dma_mode = palm_bk3710_set_dma_mode;
+       unsigned long base =
+               hwif->io_ports.data_addr - IDE_PALM_ATA_PRI_REG_OFFSET;
 
-       hwif->cable_detect = palm_bk3710_cable_detect;
+       printk(KERN_INFO "    %s: MMIO-DMA\n", hwif->name);
+
+       if (ide_allocate_dma_engine(hwif))
+               return -1;
+
+       ide_setup_dma(hwif, base);
+
+       return 0;
 }
 
+static const struct ide_port_ops palm_bk3710_ports_ops = {
+       .set_pio_mode           = palm_bk3710_set_pio_mode,
+       .set_dma_mode           = palm_bk3710_set_dma_mode,
+       .cable_detect           = palm_bk3710_cable_detect,
+};
+
 static const struct ide_port_info __devinitdata palm_bk3710_port_info = {
-       .init_hwif              = palm_bk3710_init_hwif,
-       .host_flags             = IDE_HFLAG_NO_DMA, /* hack (no PCI) */
+       .init_dma               = palm_bk3710_init_dma,
+       .port_ops               = &palm_bk3710_ports_ops,
+       .host_flags             = IDE_HFLAG_MMIO,
        .pio_mask               = ATA_PIO4,
        .udma_mask              = ATA_UDMA4,    /* (input clk 99MHz) */
        .mwdma_mask             = ATA_MWDMA2,
@@ -372,8 +387,8 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev)
 
        pribase = mem->start + IDE_PALM_ATA_PRI_REG_OFFSET;
        for (i = 0; i < IDE_NR_PORTS - 2; i++)
-               hw.io_ports[i] = pribase + i;
-       hw.io_ports[IDE_CONTROL_OFFSET] = mem->start +
+               hw.io_ports_array[i] = pribase + i;
+       hw.io_ports.ctl_addr = mem->start +
                        IDE_PALM_ATA_PRI_CTL_OFFSET;
        hw.irq = irq->start;
        hw.chipset = ide_palm3710;
@@ -384,25 +399,16 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev)
 
        i = hwif->index;
 
-       if (hwif->present)
-               ide_unregister(i);
-       else
-               ide_init_port_data(hwif, i);
-
+       ide_init_port_data(hwif, i);
        ide_init_port_hw(hwif, &hw);
 
        hwif->mmio = 1;
        default_hwif_mmiops(hwif);
 
-       ide_setup_dma(hwif, mem->start);
-
        idx[0] = i;
 
        ide_device_add(idx, &palm_bk3710_port_info);
 
-       if (!hwif->present)
-               goto out;
-
        return 0;
 out:
        printk(KERN_WARNING "Palm Chip BK3710 IDE Register Fail\n");