aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-acpi.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-12-18 02:33:03 -0500
committerJeff Garzik <jeff@garzik.org>2008-01-23 05:24:12 -0500
commit7c77fa4d51b1480bcec2e898c94d6912fe063c16 (patch)
treed7d18fb22c8df2425878d02f4b415c06efa56457 /drivers/ata/libata-acpi.c
parent9cde9ed151e170f2e2a530f7ec0032dfbe9f443b (diff)
libata: separate out ata_acpi_gtm_xfermask() from pacpi_discover_modes()
Finding out matching transfer mode from ACPI GTM values is useful for other purposes too. Separate out the function and timing tables from pata_acpi::pacpi_discover_modes(). Other than checking shared-configuration bit after doing ata_acpi_gtm() in pacpi_discover_modes() which should be safe, this patch doesn't introduce any behavior change. 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.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index ebc4dfcf2f19..d6697baf243d 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -441,6 +441,84 @@ 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/**
461 * ata_acpi_gtm_xfermode - determine xfermode from GTM parameter
462 * @dev: target device
463 * @gtm: GTM parameter to use
464 *
465 * Determine xfermask for @dev from @gtm.
466 *
467 * LOCKING:
468 * None.
469 *
470 * RETURNS:
471 * Determined xfermask.
472 */
473unsigned long ata_acpi_gtm_xfermask(struct ata_device *dev,
474 const struct ata_acpi_gtm *gtm)
475{
476 int unit, i;
477 u32 t;
478 unsigned long mask = (0x7f << ATA_SHIFT_UDMA) | (0x7 << ATA_SHIFT_MWDMA) | (0x1F << ATA_SHIFT_PIO);
479
480 /* we always use the 0 slot for crap hardware */
481 unit = dev->devno;
482 if (!(gtm->flags & 0x10))
483 unit = 0;
484
485 /* start by scanning for PIO modes */
486 for (i = 0; i < 7; i++) {
487 t = gtm->drive[unit].pio;
488 if (t <= ata_acpi_pio_cycle[i]) {
489 mask |= (2 << (ATA_SHIFT_PIO + i)) - 1;
490 break;
491 }
492 }
493
494 /* See if we have MWDMA or UDMA data. We don't bother with
495 * MWDMA if UDMA is available as this means the BIOS set UDMA
496 * and our error changedown if it works is UDMA to PIO anyway.
497 */
498 if (gtm->flags & (1 << (2 * unit))) {
499 /* MWDMA */
500 for (i = 0; i < 5; i++) {
501 t = gtm->drive[unit].dma;
502 if (t <= ata_acpi_mwdma_cycle[i]) {
503 mask |= (2 << (ATA_SHIFT_MWDMA + i)) - 1;
504 break;
505 }
506 }
507 } else {
508 /* UDMA */
509 for (i = 0; i < 7; i++) {
510 t = gtm->drive[unit].dma;
511 if (t <= ata_acpi_udma_cycle[i]) {
512 mask |= (2 << (ATA_SHIFT_UDMA + i)) - 1;
513 break;
514 }
515 }
516 }
517
518 return mask;
519}
520EXPORT_SYMBOL_GPL(ata_acpi_gtm_xfermask);
521
444/** 522/**
445 * ata_acpi_cbl_80wire - Check for 80 wire cable 523 * ata_acpi_cbl_80wire - Check for 80 wire cable
446 * @ap: Port to check 524 * @ap: Port to check