aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_acpi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/pata_acpi.c')
-rw-r--r--drivers/ata/pata_acpi.c67
1 files changed, 12 insertions, 55 deletions
diff --git a/drivers/ata/pata_acpi.c b/drivers/ata/pata_acpi.c
index e4542ab9c7f8..244098a80ce4 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 */
85static const unsigned int pio_cycle[7] = {
86 600, 383, 240, 180, 120, 100, 80
87};
88static const unsigned int mwdma_cycle[5] = {
89 480, 150, 120, 100, 80
90};
91static 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
104static unsigned long pacpi_discover_modes(struct ata_port *ap, struct ata_device *adev) 93static 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/**
@@ -180,12 +133,14 @@ static void pacpi_set_piomode(struct ata_port *ap, struct ata_device *adev)
180{ 133{
181 int unit = adev->devno; 134 int unit = adev->devno;
182 struct pata_acpi *acpi = ap->private_data; 135 struct pata_acpi *acpi = ap->private_data;
136 const struct ata_timing *t;
183 137
184 if (!(acpi->gtm.flags & 0x10)) 138 if (!(acpi->gtm.flags & 0x10))
185 unit = 0; 139 unit = 0;
186 140
187 /* Now stuff the nS values into the structure */ 141 /* Now stuff the nS values into the structure */
188 acpi->gtm.drive[unit].pio = pio_cycle[adev->pio_mode - XFER_PIO_0]; 142 t = ata_timing_find_mode(adev->pio_mode);
143 acpi->gtm.drive[unit].pio = t->cycle;
189 ata_acpi_stm(ap, &acpi->gtm); 144 ata_acpi_stm(ap, &acpi->gtm);
190 /* See what mode we actually got */ 145 /* See what mode we actually got */
191 ata_acpi_gtm(ap, &acpi->gtm); 146 ata_acpi_gtm(ap, &acpi->gtm);
@@ -201,16 +156,18 @@ static void pacpi_set_dmamode(struct ata_port *ap, struct ata_device *adev)
201{ 156{
202 int unit = adev->devno; 157 int unit = adev->devno;
203 struct pata_acpi *acpi = ap->private_data; 158 struct pata_acpi *acpi = ap->private_data;
159 const struct ata_timing *t;
204 160
205 if (!(acpi->gtm.flags & 0x10)) 161 if (!(acpi->gtm.flags & 0x10))
206 unit = 0; 162 unit = 0;
207 163
208 /* Now stuff the nS values into the structure */ 164 /* Now stuff the nS values into the structure */
165 t = ata_timing_find_mode(adev->dma_mode);
209 if (adev->dma_mode >= XFER_UDMA_0) { 166 if (adev->dma_mode >= XFER_UDMA_0) {
210 acpi->gtm.drive[unit].dma = udma_cycle[adev->dma_mode - XFER_UDMA_0]; 167 acpi->gtm.drive[unit].dma = t->udma;
211 acpi->gtm.flags |= (1 << (2 * unit)); 168 acpi->gtm.flags |= (1 << (2 * unit));
212 } else { 169 } else {
213 acpi->gtm.drive[unit].dma = mwdma_cycle[adev->dma_mode - XFER_MW_DMA_0]; 170 acpi->gtm.drive[unit].dma = t->cycle;
214 acpi->gtm.flags &= ~(1 << (2 * unit)); 171 acpi->gtm.flags &= ~(1 << (2 * unit));
215 } 172 }
216 ata_acpi_stm(ap, &acpi->gtm); 173 ata_acpi_stm(ap, &acpi->gtm);