diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ide/ppc/pmac.c | 102 |
1 files changed, 4 insertions, 98 deletions
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c index d6a1a9be58a7..ad58c7ecf858 100644 --- a/drivers/ide/ppc/pmac.c +++ b/drivers/ide/ppc/pmac.c | |||
@@ -1671,108 +1671,19 @@ pmac_ide_destroy_dmatable (ide_drive_t *drive) | |||
1671 | } | 1671 | } |
1672 | 1672 | ||
1673 | /* | 1673 | /* |
1674 | * Pick up best MDMA timing for the drive and apply it | ||
1675 | */ | ||
1676 | static int | ||
1677 | pmac_ide_mdma_enable(ide_drive_t *drive, u16 mode) | ||
1678 | { | ||
1679 | ide_hwif_t *hwif = HWIF(drive); | ||
1680 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data; | ||
1681 | u32 *timings, *timings2; | ||
1682 | u32 timing_local[2]; | ||
1683 | int ret; | ||
1684 | |||
1685 | /* which drive is it ? */ | ||
1686 | timings = &pmif->timings[drive->select.b.unit & 0x01]; | ||
1687 | timings2 = &pmif->timings[(drive->select.b.unit & 0x01) + 2]; | ||
1688 | |||
1689 | /* Copy timings to local image */ | ||
1690 | timing_local[0] = *timings; | ||
1691 | timing_local[1] = *timings2; | ||
1692 | |||
1693 | /* Calculate controller timings */ | ||
1694 | set_timings_mdma(drive, pmif->kind, &timing_local[0], &timing_local[1], mode); | ||
1695 | |||
1696 | /* Set feature on drive */ | ||
1697 | printk(KERN_INFO "%s: Enabling MultiWord DMA %d\n", drive->name, mode & 0xf); | ||
1698 | ret = pmac_ide_do_setfeature(drive, mode); | ||
1699 | if (ret) { | ||
1700 | printk(KERN_WARNING "%s: Failed !\n", drive->name); | ||
1701 | return 0; | ||
1702 | } | ||
1703 | |||
1704 | /* Apply timings to controller */ | ||
1705 | *timings = timing_local[0]; | ||
1706 | *timings2 = timing_local[1]; | ||
1707 | |||
1708 | return 1; | ||
1709 | } | ||
1710 | |||
1711 | /* | ||
1712 | * Pick up best UDMA timing for the drive and apply it | ||
1713 | */ | ||
1714 | static int | ||
1715 | pmac_ide_udma_enable(ide_drive_t *drive, u16 mode) | ||
1716 | { | ||
1717 | ide_hwif_t *hwif = HWIF(drive); | ||
1718 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data; | ||
1719 | u32 *timings, *timings2; | ||
1720 | u32 timing_local[2]; | ||
1721 | int ret; | ||
1722 | |||
1723 | /* which drive is it ? */ | ||
1724 | timings = &pmif->timings[drive->select.b.unit & 0x01]; | ||
1725 | timings2 = &pmif->timings[(drive->select.b.unit & 0x01) + 2]; | ||
1726 | |||
1727 | /* Copy timings to local image */ | ||
1728 | timing_local[0] = *timings; | ||
1729 | timing_local[1] = *timings2; | ||
1730 | |||
1731 | /* Calculate timings for interface */ | ||
1732 | if (pmif->kind == controller_un_ata6 | ||
1733 | || pmif->kind == controller_k2_ata6) | ||
1734 | ret = set_timings_udma_ata6( &timing_local[0], | ||
1735 | &timing_local[1], | ||
1736 | mode); | ||
1737 | else if (pmif->kind == controller_sh_ata6) | ||
1738 | ret = set_timings_udma_shasta( &timing_local[0], | ||
1739 | &timing_local[1], | ||
1740 | mode); | ||
1741 | else | ||
1742 | ret = set_timings_udma_ata4(&timing_local[0], mode); | ||
1743 | if (ret) | ||
1744 | return 0; | ||
1745 | |||
1746 | /* Set feature on drive */ | ||
1747 | printk(KERN_INFO "%s: Enabling Ultra DMA %d\n", drive->name, mode & 0x0f); | ||
1748 | ret = pmac_ide_do_setfeature(drive, mode); | ||
1749 | if (ret) { | ||
1750 | printk(KERN_WARNING "%s: Failed !\n", drive->name); | ||
1751 | return 0; | ||
1752 | } | ||
1753 | |||
1754 | /* Apply timings to controller */ | ||
1755 | *timings = timing_local[0]; | ||
1756 | *timings2 = timing_local[1]; | ||
1757 | |||
1758 | return 1; | ||
1759 | } | ||
1760 | |||
1761 | /* | ||
1762 | * Check what is the best DMA timing setting for the drive and | 1674 | * Check what is the best DMA timing setting for the drive and |
1763 | * call appropriate functions to apply it. | 1675 | * call appropriate functions to apply it. |
1764 | */ | 1676 | */ |
1765 | static int | 1677 | static int |
1766 | pmac_ide_dma_check(ide_drive_t *drive) | 1678 | pmac_ide_dma_check(ide_drive_t *drive) |
1767 | { | 1679 | { |
1768 | struct hd_driveid *id = drive->id; | ||
1769 | ide_hwif_t *hwif = HWIF(drive); | ||
1770 | int enable = 1; | 1680 | int enable = 1; |
1681 | |||
1771 | drive->using_dma = 0; | 1682 | drive->using_dma = 0; |
1772 | 1683 | ||
1773 | if (drive->media == ide_floppy) | 1684 | if (drive->media == ide_floppy) |
1774 | enable = 0; | 1685 | enable = 0; |
1775 | if (((id->capability & 1) == 0) && !__ide_dma_good_drive(drive)) | 1686 | if ((drive->id->capability & 1) == 0 && !__ide_dma_good_drive(drive)) |
1776 | enable = 0; | 1687 | enable = 0; |
1777 | if (__ide_dma_bad_drive(drive)) | 1688 | if (__ide_dma_bad_drive(drive)) |
1778 | enable = 0; | 1689 | enable = 0; |
@@ -1780,13 +1691,8 @@ pmac_ide_dma_check(ide_drive_t *drive) | |||
1780 | if (enable) { | 1691 | if (enable) { |
1781 | u8 mode = ide_max_dma_mode(drive); | 1692 | u8 mode = ide_max_dma_mode(drive); |
1782 | 1693 | ||
1783 | if (mode >= XFER_UDMA_0) | 1694 | if (mode && pmac_ide_tune_chipset(drive, mode) == 0) |
1784 | drive->using_dma = pmac_ide_udma_enable(drive, mode); | 1695 | drive->using_dma = 1; |
1785 | else if (mode >= XFER_MW_DMA_0) | ||
1786 | drive->using_dma = pmac_ide_mdma_enable(drive, mode); | ||
1787 | |||
1788 | /* Apply settings to controller */ | ||
1789 | pmac_ide_do_update_timings(drive); | ||
1790 | } | 1696 | } |
1791 | return 0; | 1697 | return 0; |
1792 | } | 1698 | } |