diff options
author | Tejun Heo <htejun@gmail.com> | 2007-12-18 02:33:03 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2008-01-23 05:24:12 -0500 |
commit | 7c77fa4d51b1480bcec2e898c94d6912fe063c16 (patch) | |
tree | d7d18fb22c8df2425878d02f4b415c06efa56457 /drivers/ata | |
parent | 9cde9ed151e170f2e2a530f7ec0032dfbe9f443b (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')
-rw-r--r-- | drivers/ata/libata-acpi.c | 78 | ||||
-rw-r--r-- | drivers/ata/pata_acpi.c | 66 |
2 files changed, 89 insertions, 55 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 */ | ||
445 | const unsigned int ata_acpi_pio_cycle[7] = { | ||
446 | 600, 383, 240, 180, 120, 100, 80 | ||
447 | }; | ||
448 | EXPORT_SYMBOL_GPL(ata_acpi_pio_cycle); | ||
449 | |||
450 | const unsigned int ata_acpi_mwdma_cycle[5] = { | ||
451 | 480, 150, 120, 100, 80 | ||
452 | }; | ||
453 | EXPORT_SYMBOL_GPL(ata_acpi_mwdma_cycle); | ||
454 | |||
455 | const unsigned int ata_acpi_udma_cycle[7] = { | ||
456 | 120, 80, 60, 45, 30, 20, 15 | ||
457 | }; | ||
458 | EXPORT_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 | */ | ||
473 | unsigned 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 | } | ||
520 | EXPORT_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 |
diff --git a/drivers/ata/pata_acpi.c b/drivers/ata/pata_acpi.c index e4542ab9c7f8..a4737a3d31cb 100644 --- a/drivers/ata/pata_acpi.c +++ b/drivers/ata/pata_acpi.c | |||
@@ -81,17 +81,6 @@ static void pacpi_error_handler(struct ata_port *ap) | |||
81 | NULL, ata_std_postreset); | 81 | NULL, ata_std_postreset); |
82 | } | 82 | } |
83 | 83 | ||
84 | /* Welcome to ACPI, bring a bucket */ | ||
85 | static const unsigned int pio_cycle[7] = { | ||
86 | 600, 383, 240, 180, 120, 100, 80 | ||
87 | }; | ||
88 | static const unsigned int mwdma_cycle[5] = { | ||
89 | 480, 150, 120, 100, 80 | ||
90 | }; | ||
91 | static const unsigned int udma_cycle[7] = { | ||
92 | 120, 80, 60, 45, 30, 20, 15 | ||
93 | }; | ||
94 | |||
95 | /** | 84 | /** |
96 | * pacpi_discover_modes - filter non ACPI modes | 85 | * pacpi_discover_modes - filter non ACPI modes |
97 | * @adev: ATA device | 86 | * @adev: ATA device |
@@ -103,56 +92,20 @@ static const unsigned int udma_cycle[7] = { | |||
103 | 92 | ||
104 | static unsigned long pacpi_discover_modes(struct ata_port *ap, struct ata_device *adev) | 93 | static unsigned long pacpi_discover_modes(struct ata_port *ap, struct ata_device *adev) |
105 | { | 94 | { |
106 | int unit = adev->devno; | ||
107 | struct pata_acpi *acpi = ap->private_data; | 95 | struct pata_acpi *acpi = ap->private_data; |
108 | int i; | ||
109 | u32 t; | ||
110 | unsigned long mask = (0x7f << ATA_SHIFT_UDMA) | (0x7 << ATA_SHIFT_MWDMA) | (0x1F << ATA_SHIFT_PIO); | ||
111 | |||
112 | struct ata_acpi_gtm probe; | 96 | struct ata_acpi_gtm probe; |
97 | unsigned int xfer_mask; | ||
113 | 98 | ||
114 | probe = acpi->gtm; | 99 | probe = acpi->gtm; |
115 | 100 | ||
116 | /* We always use the 0 slot for crap hardware */ | ||
117 | if (!(probe.flags & 0x10)) | ||
118 | unit = 0; | ||
119 | |||
120 | ata_acpi_gtm(ap, &probe); | 101 | ata_acpi_gtm(ap, &probe); |
121 | 102 | ||
122 | /* Start by scanning for PIO modes */ | 103 | xfer_mask = ata_acpi_gtm_xfermask(adev, &probe); |
123 | for (i = 0; i < 7; i++) { | ||
124 | t = probe.drive[unit].pio; | ||
125 | if (t <= pio_cycle[i]) { | ||
126 | mask |= (2 << (ATA_SHIFT_PIO + i)) - 1; | ||
127 | break; | ||
128 | } | ||
129 | } | ||
130 | 104 | ||
131 | /* See if we have MWDMA or UDMA data. We don't bother with MWDMA | 105 | if (xfer_mask & (0xF8 << ATA_SHIFT_UDMA)) |
132 | if UDMA is availabe as this means the BIOS set UDMA and our | ||
133 | error changedown if it works is UDMA to PIO anyway */ | ||
134 | if (probe.flags & (1 << (2 * unit))) { | ||
135 | /* MWDMA */ | ||
136 | for (i = 0; i < 5; i++) { | ||
137 | t = probe.drive[unit].dma; | ||
138 | if (t <= mwdma_cycle[i]) { | ||
139 | mask |= (2 << (ATA_SHIFT_MWDMA + i)) - 1; | ||
140 | break; | ||
141 | } | ||
142 | } | ||
143 | } else { | ||
144 | /* UDMA */ | ||
145 | for (i = 0; i < 7; i++) { | ||
146 | t = probe.drive[unit].dma; | ||
147 | if (t <= udma_cycle[i]) { | ||
148 | mask |= (2 << (ATA_SHIFT_UDMA + i)) - 1; | ||
149 | break; | ||
150 | } | ||
151 | } | ||
152 | } | ||
153 | if (mask & (0xF8 << ATA_SHIFT_UDMA)) | ||
154 | ap->cbl = ATA_CBL_PATA80; | 106 | ap->cbl = ATA_CBL_PATA80; |
155 | return mask; | 107 | |
108 | return xfer_mask; | ||
156 | } | 109 | } |
157 | 110 | ||
158 | /** | 111 | /** |
@@ -185,7 +138,8 @@ static void pacpi_set_piomode(struct ata_port *ap, struct ata_device *adev) | |||
185 | unit = 0; | 138 | unit = 0; |
186 | 139 | ||
187 | /* Now stuff the nS values into the structure */ | 140 | /* Now stuff the nS values into the structure */ |
188 | acpi->gtm.drive[unit].pio = pio_cycle[adev->pio_mode - XFER_PIO_0]; | 141 | acpi->gtm.drive[unit].pio = |
142 | ata_acpi_pio_cycle[adev->pio_mode - XFER_PIO_0]; | ||
189 | ata_acpi_stm(ap, &acpi->gtm); | 143 | ata_acpi_stm(ap, &acpi->gtm); |
190 | /* See what mode we actually got */ | 144 | /* See what mode we actually got */ |
191 | ata_acpi_gtm(ap, &acpi->gtm); | 145 | ata_acpi_gtm(ap, &acpi->gtm); |
@@ -207,10 +161,12 @@ static void pacpi_set_dmamode(struct ata_port *ap, struct ata_device *adev) | |||
207 | 161 | ||
208 | /* Now stuff the nS values into the structure */ | 162 | /* Now stuff the nS values into the structure */ |
209 | if (adev->dma_mode >= XFER_UDMA_0) { | 163 | if (adev->dma_mode >= XFER_UDMA_0) { |
210 | acpi->gtm.drive[unit].dma = udma_cycle[adev->dma_mode - XFER_UDMA_0]; | 164 | acpi->gtm.drive[unit].dma = |
165 | ata_acpi_udma_cycle[adev->dma_mode - XFER_UDMA_0]; | ||
211 | acpi->gtm.flags |= (1 << (2 * unit)); | 166 | acpi->gtm.flags |= (1 << (2 * unit)); |
212 | } else { | 167 | } else { |
213 | acpi->gtm.drive[unit].dma = mwdma_cycle[adev->dma_mode - XFER_MW_DMA_0]; | 168 | acpi->gtm.drive[unit].dma = |
169 | ata_acpi_mwdma_cycle[adev->dma_mode - XFER_MW_DMA_0]; | ||
214 | acpi->gtm.flags &= ~(1 << (2 * unit)); | 170 | acpi->gtm.flags &= ~(1 << (2 * unit)); |
215 | } | 171 | } |
216 | ata_acpi_stm(ap, &acpi->gtm); | 172 | ata_acpi_stm(ap, &acpi->gtm); |