summaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-acpi.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-12-18 16:33:05 +0900
committerJeff Garzik <jeff@garzik.org>2008-01-23 05:24:12 -0500
commita0f79b929acaba10d4780acd2543eff20bf4b5b0 (patch)
treee637c1d9388a3991cd71c5be339c2ead59c460a2 /drivers/ata/libata-acpi.c
parent5df91a25df08d85700fef5fd59bb1873273e5ef5 (diff)
downloadlinux-a0f79b929acaba10d4780acd2543eff20bf4b5b0.tar.gz
linux-a0f79b929acaba10d4780acd2543eff20bf4b5b0.tar.bz2
linux-a0f79b929acaba10d4780acd2543eff20bf4b5b0.zip
libata: implement ata_timing_cycle2mode() and use it in libata-acpi and pata_acpi
libata-acpi is using separate timing tables for transfer modes although libata-core has the complete ata_timing table. Implement ata_timing_cycle2mode() to look for matching mode given transfer type and cycle duration and use it in libata-acpi and pata_acpi to replace private timing tables. Signed-off-by: Tejun Heo <htejun@gmail.com> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/libata-acpi.c')
-rw-r--r--drivers/ata/libata-acpi.c62
1 files changed, 15 insertions, 47 deletions
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index 9f0b208afcf5..a6f1a6b56d8c 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -441,22 +441,6 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf)
return rc;
}
-/* Welcome to ACPI, bring a bucket */
-const unsigned int ata_acpi_pio_cycle[7] = {
- 600, 383, 240, 180, 120, 100, 80
-};
-EXPORT_SYMBOL_GPL(ata_acpi_pio_cycle);
-
-const unsigned int ata_acpi_mwdma_cycle[5] = {
- 480, 150, 120, 100, 80
-};
-EXPORT_SYMBOL_GPL(ata_acpi_mwdma_cycle);
-
-const unsigned int ata_acpi_udma_cycle[7] = {
- 120, 80, 60, 45, 30, 20, 15
-};
-EXPORT_SYMBOL_GPL(ata_acpi_udma_cycle);
-
/**
* ata_acpi_gtm_xfermode - determine xfermode from GTM parameter
* @dev: target device
@@ -473,49 +457,33 @@ EXPORT_SYMBOL_GPL(ata_acpi_udma_cycle);
unsigned long ata_acpi_gtm_xfermask(struct ata_device *dev,
const struct ata_acpi_gtm *gtm)
{
- unsigned long pio_mask = 0, mwdma_mask = 0, udma_mask = 0;
- int unit, i;
- u32 t;
+ unsigned long xfer_mask = 0;
+ unsigned int type;
+ int unit;
+ u8 mode;
/* we always use the 0 slot for crap hardware */
unit = dev->devno;
if (!(gtm->flags & 0x10))
unit = 0;
- /* Values larger than the longest cycle results in 0 mask
- * while values equal to smaller than the shortest cycle
- * results in mask which includes all supported modes.
- * Disabled transfer method has the value of 0xffffffff which
- * will always result in 0 mask.
- */
-
- /* start by scanning for PIO modes */
- t = gtm->drive[unit].pio;
- for (i = 0; i < ARRAY_SIZE(ata_acpi_pio_cycle); i++)
- if (t > ata_acpi_pio_cycle[i])
- break;
- pio_mask = (1 << i) - 1;
+ /* PIO */
+ mode = ata_timing_cycle2mode(ATA_SHIFT_PIO, gtm->drive[unit].pio);
+ xfer_mask |= ata_xfer_mode2mask(mode);
/* See if we have MWDMA or UDMA data. We don't bother with
* MWDMA if UDMA is available as this means the BIOS set UDMA
* and our error changedown if it works is UDMA to PIO anyway.
*/
- t = gtm->drive[unit].dma;
- if (!(gtm->flags & (1 << (2 * unit)))) {
- /* MWDMA */
- for (i = 0; i < ARRAY_SIZE(ata_acpi_mwdma_cycle); i++)
- if (t > ata_acpi_mwdma_cycle[i])
- break;
- mwdma_mask = (1 << i) - 1;
- } else {
- /* UDMA */
- for (i = 0; i < ARRAY_SIZE(ata_acpi_udma_cycle); i++)
- if (t > ata_acpi_udma_cycle[i])
- break;
- udma_mask = (1 << i) - 1;
- }
+ if (!(gtm->flags & (1 << (2 * unit))))
+ type = ATA_SHIFT_MWDMA;
+ else
+ type = ATA_SHIFT_UDMA;
+
+ mode = ata_timing_cycle2mode(type, gtm->drive[unit].dma);
+ xfer_mask |= ata_xfer_mode2mask(mode);
- return ata_pack_xfermask(pio_mask, mwdma_mask, udma_mask);
+ return xfer_mask;
}
EXPORT_SYMBOL_GPL(ata_acpi_gtm_xfermask);