diff options
author | Sergei Shtylyov <sshtylyov@ru.mvista.com> | 2009-01-06 11:21:02 -0500 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-01-06 11:21:02 -0500 |
commit | 05789634ef84c78494c61124e69da49441735146 (patch) | |
tree | 757c705b015d0f5db765a8fc3f4f06cbd43efea6 /drivers | |
parent | 592b5315219881c6c0af4785f96456ad2043193a (diff) |
ide-dma-sff: factor out ide_dma_sff_write_status()
Factor out ide_dma_sff_write_status(), symmetric to ide_dma_sff_read_status().
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ide/ide-dma-sff.c | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/drivers/ide/ide-dma-sff.c b/drivers/ide/ide-dma-sff.c index bcdadc777564..123d393658af 100644 --- a/drivers/ide/ide-dma-sff.c +++ b/drivers/ide/ide-dma-sff.c | |||
@@ -61,6 +61,16 @@ u8 ide_dma_sff_read_status(ide_hwif_t *hwif) | |||
61 | } | 61 | } |
62 | EXPORT_SYMBOL_GPL(ide_dma_sff_read_status); | 62 | EXPORT_SYMBOL_GPL(ide_dma_sff_read_status); |
63 | 63 | ||
64 | static void ide_dma_sff_write_status(ide_hwif_t *hwif, u8 val) | ||
65 | { | ||
66 | unsigned long addr = hwif->dma_base + ATA_DMA_STATUS; | ||
67 | |||
68 | if (hwif->host_flags & IDE_HFLAG_MMIO) | ||
69 | writeb(val, (void __iomem *)addr); | ||
70 | else | ||
71 | outb(val, addr); | ||
72 | } | ||
73 | |||
64 | /** | 74 | /** |
65 | * ide_dma_host_set - Enable/disable DMA on a host | 75 | * ide_dma_host_set - Enable/disable DMA on a host |
66 | * @drive: drive to control | 76 | * @drive: drive to control |
@@ -80,11 +90,7 @@ void ide_dma_host_set(ide_drive_t *drive, int on) | |||
80 | else | 90 | else |
81 | dma_stat &= ~(1 << (5 + unit)); | 91 | dma_stat &= ~(1 << (5 + unit)); |
82 | 92 | ||
83 | if (hwif->host_flags & IDE_HFLAG_MMIO) | 93 | ide_dma_sff_write_status(hwif, dma_stat); |
84 | writeb(dma_stat, | ||
85 | (void __iomem *)(hwif->dma_base + ATA_DMA_STATUS)); | ||
86 | else | ||
87 | outb(dma_stat, hwif->dma_base + ATA_DMA_STATUS); | ||
88 | } | 94 | } |
89 | EXPORT_SYMBOL_GPL(ide_dma_host_set); | 95 | EXPORT_SYMBOL_GPL(ide_dma_host_set); |
90 | 96 | ||
@@ -198,7 +204,7 @@ int ide_dma_setup(ide_drive_t *drive) | |||
198 | } | 204 | } |
199 | 205 | ||
200 | /* PRD table */ | 206 | /* PRD table */ |
201 | if (hwif->host_flags & IDE_HFLAG_MMIO) | 207 | if (mmio) |
202 | writel(hwif->dmatable_dma, | 208 | writel(hwif->dmatable_dma, |
203 | (void __iomem *)(hwif->dma_base + ATA_DMA_TABLE_OFS)); | 209 | (void __iomem *)(hwif->dma_base + ATA_DMA_TABLE_OFS)); |
204 | else | 210 | else |
@@ -214,12 +220,7 @@ int ide_dma_setup(ide_drive_t *drive) | |||
214 | dma_stat = hwif->dma_ops->dma_sff_read_status(hwif); | 220 | dma_stat = hwif->dma_ops->dma_sff_read_status(hwif); |
215 | 221 | ||
216 | /* clear INTR & ERROR flags */ | 222 | /* clear INTR & ERROR flags */ |
217 | if (mmio) | 223 | ide_dma_sff_write_status(hwif, dma_stat | ATA_DMA_ERR | ATA_DMA_INTR); |
218 | writeb(dma_stat | ATA_DMA_ERR | ATA_DMA_INTR, | ||
219 | (void __iomem *)(hwif->dma_base + ATA_DMA_STATUS)); | ||
220 | else | ||
221 | outb(dma_stat | ATA_DMA_ERR | ATA_DMA_INTR, | ||
222 | hwif->dma_base + ATA_DMA_STATUS); | ||
223 | 224 | ||
224 | drive->waiting_for_dma = 1; | 225 | drive->waiting_for_dma = 1; |
225 | return 0; | 226 | return 0; |
@@ -300,13 +301,12 @@ EXPORT_SYMBOL_GPL(ide_dma_start); | |||
300 | int ide_dma_end(ide_drive_t *drive) | 301 | int ide_dma_end(ide_drive_t *drive) |
301 | { | 302 | { |
302 | ide_hwif_t *hwif = drive->hwif; | 303 | ide_hwif_t *hwif = drive->hwif; |
303 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; | ||
304 | u8 dma_stat = 0, dma_cmd = 0, mask; | 304 | u8 dma_stat = 0, dma_cmd = 0, mask; |
305 | 305 | ||
306 | drive->waiting_for_dma = 0; | 306 | drive->waiting_for_dma = 0; |
307 | 307 | ||
308 | /* stop DMA */ | 308 | /* stop DMA */ |
309 | if (mmio) { | 309 | if (hwif->host_flags & IDE_HFLAG_MMIO) { |
310 | dma_cmd = readb((void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); | 310 | dma_cmd = readb((void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); |
311 | writeb(dma_cmd & ~ATA_DMA_START, | 311 | writeb(dma_cmd & ~ATA_DMA_START, |
312 | (void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); | 312 | (void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); |
@@ -318,13 +318,8 @@ int ide_dma_end(ide_drive_t *drive) | |||
318 | /* get DMA status */ | 318 | /* get DMA status */ |
319 | dma_stat = hwif->dma_ops->dma_sff_read_status(hwif); | 319 | dma_stat = hwif->dma_ops->dma_sff_read_status(hwif); |
320 | 320 | ||
321 | if (mmio) | 321 | /* clear INTR & ERROR bits */ |
322 | /* clear the INTR & ERROR bits */ | 322 | ide_dma_sff_write_status(hwif, dma_stat | ATA_DMA_ERR | ATA_DMA_INTR); |
323 | writeb(dma_stat | ATA_DMA_ERR | ATA_DMA_INTR, | ||
324 | (void __iomem *)(hwif->dma_base + ATA_DMA_STATUS)); | ||
325 | else | ||
326 | outb(dma_stat | ATA_DMA_ERR | ATA_DMA_INTR, | ||
327 | hwif->dma_base + ATA_DMA_STATUS); | ||
328 | 323 | ||
329 | /* purge DMA mappings */ | 324 | /* purge DMA mappings */ |
330 | ide_destroy_dmatable(drive); | 325 | ide_destroy_dmatable(drive); |