]> err.no Git - linux-2.6/blobdiff - drivers/ide/arm/icside.c
Merge branches 'omap1-upstream' and 'omap2-upstream' into devel
[linux-2.6] / drivers / ide / arm / icside.c
index 1fe0457243dbbcf824d8ef1f468a5ca9fe275b24..7912a471f10daaa8e69cec965db3a0b3f819ee89 100644 (file)
 #include <linux/device.h>
 #include <linux/init.h>
 #include <linux/scatterlist.h>
+#include <linux/io.h>
 
 #include <asm/dma.h>
 #include <asm/ecard.h>
-#include <asm/io.h>
 
 #define ICS_IDENT_OFFSET               0x2280
 
@@ -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 int icside_set_speed(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 1;
        }
 
        /*
@@ -289,17 +285,10 @@ 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;
+       return ide_config_drive_speed(drive, xfer_mode);
 }
 
 static void icside_dma_host_off(ide_drive_t *drive)
@@ -326,8 +315,7 @@ 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;
+       int xfer_mode = 0;
 
        if (!(id->capability & 1) || !hwif->autodma)
                goto out;
@@ -356,9 +344,10 @@ static int icside_dma_check(ide_drive_t *drive)
        }
 
 out:
-       on = icside_set_speed(drive, xfer_mode);
+       if (xfer_mode == 0)
+               return -1;
 
-       return on ? 0 : -1;
+       return icside_set_speed(drive, xfer_mode) ? -1 : 0;
 }
 
 static int icside_dma_end(ide_drive_t *drive)
@@ -448,23 +437,21 @@ static int icside_dma_test_irq(ide_drive_t *drive)
                        ICS_ARCIN_V6_INTRSTAT_1)) & 1;
 }
 
-static int icside_dma_timeout(ide_drive_t *drive)
+static void icside_dma_timeout(ide_drive_t *drive)
 {
        printk(KERN_ERR "%s: DMA timeout occurred: ", drive->name);
 
        if (icside_dma_test_irq(drive))
-               return 0;
+               return;
 
-       ide_dump_status(drive, "DMA timeout",
-               HWIF(drive)->INB(IDE_STATUS_REG));
+       ide_dump_status(drive, "DMA timeout", HWIF(drive)->INB(IDE_STATUS_REG));
 
-       return icside_dma_end(drive);
+       icside_dma_end(drive);
 }
 
-static int icside_dma_lostirq(ide_drive_t *drive)
+static void icside_dma_lost_irq(ide_drive_t *drive)
 {
        printk(KERN_ERR "%s: IRQ lost\n", drive->name);
-       return 1;
 }
 
 static void icside_dma_init(ide_hwif_t *hwif)
@@ -490,8 +477,8 @@ static void icside_dma_init(ide_hwif_t *hwif)
        hwif->dma_start         = icside_dma_start;
        hwif->ide_dma_end       = icside_dma_end;
        hwif->ide_dma_test_irq  = icside_dma_test_irq;
-       hwif->ide_dma_timeout   = icside_dma_timeout;
-       hwif->ide_dma_lostirq   = icside_dma_lostirq;
+       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;
@@ -565,8 +552,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
        ide_hwif_t *hwif;
        void __iomem *base;
 
-       base = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC),
-                      ecard_resource_len(ec, ECARD_RES_MEMC));
+       base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
        if (!base)
                return -ENOMEM;
 
@@ -574,8 +560,8 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
 
        ec->irqaddr  = base + ICS_ARCIN_V5_INTRSTAT;
        ec->irqmask  = 1;
-       ec->irq_data = state;
-       ec->ops      = &icside_ops_arcin_v5;
+
+       ecard_setirq(ec, &icside_ops_arcin_v5, state);
 
        /*
         * Be on the safe side - disable interrupts
@@ -583,10 +569,8 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
        icside_irqdisable_arcin_v5(ec, 0);
 
        hwif = icside_setup(base, &icside_cardinfo_v5, ec);
-       if (!hwif) {
-               iounmap(base);
+       if (!hwif)
                return -ENODEV;
-       }
 
        state->hwif[0] = hwif;
 
@@ -605,8 +589,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
        unsigned int sel = 0;
        int ret;
 
-       ioc_base = ioremap(ecard_resource_start(ec, ECARD_RES_IOCFAST),
-                          ecard_resource_len(ec, ECARD_RES_IOCFAST));
+       ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
        if (!ioc_base) {
                ret = -ENOMEM;
                goto out;
@@ -615,11 +598,10 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
        easi_base = ioc_base;
 
        if (ecard_resource_flags(ec, ECARD_RES_EASI)) {
-               easi_base = ioremap(ecard_resource_start(ec, ECARD_RES_EASI),
-                                   ecard_resource_len(ec, ECARD_RES_EASI));
+               easi_base = ecardm_iomap(ec, ECARD_RES_EASI, 0, 0);
                if (!easi_base) {
                        ret = -ENOMEM;
-                       goto unmap_slot;
+                       goto out;
                }
 
                /*
@@ -630,8 +612,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
 
        writeb(sel, ioc_base);
 
-       ec->irq_data      = state;
-       ec->ops           = &icside_ops_arcin_v6;
+       ecard_setirq(ec, &icside_ops_arcin_v6, state);
 
        state->irq_port   = easi_base;
        state->ioc_base   = ioc_base;
@@ -649,7 +630,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
 
        if (!hwif || !mate) {
                ret = -ENODEV;
-               goto unmap_port;
+               goto out;
        }
 
        state->hwif[0]    = hwif;
@@ -686,11 +667,6 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
 
        return 0;
 
- unmap_port:
-       if (easi_base != ioc_base)
-               iounmap(easi_base);
- unmap_slot:
-       iounmap(ioc_base);
  out:
        return ret;
 }
@@ -706,18 +682,16 @@ 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;
 
-       idmem = ioremap(ecard_resource_start(ec, ECARD_RES_IOCFAST),
-                       ecard_resource_len(ec, ECARD_RES_IOCFAST));
+       idmem = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
        if (idmem) {
                unsigned int type;
 
@@ -725,7 +699,7 @@ icside_probe(struct expansion_card *ec, const struct ecard_id *id)
                type |= (readb(idmem + ICS_IDENT_OFFSET + 4) & 1) << 1;
                type |= (readb(idmem + ICS_IDENT_OFFSET + 8) & 1) << 2;
                type |= (readb(idmem + ICS_IDENT_OFFSET + 12) & 1) << 3;
-               iounmap(idmem);
+               ecardm_iounmap(ec, idmem);
 
                state->type = type;
        }
@@ -793,13 +767,6 @@ static void __devexit icside_remove(struct expansion_card *ec)
        }
 
        ecard_set_drvdata(ec, NULL);
-       ec->ops = NULL;
-       ec->irq_data = NULL;
-
-       if (state->ioc_base)
-               iounmap(state->ioc_base);
-       if (state->ioc_base != state->irq_port)
-               iounmap(state->irq_port);
 
        kfree(state);
        ecard_release_resources(ec);