aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ppc/pmac.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ppc/pmac.c')
-rw-r--r--drivers/ide/ppc/pmac.c71
1 files changed, 14 insertions, 57 deletions
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index c3432da78d52..2e19d6298536 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -430,10 +430,7 @@ pmac_ide_selectproc(ide_drive_t *drive)
430 pmac_ide_hwif_t *pmif = 430 pmac_ide_hwif_t *pmif =
431 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); 431 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
432 432
433 if (pmif == NULL) 433 if (drive->dn & 1)
434 return;
435
436 if (drive->select.b.unit & 0x01)
437 writel(pmif->timings[1], PMAC_IDE_REG(IDE_TIMING_CONFIG)); 434 writel(pmif->timings[1], PMAC_IDE_REG(IDE_TIMING_CONFIG));
438 else 435 else
439 writel(pmif->timings[0], PMAC_IDE_REG(IDE_TIMING_CONFIG)); 436 writel(pmif->timings[0], PMAC_IDE_REG(IDE_TIMING_CONFIG));
@@ -452,10 +449,7 @@ pmac_ide_kauai_selectproc(ide_drive_t *drive)
452 pmac_ide_hwif_t *pmif = 449 pmac_ide_hwif_t *pmif =
453 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); 450 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
454 451
455 if (pmif == NULL) 452 if (drive->dn & 1) {
456 return;
457
458 if (drive->select.b.unit & 0x01) {
459 writel(pmif->timings[1], PMAC_IDE_REG(IDE_KAUAI_PIO_CONFIG)); 453 writel(pmif->timings[1], PMAC_IDE_REG(IDE_KAUAI_PIO_CONFIG));
460 writel(pmif->timings[3], PMAC_IDE_REG(IDE_KAUAI_ULTRA_CONFIG)); 454 writel(pmif->timings[3], PMAC_IDE_REG(IDE_KAUAI_ULTRA_CONFIG));
461 } else { 455 } else {
@@ -475,9 +469,6 @@ pmac_ide_do_update_timings(ide_drive_t *drive)
475 pmac_ide_hwif_t *pmif = 469 pmac_ide_hwif_t *pmif =
476 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); 470 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
477 471
478 if (pmif == NULL)
479 return;
480
481 if (pmif->kind == controller_sh_ata6 || 472 if (pmif->kind == controller_sh_ata6 ||
482 pmif->kind == controller_un_ata6 || 473 pmif->kind == controller_un_ata6 ||
483 pmif->kind == controller_k2_ata6) 474 pmif->kind == controller_k2_ata6)
@@ -524,11 +515,8 @@ pmac_ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
524 unsigned accessTime, recTime; 515 unsigned accessTime, recTime;
525 unsigned int cycle_time; 516 unsigned int cycle_time;
526 517
527 if (pmif == NULL)
528 return;
529
530 /* which drive is it ? */ 518 /* which drive is it ? */
531 timings = &pmif->timings[drive->select.b.unit & 0x01]; 519 timings = &pmif->timings[drive->dn & 1];
532 t = *timings; 520 t = *timings;
533 521
534 cycle_time = ide_pio_cycle_time(drive, pio); 522 cycle_time = ide_pio_cycle_time(drive, pio);
@@ -805,9 +793,9 @@ static void pmac_ide_set_dma_mode(ide_drive_t *drive, const u8 speed)
805 ide_hwif_t *hwif = drive->hwif; 793 ide_hwif_t *hwif = drive->hwif;
806 pmac_ide_hwif_t *pmif = 794 pmac_ide_hwif_t *pmif =
807 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); 795 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
808 int unit = (drive->select.b.unit & 0x01);
809 int ret = 0; 796 int ret = 0;
810 u32 *timings, *timings2, tl[2]; 797 u32 *timings, *timings2, tl[2];
798 u8 unit = drive->dn & 1;
811 799
812 timings = &pmif->timings[unit]; 800 timings = &pmif->timings[unit];
813 timings2 = &pmif->timings[unit+2]; 801 timings2 = &pmif->timings[unit+2];
@@ -966,11 +954,11 @@ static void pmac_ide_init_dev(ide_drive_t *drive)
966 if (pmif->mediabay) { 954 if (pmif->mediabay) {
967#ifdef CONFIG_PMAC_MEDIABAY 955#ifdef CONFIG_PMAC_MEDIABAY
968 if (check_media_bay_by_base(pmif->regbase, MB_CD) == 0) { 956 if (check_media_bay_by_base(pmif->regbase, MB_CD) == 0) {
969 drive->noprobe = 0; 957 drive->dev_flags &= ~IDE_DFLAG_NOPROBE;
970 return; 958 return;
971 } 959 }
972#endif 960#endif
973 drive->noprobe = 1; 961 drive->dev_flags |= IDE_DFLAG_NOPROBE;
974 } 962 }
975} 963}
976 964
@@ -1535,18 +1523,6 @@ use_pio_instead:
1535 return 0; /* revert to PIO for this request */ 1523 return 0; /* revert to PIO for this request */
1536} 1524}
1537 1525
1538/* Teardown mappings after DMA has completed. */
1539static void
1540pmac_ide_destroy_dmatable (ide_drive_t *drive)
1541{
1542 ide_hwif_t *hwif = drive->hwif;
1543
1544 if (hwif->sg_nents) {
1545 ide_destroy_dmatable(drive);
1546 hwif->sg_nents = 0;
1547 }
1548}
1549
1550/* 1526/*
1551 * Prepare a DMA transfer. We build the DMA table, adjust the timings for 1527 * Prepare a DMA transfer. We build the DMA table, adjust the timings for
1552 * a read on KeyLargo ATA/66 and mark us as waiting for DMA completion 1528 * a read on KeyLargo ATA/66 and mark us as waiting for DMA completion
@@ -1558,12 +1534,7 @@ pmac_ide_dma_setup(ide_drive_t *drive)
1558 pmac_ide_hwif_t *pmif = 1534 pmac_ide_hwif_t *pmif =
1559 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); 1535 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
1560 struct request *rq = HWGROUP(drive)->rq; 1536 struct request *rq = HWGROUP(drive)->rq;
1561 u8 unit = (drive->select.b.unit & 0x01); 1537 u8 unit = drive->dn & 1, ata4 = (pmif->kind == controller_kl_ata4);
1562 u8 ata4;
1563
1564 if (pmif == NULL)
1565 return 1;
1566 ata4 = (pmif->kind == controller_kl_ata4);
1567 1538
1568 if (!pmac_ide_build_dmatable(drive, rq)) { 1539 if (!pmac_ide_build_dmatable(drive, rq)) {
1569 ide_map_sg(drive, rq); 1540 ide_map_sg(drive, rq);
@@ -1617,17 +1588,15 @@ pmac_ide_dma_end (ide_drive_t *drive)
1617 ide_hwif_t *hwif = drive->hwif; 1588 ide_hwif_t *hwif = drive->hwif;
1618 pmac_ide_hwif_t *pmif = 1589 pmac_ide_hwif_t *pmif =
1619 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); 1590 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
1620 volatile struct dbdma_regs __iomem *dma; 1591 volatile struct dbdma_regs __iomem *dma = pmif->dma_regs;
1621 u32 dstat; 1592 u32 dstat;
1622
1623 if (pmif == NULL)
1624 return 0;
1625 dma = pmif->dma_regs;
1626 1593
1627 drive->waiting_for_dma = 0; 1594 drive->waiting_for_dma = 0;
1628 dstat = readl(&dma->status); 1595 dstat = readl(&dma->status);
1629 writel(((RUN|WAKE|DEAD) << 16), &dma->control); 1596 writel(((RUN|WAKE|DEAD) << 16), &dma->control);
1630 pmac_ide_destroy_dmatable(drive); 1597
1598 ide_destroy_dmatable(drive);
1599
1631 /* verify good dma status. we don't check for ACTIVE beeing 0. We should... 1600 /* verify good dma status. we don't check for ACTIVE beeing 0. We should...
1632 * in theory, but with ATAPI decices doing buffer underruns, that would 1601 * in theory, but with ATAPI decices doing buffer underruns, that would
1633 * cause us to disable DMA, which isn't what we want 1602 * cause us to disable DMA, which isn't what we want
@@ -1647,13 +1616,9 @@ pmac_ide_dma_test_irq (ide_drive_t *drive)
1647 ide_hwif_t *hwif = drive->hwif; 1616 ide_hwif_t *hwif = drive->hwif;
1648 pmac_ide_hwif_t *pmif = 1617 pmac_ide_hwif_t *pmif =
1649 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); 1618 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
1650 volatile struct dbdma_regs __iomem *dma; 1619 volatile struct dbdma_regs __iomem *dma = pmif->dma_regs;
1651 unsigned long status, timeout; 1620 unsigned long status, timeout;
1652 1621
1653 if (pmif == NULL)
1654 return 0;
1655 dma = pmif->dma_regs;
1656
1657 /* We have to things to deal with here: 1622 /* We have to things to deal with here:
1658 * 1623 *
1659 * - The dbdma won't stop if the command was started 1624 * - The dbdma won't stop if the command was started
@@ -1672,9 +1637,6 @@ pmac_ide_dma_test_irq (ide_drive_t *drive)
1672 status = readl(&dma->status); 1637 status = readl(&dma->status);
1673 if (!(status & ACTIVE)) 1638 if (!(status & ACTIVE))
1674 return 1; 1639 return 1;
1675 if (!drive->waiting_for_dma)
1676 printk(KERN_WARNING "ide%d, ide_dma_test_irq \
1677 called while not waiting\n", HWIF(drive)->index);
1678 1640
1679 /* If dbdma didn't execute the STOP command yet, the 1641 /* If dbdma didn't execute the STOP command yet, the
1680 * active bit is still set. We consider that we aren't 1642 * active bit is still set. We consider that we aren't
@@ -1709,14 +1671,9 @@ pmac_ide_dma_lost_irq (ide_drive_t *drive)
1709 ide_hwif_t *hwif = drive->hwif; 1671 ide_hwif_t *hwif = drive->hwif;
1710 pmac_ide_hwif_t *pmif = 1672 pmac_ide_hwif_t *pmif =
1711 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); 1673 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
1712 volatile struct dbdma_regs __iomem *dma; 1674 volatile struct dbdma_regs __iomem *dma = pmif->dma_regs;
1713 unsigned long status; 1675 unsigned long status = readl(&dma->status);
1714
1715 if (pmif == NULL)
1716 return;
1717 dma = pmif->dma_regs;
1718 1676
1719 status = readl(&dma->status);
1720 printk(KERN_ERR "ide-pmac lost interrupt, dma status: %lx\n", status); 1677 printk(KERN_ERR "ide-pmac lost interrupt, dma status: %lx\n", status);
1721} 1678}
1722 1679