aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-acpi.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-12-18 02:33:05 -0500
committerJeff Garzik <jeff@garzik.org>2008-01-23 05:24:12 -0500
commita0f79b929acaba10d4780acd2543eff20bf4b5b0 (patch)
treee637c1d9388a3991cd71c5be339c2ead59c460a2 /drivers/ata/libata-acpi.c
parent5df91a25df08d85700fef5fd59bb1873273e5ef5 (diff)
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)
441 return rc; 441 return rc;
442} 442}
443 443
444/* Welcome to ACPI, bring a bucket */
445const unsigned int ata_acpi_pio_cycle[7] = {
446 600, 383, 240, 180, 120, 100, 80
447};
448EXPORT_SYMBOL_GPL(ata_acpi_pio_cycle);
449
450const unsigned int ata_acpi_mwdma_cycle[5] = {
451 480, 150, 120, 100, 80
452};
453EXPORT_SYMBOL_GPL(ata_acpi_mwdma_cycle);
454
455const unsigned int ata_acpi_udma_cycle[7] = {
456 120, 80, 60, 45, 30, 20, 15
457};
458EXPORT_SYMBOL_GPL(ata_acpi_udma_cycle);
459
460/** 444/**
461 * ata_acpi_gtm_xfermode - determine xfermode from GTM parameter 445 * ata_acpi_gtm_xfermode - determine xfermode from GTM parameter
462 * @dev: target device 446 * @dev: target device
@@ -473,49 +457,33 @@ EXPORT_SYMBOL_GPL(ata_acpi_udma_cycle);
473unsigned long ata_acpi_gtm_xfermask(struct ata_device *dev, 457unsigned long ata_acpi_gtm_xfermask(struct ata_device *dev,
474 const struct ata_acpi_gtm *gtm) 458 const struct ata_acpi_gtm *gtm)
475{ 459{
476 unsigned long pio_mask = 0, mwdma_mask = 0, udma_mask = 0; 460 unsigned long xfer_mask = 0;
477 int unit, i; 461 unsigned int type;
478 u32 t; 462 int unit;
463 u8 mode;
479 464
480 /* we always use the 0 slot for crap hardware */ 465 /* we always use the 0 slot for crap hardware */
481 unit = dev->devno; 466 unit = dev->devno;
482 if (!(gtm->flags & 0x10)) 467 if (!(gtm->flags & 0x10))
483 unit = 0; 468 unit = 0;
484 469
485 /* Values larger than the longest cycle results in 0 mask 470 /* PIO */
486 * while values equal to smaller than the shortest cycle 471 mode = ata_timing_cycle2mode(ATA_SHIFT_PIO, gtm->drive[unit].pio);
487 * results in mask which includes all supported modes. 472 xfer_mask |= ata_xfer_mode2mask(mode);
488 * Disabled transfer method has the value of 0xffffffff which
489 * will always result in 0 mask.
490 */
491
492 /* start by scanning for PIO modes */
493 t = gtm->drive[unit].pio;
494 for (i = 0; i < ARRAY_SIZE(ata_acpi_pio_cycle); i++)
495 if (t > ata_acpi_pio_cycle[i])
496 break;
497 pio_mask = (1 << i) - 1;
498 473
499 /* See if we have MWDMA or UDMA data. We don't bother with 474 /* See if we have MWDMA or UDMA data. We don't bother with
500 * MWDMA if UDMA is available as this means the BIOS set UDMA 475 * MWDMA if UDMA is available as this means the BIOS set UDMA
501 * and our error changedown if it works is UDMA to PIO anyway. 476 * and our error changedown if it works is UDMA to PIO anyway.
502 */ 477 */
503 t = gtm->drive[unit].dma; 478 if (!(gtm->flags & (1 << (2 * unit))))
504 if (!(gtm->flags & (1 << (2 * unit)))) { 479 type = ATA_SHIFT_MWDMA;
505 /* MWDMA */ 480 else
506 for (i = 0; i < ARRAY_SIZE(ata_acpi_mwdma_cycle); i++) 481 type = ATA_SHIFT_UDMA;
507 if (t > ata_acpi_mwdma_cycle[i]) 482
508 break; 483 mode = ata_timing_cycle2mode(type, gtm->drive[unit].dma);
509 mwdma_mask = (1 << i) - 1; 484 xfer_mask |= ata_xfer_mode2mask(mode);
510 } else {
511 /* UDMA */
512 for (i = 0; i < ARRAY_SIZE(ata_acpi_udma_cycle); i++)
513 if (t > ata_acpi_udma_cycle[i])
514 break;
515 udma_mask = (1 << i) - 1;
516 }
517 485
518 return ata_pack_xfermask(pio_mask, mwdma_mask, udma_mask); 486 return xfer_mask;
519} 487}
520EXPORT_SYMBOL_GPL(ata_acpi_gtm_xfermask); 488EXPORT_SYMBOL_GPL(ata_acpi_gtm_xfermask);
521 489