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/pata_acpi.c | |
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/pata_acpi.c')
-rw-r--r-- | drivers/ata/pata_acpi.c | 66 |
1 files changed, 11 insertions, 55 deletions
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); |