]> err.no Git - linux-2.6/blobdiff - drivers/ide/arm/icside.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
[linux-2.6] / drivers / ide / arm / icside.c
index c89b5f4b2d043b09a418cb408d393582b9cb01c2..93f71fcfc04df46a571aa72e14726d36a3d81f58 100644 (file)
@@ -248,15 +248,9 @@ static void icside_build_sglist(ide_drive_t *drive, struct request *rq)
  *     MW1     80      50      50      150     C
  *     MW2     70      25      25      120     C
  */
-static int icside_set_speed(ide_drive_t *drive, u8 xfer_mode)
+static void icside_set_dma_mode(ide_drive_t *drive, const u8 xfer_mode)
 {
-       int on = 0, cycle_time = 0, use_dma_info = 0;
-
-       /*
-        * Limit the transfer speed to MW_DMA_2.
-        */
-       if (xfer_mode > XFER_MW_DMA_2)
-               xfer_mode = XFER_MW_DMA_2;
+       int cycle_time, use_dma_info = 0;
 
        switch (xfer_mode) {
        case XFER_MW_DMA_2:
@@ -278,6 +272,8 @@ static int icside_set_speed(ide_drive_t *drive, u8 xfer_mode)
        case XFER_SW_DMA_0:
                cycle_time = 480;
                break;
+       default:
+               return;
        }
 
        /*
@@ -289,17 +285,8 @@ static int icside_set_speed(ide_drive_t *drive, u8 xfer_mode)
 
        drive->drive_data = cycle_time;
 
-       if (cycle_time && ide_config_drive_speed(drive, xfer_mode) == 0)
-               on = 1;
-       else
-               drive->drive_data = 480;
-
        printk("%s: %s selected (peak %dMB/s)\n", drive->name,
                ide_xfer_verbose(xfer_mode), 2000 / drive->drive_data);
-
-       drive->current_speed = xfer_mode;
-
-       return on;
 }
 
 static void icside_dma_host_off(ide_drive_t *drive)
@@ -322,45 +309,6 @@ static int icside_dma_on(ide_drive_t *drive)
        return 0;
 }
 
-static int icside_dma_check(ide_drive_t *drive)
-{
-       struct hd_driveid *id = drive->id;
-       ide_hwif_t *hwif = HWIF(drive);
-       int xfer_mode = XFER_PIO_2;
-       int on;
-
-       if (!(id->capability & 1) || !hwif->autodma)
-               goto out;
-
-       /*
-        * Consult the list of known "bad" drives
-        */
-       if (__ide_dma_bad_drive(drive))
-               goto out;
-
-       /*
-        * Enable DMA on any drive that has multiword DMA
-        */
-       if (id->field_valid & 2) {
-               xfer_mode = ide_max_dma_mode(drive);
-               goto out;
-       }
-
-       /*
-        * Consult the list of known "good" drives
-        */
-       if (__ide_dma_good_drive(drive)) {
-               if (id->eide_dma_time > 150)
-                       goto out;
-               xfer_mode = XFER_MW_DMA_1;
-       }
-
-out:
-       on = icside_set_speed(drive, xfer_mode);
-
-       return on ? 0 : -1;
-}
-
 static int icside_dma_end(ide_drive_t *drive)
 {
        ide_hwif_t *hwif = HWIF(drive);
@@ -368,27 +316,29 @@ static int icside_dma_end(ide_drive_t *drive)
 
        drive->waiting_for_dma = 0;
 
-       disable_dma(hwif->hw.dma);
+       disable_dma(ECARD_DEV(state->dev)->dma);
 
        /* Teardown mappings after DMA has completed. */
        dma_unmap_sg(state->dev, hwif->sg_table, hwif->sg_nents,
                     hwif->sg_dma_direction);
 
-       return get_dma_residue(hwif->hw.dma) != 0;
+       return get_dma_residue(ECARD_DEV(state->dev)->dma) != 0;
 }
 
 static void icside_dma_start(ide_drive_t *drive)
 {
        ide_hwif_t *hwif = HWIF(drive);
+       struct icside_state *state = hwif->hwif_data;
 
        /* 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(ECARD_DEV(state->dev)->dma));
+       enable_dma(ECARD_DEV(state->dev)->dma);
 }
 
 static int icside_dma_setup(ide_drive_t *drive)
 {
        ide_hwif_t *hwif = HWIF(drive);
+       struct icside_state *state = hwif->hwif_data;
        struct request *rq = hwif->hwgroup->rq;
        unsigned int dma_mode;
 
@@ -400,7 +350,7 @@ 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(ECARD_DEV(state->dev)->dma));
 
        icside_build_sglist(drive, rq);
 
@@ -417,14 +367,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(ECARD_DEV(state->dev)->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(ECARD_DEV(state->dev)->dma, hwif->sg_table, hwif->sg_nents);
+       set_dma_mode(ECARD_DEV(state->dev)->dma, dma_mode);
 
        drive->waiting_for_dma = 1;
 
@@ -467,18 +417,13 @@ static void icside_dma_lost_irq(ide_drive_t *drive)
 
 static void icside_dma_init(ide_hwif_t *hwif)
 {
-       printk("    %s: SG-DMA", hwif->name);
-
-       hwif->atapi_dma         = 1;
        hwif->mwdma_mask        = 7; /* MW0..2 */
        hwif->swdma_mask        = 7; /* SW0..2 */
 
        hwif->dmatable_cpu      = NULL;
        hwif->dmatable_dma      = 0;
-       hwif->speedproc         = icside_set_speed;
-       hwif->autodma           = 1;
+       hwif->set_dma_mode      = icside_set_dma_mode;
 
-       hwif->ide_dma_check     = icside_dma_check;
        hwif->dma_host_off      = icside_dma_host_off;
        hwif->dma_off_quietly   = icside_dma_off_quietly;
        hwif->dma_host_on       = icside_dma_host_on;
@@ -490,50 +435,21 @@ static void icside_dma_init(ide_hwif_t *hwif)
        hwif->ide_dma_test_irq  = icside_dma_test_irq;
        hwif->dma_timeout       = icside_dma_timeout;
        hwif->dma_lost_irq      = icside_dma_lost_irq;
-
-       hwif->drives[0].autodma = hwif->autodma;
-       hwif->drives[1].autodma = hwif->autodma;
-
-       printk(" capable%s\n", hwif->autodma ? ", auto-enable" : "");
 }
 #else
 #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
                 */
@@ -541,13 +457,10 @@ 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;
@@ -562,6 +475,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
 {
        ide_hwif_t *hwif;
        void __iomem *base;
+       u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
 
        base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
        if (!base)
@@ -585,9 +499,9 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
 
        state->hwif[0] = hwif;
 
-       probe_hwif_init(hwif);
+       idx[0] = hwif->index;
 
-       ide_proc_register_port(hwif);
+       ide_device_add(idx);
 
        return 0;
 }
@@ -599,6 +513,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
        void __iomem *ioc_base, *easi_base;
        unsigned int sel = 0;
        int ret;
+       u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
 
        ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
        if (!ioc_base) {
@@ -654,7 +569,6 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
        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;
@@ -663,18 +577,16 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
        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);
        }
 
-       probe_hwif_init(hwif);
-       probe_hwif_init(mate);
+       idx[0] = hwif->index;
+       idx[1] = mate->index;
 
-       ide_proc_register_port(hwif);
-       ide_proc_register_port(mate);
+       ide_device_add(idx);
 
        return 0;
 
@@ -693,13 +605,12 @@ icside_probe(struct expansion_card *ec, const struct ecard_id *id)
        if (ret)
                goto out;
 
-       state = kmalloc(sizeof(struct icside_state), GFP_KERNEL);
+       state = kzalloc(sizeof(struct icside_state), GFP_KERNEL);
        if (!state) {
                ret = -ENOMEM;
                goto release;
        }
 
-       memset(state, 0, sizeof(state));
        state->type     = ICS_TYPE_NOTYPE;
        state->dev      = &ec->dev;