diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2007-02-16 20:40:25 -0500 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2007-02-16 20:40:25 -0500 |
commit | 0ecdca26e556eae9668ce6de9554757dddb942ef (patch) | |
tree | 21d62c01d0c0d5aeea2524252ed8dec6ca20b6d4 /drivers/ide/ppc/scc_pata.c | |
parent | 7569e8dc2213ecc47024ea5edbadc8736487d926 (diff) |
ide: use PIO/MMIO operations directly where possible (v2)
This results in smaller/faster/simpler code and allows future optimizations.
Also remove no longer needed ide[_mm]_{inl,outl}() and ide_hwif_t.{INL,OUTL}.
v2:
* updated for scc_pata
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ppc/scc_pata.c')
-rw-r--r-- | drivers/ide/ppc/scc_pata.c | 122 |
1 files changed, 76 insertions, 46 deletions
diff --git a/drivers/ide/ppc/scc_pata.c b/drivers/ide/ppc/scc_pata.c index 0ab26ea5a35a..de9110803745 100644 --- a/drivers/ide/ppc/scc_pata.c +++ b/drivers/ide/ppc/scc_pata.c | |||
@@ -132,12 +132,6 @@ static u16 scc_ide_inw(unsigned long port) | |||
132 | return (u16)data; | 132 | return (u16)data; |
133 | } | 133 | } |
134 | 134 | ||
135 | static u32 scc_ide_inl(unsigned long port) | ||
136 | { | ||
137 | u32 data = in_be32((void*)port); | ||
138 | return data; | ||
139 | } | ||
140 | |||
141 | static void scc_ide_insw(unsigned long port, void *addr, u32 count) | 135 | static void scc_ide_insw(unsigned long port, void *addr, u32 count) |
142 | { | 136 | { |
143 | u16 *ptr = (u16 *)addr; | 137 | u16 *ptr = (u16 *)addr; |
@@ -165,11 +159,6 @@ static void scc_ide_outw(u16 addr, unsigned long port) | |||
165 | out_be32((void*)port, addr); | 159 | out_be32((void*)port, addr); |
166 | } | 160 | } |
167 | 161 | ||
168 | static void scc_ide_outl(u32 addr, unsigned long port) | ||
169 | { | ||
170 | out_be32((void*)port, addr); | ||
171 | } | ||
172 | |||
173 | static void | 162 | static void |
174 | scc_ide_outbsync(ide_drive_t * drive, u8 addr, unsigned long port) | 163 | scc_ide_outbsync(ide_drive_t * drive, u8 addr, unsigned long port) |
175 | { | 164 | { |
@@ -258,16 +247,16 @@ static void scc_tuneproc(ide_drive_t *drive, byte mode_wanted) | |||
258 | break; | 247 | break; |
259 | } | 248 | } |
260 | 249 | ||
261 | reg = hwif->INL(cckctrl_port); | 250 | reg = in_be32((void __iomem *)cckctrl_port); |
262 | if (reg & CCKCTRL_ATACLKOEN) { | 251 | if (reg & CCKCTRL_ATACLKOEN) { |
263 | offset = 1; /* 133MHz */ | 252 | offset = 1; /* 133MHz */ |
264 | } else { | 253 | } else { |
265 | offset = 0; /* 100MHz */ | 254 | offset = 0; /* 100MHz */ |
266 | } | 255 | } |
267 | reg = JCHSTtbl[offset][mode_wanted] << 16 | JCHHTtbl[offset][mode_wanted]; | 256 | reg = JCHSTtbl[offset][mode_wanted] << 16 | JCHHTtbl[offset][mode_wanted]; |
268 | hwif->OUTL(reg, piosht_port); | 257 | out_be32((void __iomem *)piosht_port, reg); |
269 | reg = JCHCTtbl[offset][mode_wanted]; | 258 | reg = JCHCTtbl[offset][mode_wanted]; |
270 | hwif->OUTL(reg, pioct_port); | 259 | out_be32((void __iomem *)pioct_port, reg); |
271 | 260 | ||
272 | ide_config_drive_speed(drive, speed); | 261 | ide_config_drive_speed(drive, speed); |
273 | } | 262 | } |
@@ -299,7 +288,7 @@ static int scc_tune_chipset(ide_drive_t *drive, byte xferspeed) | |||
299 | unsigned long reg; | 288 | unsigned long reg; |
300 | unsigned long jcactsel; | 289 | unsigned long jcactsel; |
301 | 290 | ||
302 | reg = hwif->INL(cckctrl_port); | 291 | reg = in_be32((void __iomem *)cckctrl_port); |
303 | if (reg & CCKCTRL_ATACLKOEN) { | 292 | if (reg & CCKCTRL_ATACLKOEN) { |
304 | offset = 1; /* 133MHz */ | 293 | offset = 1; /* 133MHz */ |
305 | } else { | 294 | } else { |
@@ -334,17 +323,17 @@ static int scc_tune_chipset(ide_drive_t *drive, byte xferspeed) | |||
334 | 323 | ||
335 | jcactsel = JCACTSELtbl[offset][idx]; | 324 | jcactsel = JCACTSELtbl[offset][idx]; |
336 | if (is_slave) { | 325 | if (is_slave) { |
337 | hwif->OUTL(JCHDCTxtbl[offset][idx], sdmact_port); | 326 | out_be32((void __iomem *)sdmact_port, JCHDCTxtbl[offset][idx]); |
338 | hwif->OUTL(JCSTWTxtbl[offset][idx], scrcst_port); | 327 | out_be32((void __iomem *)scrcst_port, JCSTWTxtbl[offset][idx]); |
339 | jcactsel = jcactsel << 2 ; | 328 | jcactsel = jcactsel << 2; |
340 | hwif->OUTL( (hwif->INL( tdvhsel_port ) & ~TDVHSEL_SLAVE) | jcactsel, tdvhsel_port ); | 329 | out_be32((void __iomem *)tdvhsel_port, (in_be32((void __iomem *)tdvhsel_port) & ~TDVHSEL_SLAVE) | jcactsel); |
341 | } else { | 330 | } else { |
342 | hwif->OUTL(JCHDCTxtbl[offset][idx], mdmact_port); | 331 | out_be32((void __iomem *)mdmact_port, JCHDCTxtbl[offset][idx]); |
343 | hwif->OUTL(JCSTWTxtbl[offset][idx], mcrcst_port); | 332 | out_be32((void __iomem *)mcrcst_port, JCSTWTxtbl[offset][idx]); |
344 | hwif->OUTL( (hwif->INL( tdvhsel_port ) & ~TDVHSEL_MASTER) | jcactsel, tdvhsel_port ); | 333 | out_be32((void __iomem *)tdvhsel_port, (in_be32((void __iomem *)tdvhsel_port) & ~TDVHSEL_MASTER) | jcactsel); |
345 | } | 334 | } |
346 | reg = JCTSStbl[offset][idx] << 16 | JCENVTtbl[offset][idx]; | 335 | reg = JCTSStbl[offset][idx] << 16 | JCENVTtbl[offset][idx]; |
347 | hwif->OUTL(reg, udenvt_port); | 336 | out_be32((void __iomem *)udenvt_port, reg); |
348 | 337 | ||
349 | return ide_config_drive_speed(drive, speed); | 338 | return ide_config_drive_speed(drive, speed); |
350 | } | 339 | } |
@@ -395,6 +384,51 @@ static int scc_config_drive_for_dma(ide_drive_t *drive) | |||
395 | } | 384 | } |
396 | 385 | ||
397 | /** | 386 | /** |
387 | * scc_ide_dma_setup - begin a DMA phase | ||
388 | * @drive: target device | ||
389 | * | ||
390 | * Build an IDE DMA PRD (IDE speak for scatter gather table) | ||
391 | * and then set up the DMA transfer registers. | ||
392 | * | ||
393 | * Returns 0 on success. If a PIO fallback is required then 1 | ||
394 | * is returned. | ||
395 | */ | ||
396 | |||
397 | static int scc_dma_setup(ide_drive_t *drive) | ||
398 | { | ||
399 | ide_hwif_t *hwif = drive->hwif; | ||
400 | struct request *rq = HWGROUP(drive)->rq; | ||
401 | unsigned int reading; | ||
402 | u8 dma_stat; | ||
403 | |||
404 | if (rq_data_dir(rq)) | ||
405 | reading = 0; | ||
406 | else | ||
407 | reading = 1 << 3; | ||
408 | |||
409 | /* fall back to pio! */ | ||
410 | if (!ide_build_dmatable(drive, rq)) { | ||
411 | ide_map_sg(drive, rq); | ||
412 | return 1; | ||
413 | } | ||
414 | |||
415 | /* PRD table */ | ||
416 | out_be32((void __iomem *)hwif->dma_prdtable, hwif->dmatable_dma); | ||
417 | |||
418 | /* specify r/w */ | ||
419 | out_be32((void __iomem *)hwif->dma_command, reading); | ||
420 | |||
421 | /* read dma_status for INTR & ERROR flags */ | ||
422 | dma_stat = in_be32((void __iomem *)hwif->dma_status); | ||
423 | |||
424 | /* clear INTR & ERROR flags */ | ||
425 | out_be32((void __iomem *)hwif->dma_status, dma_stat|6); | ||
426 | drive->waiting_for_dma = 1; | ||
427 | return 0; | ||
428 | } | ||
429 | |||
430 | |||
431 | /** | ||
398 | * scc_ide_dma_end - Stop DMA | 432 | * scc_ide_dma_end - Stop DMA |
399 | * @drive: IDE drive | 433 | * @drive: IDE drive |
400 | * | 434 | * |
@@ -409,14 +443,13 @@ static int scc_ide_dma_end(ide_drive_t * drive) | |||
409 | u32 reg; | 443 | u32 reg; |
410 | 444 | ||
411 | while (1) { | 445 | while (1) { |
412 | reg = hwif->INL(intsts_port); | 446 | reg = in_be32((void __iomem *)intsts_port); |
413 | 447 | ||
414 | if (reg & INTSTS_SERROR) { | 448 | if (reg & INTSTS_SERROR) { |
415 | printk(KERN_WARNING "%s: SERROR\n", SCC_PATA_NAME); | 449 | printk(KERN_WARNING "%s: SERROR\n", SCC_PATA_NAME); |
416 | hwif->OUTL(INTSTS_SERROR|INTSTS_BMSINT, intsts_port); | 450 | out_be32((void __iomem *)intsts_port, INTSTS_SERROR|INTSTS_BMSINT); |
417 | 451 | ||
418 | hwif->OUTB(hwif->INB(hwif->dma_command) & ~QCHCD_IOS_SS, | 452 | out_be32((void __iomem *)hwif->dma_command, in_be32((void __iomem *)hwif->dma_command) & ~QCHCD_IOS_SS); |
419 | hwif->dma_command); | ||
420 | continue; | 453 | continue; |
421 | } | 454 | } |
422 | 455 | ||
@@ -424,56 +457,53 @@ static int scc_ide_dma_end(ide_drive_t * drive) | |||
424 | u32 maea0, maec0; | 457 | u32 maea0, maec0; |
425 | unsigned long ctl_base = hwif->config_data; | 458 | unsigned long ctl_base = hwif->config_data; |
426 | 459 | ||
427 | maea0 = hwif->INL(ctl_base + 0xF50); | 460 | maea0 = in_be32((void __iomem *)(ctl_base + 0xF50)); |
428 | maec0 = hwif->INL(ctl_base + 0xF54); | 461 | maec0 = in_be32((void __iomem *)(ctl_base + 0xF54)); |
429 | 462 | ||
430 | printk(KERN_WARNING "%s: PRERR [addr:%x cmd:%x]\n", SCC_PATA_NAME, maea0, maec0); | 463 | printk(KERN_WARNING "%s: PRERR [addr:%x cmd:%x]\n", SCC_PATA_NAME, maea0, maec0); |
431 | 464 | ||
432 | hwif->OUTL(INTSTS_PRERR|INTSTS_BMSINT, intsts_port); | 465 | out_be32((void __iomem *)intsts_port, INTSTS_PRERR|INTSTS_BMSINT); |
433 | 466 | ||
434 | hwif->OUTB(hwif->INB(hwif->dma_command) & ~QCHCD_IOS_SS, | 467 | out_be32((void __iomem *)hwif->dma_command, in_be32((void __iomem *)hwif->dma_command) & ~QCHCD_IOS_SS); |
435 | hwif->dma_command); | ||
436 | continue; | 468 | continue; |
437 | } | 469 | } |
438 | 470 | ||
439 | if (reg & INTSTS_RERR) { | 471 | if (reg & INTSTS_RERR) { |
440 | printk(KERN_WARNING "%s: Response Error\n", SCC_PATA_NAME); | 472 | printk(KERN_WARNING "%s: Response Error\n", SCC_PATA_NAME); |
441 | hwif->OUTL(INTSTS_RERR|INTSTS_BMSINT, intsts_port); | 473 | out_be32((void __iomem *)intsts_port, INTSTS_RERR|INTSTS_BMSINT); |
442 | 474 | ||
443 | hwif->OUTB(hwif->INB(hwif->dma_command) & ~QCHCD_IOS_SS, | 475 | out_be32((void __iomem *)hwif->dma_command, in_be32((void __iomem *)hwif->dma_command) & ~QCHCD_IOS_SS); |
444 | hwif->dma_command); | ||
445 | continue; | 476 | continue; |
446 | } | 477 | } |
447 | 478 | ||
448 | if (reg & INTSTS_ICERR) { | 479 | if (reg & INTSTS_ICERR) { |
449 | hwif->OUTB(hwif->INB(hwif->dma_command) & ~QCHCD_IOS_SS, | 480 | out_be32((void __iomem *)hwif->dma_command, in_be32((void __iomem *)hwif->dma_command) & ~QCHCD_IOS_SS); |
450 | hwif->dma_command); | ||
451 | 481 | ||
452 | printk(KERN_WARNING "%s: Illegal Configuration\n", SCC_PATA_NAME); | 482 | printk(KERN_WARNING "%s: Illegal Configuration\n", SCC_PATA_NAME); |
453 | hwif->OUTL(INTSTS_ICERR|INTSTS_BMSINT, intsts_port); | 483 | out_be32((void __iomem *)intsts_port, INTSTS_ICERR|INTSTS_BMSINT); |
454 | continue; | 484 | continue; |
455 | } | 485 | } |
456 | 486 | ||
457 | if (reg & INTSTS_BMSINT) { | 487 | if (reg & INTSTS_BMSINT) { |
458 | printk(KERN_WARNING "%s: Internal Bus Error\n", SCC_PATA_NAME); | 488 | printk(KERN_WARNING "%s: Internal Bus Error\n", SCC_PATA_NAME); |
459 | hwif->OUTL(INTSTS_BMSINT, intsts_port); | 489 | out_be32((void __iomem *)intsts_port, INTSTS_BMSINT); |
460 | 490 | ||
461 | ide_do_reset(drive); | 491 | ide_do_reset(drive); |
462 | continue; | 492 | continue; |
463 | } | 493 | } |
464 | 494 | ||
465 | if (reg & INTSTS_BMHE) { | 495 | if (reg & INTSTS_BMHE) { |
466 | hwif->OUTL(INTSTS_BMHE, intsts_port); | 496 | out_be32((void __iomem *)intsts_port, INTSTS_BMHE); |
467 | continue; | 497 | continue; |
468 | } | 498 | } |
469 | 499 | ||
470 | if (reg & INTSTS_ACTEINT) { | 500 | if (reg & INTSTS_ACTEINT) { |
471 | hwif->OUTL(INTSTS_ACTEINT, intsts_port); | 501 | out_be32((void __iomem *)intsts_port, INTSTS_ACTEINT); |
472 | continue; | 502 | continue; |
473 | } | 503 | } |
474 | 504 | ||
475 | if (reg & INTSTS_IOIRQS) { | 505 | if (reg & INTSTS_IOIRQS) { |
476 | hwif->OUTL(INTSTS_IOIRQS, intsts_port); | 506 | out_be32((void __iomem *)intsts_port, INTSTS_IOIRQS); |
477 | continue; | 507 | continue; |
478 | } | 508 | } |
479 | break; | 509 | break; |
@@ -617,13 +647,11 @@ static void __devinit init_mmio_iops_scc(ide_hwif_t *hwif) | |||
617 | 647 | ||
618 | hwif->INB = scc_ide_inb; | 648 | hwif->INB = scc_ide_inb; |
619 | hwif->INW = scc_ide_inw; | 649 | hwif->INW = scc_ide_inw; |
620 | hwif->INL = scc_ide_inl; | ||
621 | hwif->INSW = scc_ide_insw; | 650 | hwif->INSW = scc_ide_insw; |
622 | hwif->INSL = scc_ide_insl; | 651 | hwif->INSL = scc_ide_insl; |
623 | hwif->OUTB = scc_ide_outb; | 652 | hwif->OUTB = scc_ide_outb; |
624 | hwif->OUTBSYNC = scc_ide_outbsync; | 653 | hwif->OUTBSYNC = scc_ide_outbsync; |
625 | hwif->OUTW = scc_ide_outw; | 654 | hwif->OUTW = scc_ide_outw; |
626 | hwif->OUTL = scc_ide_outl; | ||
627 | hwif->OUTSW = scc_ide_outsw; | 655 | hwif->OUTSW = scc_ide_outsw; |
628 | hwif->OUTSL = scc_ide_outsl; | 656 | hwif->OUTSL = scc_ide_outsl; |
629 | 657 | ||
@@ -679,8 +707,10 @@ static void __devinit init_hwif_scc(ide_hwif_t *hwif) | |||
679 | hwif->dma_status = hwif->dma_base + 0x04; | 707 | hwif->dma_status = hwif->dma_base + 0x04; |
680 | hwif->dma_prdtable = hwif->dma_base + 0x08; | 708 | hwif->dma_prdtable = hwif->dma_base + 0x08; |
681 | 709 | ||
682 | hwif->OUTL(hwif->dmatable_dma, (hwif->dma_base + 0x018)); /* PTERADD */ | 710 | /* PTERADD */ |
711 | out_be32((void __iomem *)(hwif->dma_base + 0x018), hwif->dmatable_dma); | ||
683 | 712 | ||
713 | hwif->dma_setup = scc_dma_setup; | ||
684 | hwif->ide_dma_end = scc_ide_dma_end; | 714 | hwif->ide_dma_end = scc_ide_dma_end; |
685 | hwif->speedproc = scc_tune_chipset; | 715 | hwif->speedproc = scc_tune_chipset; |
686 | hwif->tuneproc = scc_tuneproc; | 716 | hwif->tuneproc = scc_tuneproc; |
@@ -689,7 +719,7 @@ static void __devinit init_hwif_scc(ide_hwif_t *hwif) | |||
689 | hwif->drives[0].autotune = IDE_TUNE_AUTO; | 719 | hwif->drives[0].autotune = IDE_TUNE_AUTO; |
690 | hwif->drives[1].autotune = IDE_TUNE_AUTO; | 720 | hwif->drives[1].autotune = IDE_TUNE_AUTO; |
691 | 721 | ||
692 | if (hwif->INL(hwif->config_data + 0xff0) & CCKCTRL_ATACLKOEN) { | 722 | if (in_be32((void __iomem *)(hwif->config_data + 0xff0)) & CCKCTRL_ATACLKOEN) { |
693 | hwif->ultra_mask = 0x7f; /* 133MHz */ | 723 | hwif->ultra_mask = 0x7f; /* 133MHz */ |
694 | } else { | 724 | } else { |
695 | hwif->ultra_mask = 0x3f; /* 100MHz */ | 725 | hwif->ultra_mask = 0x3f; /* 100MHz */ |