aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/scc_pata.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/scc_pata.c')
-rw-r--r--drivers/ide/scc_pata.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/drivers/ide/scc_pata.c b/drivers/ide/scc_pata.c
index 0f48f9dacfa5..8d2314b6327c 100644
--- a/drivers/ide/scc_pata.c
+++ b/drivers/ide/scc_pata.c
@@ -143,7 +143,7 @@ static u8 scc_read_altstatus(ide_hwif_t *hwif)
143 return (u8)in_be32((void *)hwif->io_ports.ctl_addr); 143 return (u8)in_be32((void *)hwif->io_ports.ctl_addr);
144} 144}
145 145
146static u8 scc_read_sff_dma_status(ide_hwif_t *hwif) 146static u8 scc_dma_sff_read_status(ide_hwif_t *hwif)
147{ 147{
148 return (u8)in_be32((void *)(hwif->dma_base + 4)); 148 return (u8)in_be32((void *)(hwif->dma_base + 4));
149} 149}
@@ -217,7 +217,7 @@ scc_ide_outsl(unsigned long port, void *addr, u32 count)
217 217
218static void scc_set_pio_mode(ide_drive_t *drive, const u8 pio) 218static void scc_set_pio_mode(ide_drive_t *drive, const u8 pio)
219{ 219{
220 ide_hwif_t *hwif = HWIF(drive); 220 ide_hwif_t *hwif = drive->hwif;
221 struct scc_ports *ports = ide_get_hwifdata(hwif); 221 struct scc_ports *ports = ide_get_hwifdata(hwif);
222 unsigned long ctl_base = ports->ctl; 222 unsigned long ctl_base = ports->ctl;
223 unsigned long cckctrl_port = ctl_base + 0xff0; 223 unsigned long cckctrl_port = ctl_base + 0xff0;
@@ -249,7 +249,7 @@ static void scc_set_pio_mode(ide_drive_t *drive, const u8 pio)
249 249
250static void scc_set_dma_mode(ide_drive_t *drive, const u8 speed) 250static void scc_set_dma_mode(ide_drive_t *drive, const u8 speed)
251{ 251{
252 ide_hwif_t *hwif = HWIF(drive); 252 ide_hwif_t *hwif = drive->hwif;
253 struct scc_ports *ports = ide_get_hwifdata(hwif); 253 struct scc_ports *ports = ide_get_hwifdata(hwif);
254 unsigned long ctl_base = ports->ctl; 254 unsigned long ctl_base = ports->ctl;
255 unsigned long cckctrl_port = ctl_base + 0xff0; 255 unsigned long cckctrl_port = ctl_base + 0xff0;
@@ -259,7 +259,7 @@ static void scc_set_dma_mode(ide_drive_t *drive, const u8 speed)
259 unsigned long scrcst_port = ctl_base + 0x014; 259 unsigned long scrcst_port = ctl_base + 0x014;
260 unsigned long udenvt_port = ctl_base + 0x018; 260 unsigned long udenvt_port = ctl_base + 0x018;
261 unsigned long tdvhsel_port = ctl_base + 0x020; 261 unsigned long tdvhsel_port = ctl_base + 0x020;
262 int is_slave = (&hwif->drives[1] == drive); 262 int is_slave = drive->dn & 1;
263 int offset, idx; 263 int offset, idx;
264 unsigned long reg; 264 unsigned long reg;
265 unsigned long jcactsel; 265 unsigned long jcactsel;
@@ -292,7 +292,7 @@ static void scc_dma_host_set(ide_drive_t *drive, int on)
292{ 292{
293 ide_hwif_t *hwif = drive->hwif; 293 ide_hwif_t *hwif = drive->hwif;
294 u8 unit = drive->dn & 1; 294 u8 unit = drive->dn & 1;
295 u8 dma_stat = scc_ide_inb(hwif->dma_base + 4); 295 u8 dma_stat = scc_dma_sff_read_status(hwif);
296 296
297 if (on) 297 if (on)
298 dma_stat |= (1 << (5 + unit)); 298 dma_stat |= (1 << (5 + unit));
@@ -316,7 +316,7 @@ static void scc_dma_host_set(ide_drive_t *drive, int on)
316static int scc_dma_setup(ide_drive_t *drive) 316static int scc_dma_setup(ide_drive_t *drive)
317{ 317{
318 ide_hwif_t *hwif = drive->hwif; 318 ide_hwif_t *hwif = drive->hwif;
319 struct request *rq = HWGROUP(drive)->rq; 319 struct request *rq = hwif->rq;
320 unsigned int reading; 320 unsigned int reading;
321 u8 dma_stat; 321 u8 dma_stat;
322 322
@@ -338,7 +338,7 @@ static int scc_dma_setup(ide_drive_t *drive)
338 out_be32((void __iomem *)hwif->dma_base, reading); 338 out_be32((void __iomem *)hwif->dma_base, reading);
339 339
340 /* read DMA status for INTR & ERROR flags */ 340 /* read DMA status for INTR & ERROR flags */
341 dma_stat = in_be32((void __iomem *)(hwif->dma_base + 4)); 341 dma_stat = scc_dma_sff_read_status(hwif);
342 342
343 /* clear INTR & ERROR flags */ 343 /* clear INTR & ERROR flags */
344 out_be32((void __iomem *)(hwif->dma_base + 4), dma_stat | 6); 344 out_be32((void __iomem *)(hwif->dma_base + 4), dma_stat | 6);
@@ -367,7 +367,7 @@ static int __scc_dma_end(ide_drive_t *drive)
367 /* stop DMA */ 367 /* stop DMA */
368 scc_ide_outb(dma_cmd & ~1, hwif->dma_base); 368 scc_ide_outb(dma_cmd & ~1, hwif->dma_base);
369 /* get DMA status */ 369 /* get DMA status */
370 dma_stat = scc_ide_inb(hwif->dma_base + 4); 370 dma_stat = scc_dma_sff_read_status(hwif);
371 /* clear the INTR & ERROR bits */ 371 /* clear the INTR & ERROR bits */
372 scc_ide_outb(dma_stat | 6, hwif->dma_base + 4); 372 scc_ide_outb(dma_stat | 6, hwif->dma_base + 4);
373 /* purge DMA mappings */ 373 /* purge DMA mappings */
@@ -387,7 +387,7 @@ static int __scc_dma_end(ide_drive_t *drive)
387 387
388static int scc_dma_end(ide_drive_t *drive) 388static int scc_dma_end(ide_drive_t *drive)
389{ 389{
390 ide_hwif_t *hwif = HWIF(drive); 390 ide_hwif_t *hwif = drive->hwif;
391 void __iomem *dma_base = (void __iomem *)hwif->dma_base; 391 void __iomem *dma_base = (void __iomem *)hwif->dma_base;
392 unsigned long intsts_port = hwif->dma_base + 0x014; 392 unsigned long intsts_port = hwif->dma_base + 0x014;
393 u32 reg; 393 u32 reg;
@@ -405,17 +405,18 @@ static int scc_dma_end(ide_drive_t *drive)
405 drive->name); 405 drive->name);
406 data_loss = 1; 406 data_loss = 1;
407 if (retry++) { 407 if (retry++) {
408 struct request *rq = HWGROUP(drive)->rq; 408 struct request *rq = hwif->rq;
409 int unit; 409 ide_drive_t *drive;
410 int i;
411
410 /* ERROR_RESET and drive->crc_count are needed 412 /* ERROR_RESET and drive->crc_count are needed
411 * to reduce DMA transfer mode in retry process. 413 * to reduce DMA transfer mode in retry process.
412 */ 414 */
413 if (rq) 415 if (rq)
414 rq->errors |= ERROR_RESET; 416 rq->errors |= ERROR_RESET;
415 for (unit = 0; unit < MAX_DRIVES; unit++) { 417
416 ide_drive_t *drive = &hwif->drives[unit]; 418 ide_port_for_each_dev(i, drive, hwif)
417 drive->crc_count++; 419 drive->crc_count++;
418 }
419 } 420 }
420 } 421 }
421 } 422 }
@@ -496,7 +497,7 @@ static int scc_dma_end(ide_drive_t *drive)
496/* returns 1 if dma irq issued, 0 otherwise */ 497/* returns 1 if dma irq issued, 0 otherwise */
497static int scc_dma_test_irq(ide_drive_t *drive) 498static int scc_dma_test_irq(ide_drive_t *drive)
498{ 499{
499 ide_hwif_t *hwif = HWIF(drive); 500 ide_hwif_t *hwif = drive->hwif;
500 u32 int_stat = in_be32((void __iomem *)hwif->dma_base + 0x014); 501 u32 int_stat = in_be32((void __iomem *)hwif->dma_base + 0x014);
501 502
502 /* SCC errata A252,A308 workaround: Step4 */ 503 /* SCC errata A252,A308 workaround: Step4 */
@@ -852,7 +853,6 @@ static const struct ide_tp_ops scc_tp_ops = {
852 .exec_command = scc_exec_command, 853 .exec_command = scc_exec_command,
853 .read_status = scc_read_status, 854 .read_status = scc_read_status,
854 .read_altstatus = scc_read_altstatus, 855 .read_altstatus = scc_read_altstatus,
855 .read_sff_dma_status = scc_read_sff_dma_status,
856 856
857 .set_irq = scc_set_irq, 857 .set_irq = scc_set_irq,
858 858
@@ -879,6 +879,7 @@ static const struct ide_dma_ops scc_dma_ops = {
879 .dma_test_irq = scc_dma_test_irq, 879 .dma_test_irq = scc_dma_test_irq,
880 .dma_lost_irq = ide_dma_lost_irq, 880 .dma_lost_irq = ide_dma_lost_irq,
881 .dma_timeout = ide_dma_timeout, 881 .dma_timeout = ide_dma_timeout,
882 .dma_sff_read_status = scc_dma_sff_read_status,
882}; 883};
883 884
884#define DECLARE_SCC_DEV(name_str) \ 885#define DECLARE_SCC_DEV(name_str) \