ide: add 'init_default' and 'restore' arguments to ide_unregister()
[safe/jmp/linux-2.6] / drivers / ide / arm / icside.c
index 6298932..fb00f38 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * linux/drivers/ide/arm/icside.c
- *
  * Copyright (c) 1996-2004 Russell King.
  *
  * Please note that this platform does not support 32-bit IDE IO.
@@ -71,8 +69,6 @@ struct icside_state {
        void __iomem *irq_port;
        void __iomem *ioc_base;
        unsigned int type;
-       /* parent device... until the IDE core gets one of its own */
-       struct device *dev;
        ide_hwif_t *hwif[2];
 };
 
@@ -206,23 +202,6 @@ static void icside_maskproc(ide_drive_t *drive, int mask)
  * interfaces use the same IRQ, which should guarantee this.
  */
 
-static void icside_build_sglist(ide_drive_t *drive, struct request *rq)
-{
-       ide_hwif_t *hwif = drive->hwif;
-       struct icside_state *state = hwif->hwif_data;
-       struct scatterlist *sg = hwif->sg_table;
-
-       ide_map_sg(drive, rq);
-
-       if (rq_data_dir(rq) == READ)
-               hwif->sg_dma_direction = DMA_FROM_DEVICE;
-       else
-               hwif->sg_dma_direction = DMA_TO_DEVICE;
-
-       hwif->sg_nents = dma_map_sg(state->dev, sg, hwif->sg_nents,
-                                   hwif->sg_dma_direction);
-}
-
 /*
  * Configure the IOMD to give the appropriate timings for the transfer
  * mode being requested.  We take the advice of the ATA standards, and
@@ -272,8 +251,6 @@ static void icside_set_dma_mode(ide_drive_t *drive, const u8 xfer_mode)
        case XFER_SW_DMA_0:
                cycle_time = 480;
                break;
-       default:
-               return;
        }
 
        /*
@@ -289,54 +266,39 @@ static void icside_set_dma_mode(ide_drive_t *drive, const u8 xfer_mode)
                ide_xfer_verbose(xfer_mode), 2000 / drive->drive_data);
 }
 
-static void icside_dma_host_off(ide_drive_t *drive)
-{
-}
-
-static void icside_dma_off_quietly(ide_drive_t *drive)
-{
-       drive->using_dma = 0;
-}
-
-static void icside_dma_host_on(ide_drive_t *drive)
-{
-}
-
-static int icside_dma_on(ide_drive_t *drive)
+static void icside_dma_host_set(ide_drive_t *drive, int on)
 {
-       drive->using_dma = 1;
-
-       return 0;
 }
 
 static int icside_dma_end(ide_drive_t *drive)
 {
        ide_hwif_t *hwif = HWIF(drive);
-       struct icside_state *state = hwif->hwif_data;
+       struct expansion_card *ec = ECARD_DEV(hwif->dev);
 
        drive->waiting_for_dma = 0;
 
-       disable_dma(hwif->hw.dma);
+       disable_dma(ec->dma);
 
        /* Teardown mappings after DMA has completed. */
-       dma_unmap_sg(state->dev, hwif->sg_table, hwif->sg_nents,
-                    hwif->sg_dma_direction);
+       ide_destroy_dmatable(drive);
 
-       return get_dma_residue(hwif->hw.dma) != 0;
+       return get_dma_residue(ec->dma) != 0;
 }
 
 static void icside_dma_start(ide_drive_t *drive)
 {
        ide_hwif_t *hwif = HWIF(drive);
+       struct expansion_card *ec = ECARD_DEV(hwif->dev);
 
        /* We can not enable DMA on both channels simultaneously. */
-       BUG_ON(dma_channel_active(hwif->hw.dma));
-       enable_dma(hwif->hw.dma);
+       BUG_ON(dma_channel_active(ec->dma));
+       enable_dma(ec->dma);
 }
 
 static int icside_dma_setup(ide_drive_t *drive)
 {
        ide_hwif_t *hwif = HWIF(drive);
+       struct expansion_card *ec = ECARD_DEV(hwif->dev);
        struct request *rq = hwif->hwgroup->rq;
        unsigned int dma_mode;
 
@@ -348,9 +310,9 @@ static int icside_dma_setup(ide_drive_t *drive)
        /*
         * We can not enable DMA on both channels.
         */
-       BUG_ON(dma_channel_active(hwif->hw.dma));
+       BUG_ON(dma_channel_active(ec->dma));
 
-       icside_build_sglist(drive, rq);
+       hwif->sg_nents = ide_build_sglist(drive, rq);
 
        /*
         * Ensure that we have the right interrupt routed.
@@ -365,14 +327,14 @@ static int icside_dma_setup(ide_drive_t *drive)
        /*
         * Select the correct timing for this drive.
         */
-       set_dma_speed(hwif->hw.dma, drive->drive_data);
+       set_dma_speed(ec->dma, drive->drive_data);
 
        /*
         * Tell the DMA engine about the SG table and
         * data direction.
         */
-       set_dma_sg(hwif->hw.dma, hwif->sg_table, hwif->sg_nents);
-       set_dma_mode(hwif->hw.dma, dma_mode);
+       set_dma_sg(ec->dma, hwif->sg_table, hwif->sg_nents);
+       set_dma_mode(ec->dma, dma_mode);
 
        drive->waiting_for_dma = 1;
 
@@ -415,17 +377,11 @@ static void icside_dma_lost_irq(ide_drive_t *drive)
 
 static void icside_dma_init(ide_hwif_t *hwif)
 {
-       hwif->mwdma_mask        = 7; /* MW0..2 */
-       hwif->swdma_mask        = 7; /* SW0..2 */
-
        hwif->dmatable_cpu      = NULL;
        hwif->dmatable_dma      = 0;
        hwif->set_dma_mode      = icside_set_dma_mode;
 
-       hwif->dma_host_off      = icside_dma_host_off;
-       hwif->dma_off_quietly   = icside_dma_off_quietly;
-       hwif->dma_host_on       = icside_dma_host_on;
-       hwif->ide_dma_on        = icside_dma_on;
+       hwif->dma_host_set      = icside_dma_host_set;
        hwif->dma_setup         = icside_dma_setup;
        hwif->dma_exec_cmd      = icside_dma_exec_cmd;
        hwif->dma_start         = icside_dma_start;
@@ -438,40 +394,16 @@ static void icside_dma_init(ide_hwif_t *hwif)
 #define icside_dma_init(hwif)  (0)
 #endif
 
-static ide_hwif_t *icside_find_hwif(unsigned long dataport)
-{
-       ide_hwif_t *hwif;
-       int index;
-
-       for (index = 0; index < MAX_HWIFS; ++index) {
-               hwif = &ide_hwifs[index];
-               if (hwif->io_ports[IDE_DATA_OFFSET] == dataport)
-                       goto found;
-       }
-
-       for (index = 0; index < MAX_HWIFS; ++index) {
-               hwif = &ide_hwifs[index];
-               if (!hwif->io_ports[IDE_DATA_OFFSET])
-                       goto found;
-       }
-
-       hwif = NULL;
-found:
-       return hwif;
-}
-
 static ide_hwif_t *
 icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *ec)
 {
        unsigned long port = (unsigned long)base + info->dataoffset;
        ide_hwif_t *hwif;
 
-       hwif = icside_find_hwif(port);
+       hwif = ide_find_port(port);
        if (hwif) {
                int i;
 
-               memset(&hwif->hw, 0, sizeof(hw_regs_t));
-
                /*
                 * Ensure we're using MMIO
                 */
@@ -479,17 +411,15 @@ icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *e
                hwif->mmio = 1;
 
                for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
-                       hwif->hw.io_ports[i] = port;
                        hwif->io_ports[i] = port;
                        port += 1 << info->stepping;
                }
-               hwif->hw.io_ports[IDE_CONTROL_OFFSET] = (unsigned long)base + info->ctrloffset;
                hwif->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)base + info->ctrloffset;
-               hwif->hw.irq  = ec->irq;
                hwif->irq     = ec->irq;
                hwif->noprobe = 0;
                hwif->chipset = ide_acorn;
                hwif->gendev.parent = &ec->dev;
+               hwif->dev = &ec->dev;
        }
 
        return hwif;
@@ -526,11 +456,19 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
 
        idx[0] = hwif->index;
 
-       ide_device_add(idx);
+       ide_device_add(idx, NULL);
 
        return 0;
 }
 
+static const struct ide_port_info icside_v6_port_info __initdata = {
+       .host_flags             = IDE_HFLAG_SERIALIZE |
+                                 IDE_HFLAG_NO_DMA | /* no SFF-style DMA */
+                                 IDE_HFLAG_NO_AUTOTUNE,
+       .mwdma_mask             = ATA_MWDMA2,
+       .swdma_mask             = ATA_SWDMA2,
+};
+
 static int __init
 icside_register_v6(struct icside_state *state, struct expansion_card *ec)
 {
@@ -539,6 +477,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
        unsigned int sel = 0;
        int ret;
        u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
+       struct ide_port_info d = icside_v6_port_info;
 
        ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
        if (!ioc_base) {
@@ -588,32 +527,25 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
        state->hwif[1]    = mate;
 
        hwif->maskproc    = icside_maskproc;
-       hwif->channel     = 0;
        hwif->hwif_data   = state;
-       hwif->mate        = mate;
-       hwif->serialized  = 1;
        hwif->config_data = (unsigned long)ioc_base;
        hwif->select_data = sel;
-       hwif->hw.dma      = ec->dma;
 
        mate->maskproc    = icside_maskproc;
-       mate->channel     = 1;
        mate->hwif_data   = state;
-       mate->mate        = hwif;
-       mate->serialized  = 1;
        mate->config_data = (unsigned long)ioc_base;
        mate->select_data = sel | 1;
-       mate->hw.dma      = ec->dma;
 
        if (ec->dma != NO_DMA && !request_dma(ec->dma, hwif->name)) {
                icside_dma_init(hwif);
                icside_dma_init(mate);
-       }
+       } else
+               d.mwdma_mask = d.swdma_mask = 0;
 
        idx[0] = hwif->index;
        idx[1] = mate->index;
 
-       ide_device_add(idx);
+       ide_device_add(idx, &d);
 
        return 0;
 
@@ -639,7 +571,6 @@ icside_probe(struct expansion_card *ec, const struct ecard_id *id)
        }
 
        state->type     = ICS_TYPE_NOTYPE;
-       state->dev      = &ec->dev;
 
        idmem = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
        if (idmem) {