diff options
Diffstat (limited to 'drivers/ide/arm/palm_bk3710.c')
-rw-r--r-- | drivers/ide/arm/palm_bk3710.c | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/drivers/ide/arm/palm_bk3710.c b/drivers/ide/arm/palm_bk3710.c index 420fcb78a7c..aaf32541622 100644 --- a/drivers/ide/arm/palm_bk3710.c +++ b/drivers/ide/arm/palm_bk3710.c @@ -96,11 +96,11 @@ static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev, u16 val16; /* DMA Data Setup */ - t0 = (palm_bk3710_udmatimings[mode].cycletime + ide_palm_clk - 1) - / ide_palm_clk - 1; - tenv = (20 + ide_palm_clk - 1) / ide_palm_clk - 1; - trp = (palm_bk3710_udmatimings[mode].rptime + ide_palm_clk - 1) - / ide_palm_clk - 1; + t0 = DIV_ROUND_UP(palm_bk3710_udmatimings[mode].cycletime, + ide_palm_clk) - 1; + tenv = DIV_ROUND_UP(20, ide_palm_clk) - 1; + trp = DIV_ROUND_UP(palm_bk3710_udmatimings[mode].rptime, + ide_palm_clk) - 1; /* udmatim Register */ val16 = readw(base + BK3710_UDMATIM) & (dev ? 0xFF0F : 0xFFF0); @@ -141,8 +141,8 @@ static void palm_bk3710_setdmamode(void __iomem *base, unsigned int dev, cycletime = max_t(int, t->cycle, min_cycle); /* DMA Data Setup */ - t0 = (cycletime + ide_palm_clk - 1) / ide_palm_clk; - td = (t->active + ide_palm_clk - 1) / ide_palm_clk; + t0 = DIV_ROUND_UP(cycletime, ide_palm_clk); + td = DIV_ROUND_UP(t->active, ide_palm_clk); tkw = t0 - td - 1; td -= 1; @@ -168,9 +168,9 @@ static void palm_bk3710_setpiomode(void __iomem *base, ide_drive_t *mate, struct ide_timing *t; /* PIO Data Setup */ - t0 = (cycletime + ide_palm_clk - 1) / ide_palm_clk; - t2 = (ide_timing_find_mode(XFER_PIO_0 + mode)->active + - ide_palm_clk - 1) / ide_palm_clk; + t0 = DIV_ROUND_UP(cycletime, ide_palm_clk); + t2 = DIV_ROUND_UP(ide_timing_find_mode(XFER_PIO_0 + mode)->active, + ide_palm_clk); t2i = t0 - t2 - 1; t2 -= 1; @@ -192,8 +192,8 @@ static void palm_bk3710_setpiomode(void __iomem *base, ide_drive_t *mate, /* TASKFILE Setup */ t = ide_timing_find_mode(XFER_PIO_0 + mode); - t0 = (t->cyc8b + ide_palm_clk - 1) / ide_palm_clk; - t2 = (t->act8b + ide_palm_clk - 1) / ide_palm_clk; + t0 = DIV_ROUND_UP(t->cyc8b, ide_palm_clk); + t2 = DIV_ROUND_UP(t->act8b, ide_palm_clk); t2i = t0 - t2 - 1; t2 -= 1; @@ -317,17 +317,31 @@ 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, .pio_mask = ATA_PIO4, .udma_mask = ATA_UDMA4, /* (input clk 99MHz) */ .mwdma_mask = ATA_MWDMA2, @@ -372,30 +386,24 @@ 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; - hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); + hwif = ide_find_port(); if (hwif == NULL) goto out; 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); |