1/*-
2 * Copyright (c) 1998,1999 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 11 unchanged lines hidden (view full) ---
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $FreeBSD: head/sys/dev/ata/ata-dma.c 52918 1999-11-06 16:50:21Z sos $
29 */
30
31#include "pci.h"
32#include "apm.h"
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/buf.h>
36#include <sys/malloc.h>
--- 58 unchanged lines hidden (view full) ---
95
96 switch (type = pci_get_devid(scp->dev)) {
97
98 case 0x71118086: /* Intel PIIX4 */
99 if (udmamode >= 2) {
100 int32_t mask48, new48;
101
102 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
103 ATA_UDMA2, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
104 if (bootverbose)
105 printf("ata%d: %s: %s setting up UDMA2 mode on PIIX4 chip\n",
106 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
107 (error) ? "failed" : "success");
108 if (error)
109 break;
110 devno = (scp->unit << 1) + ((device == ATA_MASTER) ? 0 : 1);
111 mask48 = (1 << devno) + (3 << (16 + (devno << 2)));
--- 22 unchanged lines hidden (view full) ---
134 new44 &= ~0x000000f0;
135 new44 |= ((new40&0x30000000)>>22)|((new40&0x03000000)>>20);
136 }
137 new40 |= 0x40004000;
138 pci_write_config(scp->dev, 0x40, new40, 4);
139 pci_write_config(scp->dev, 0x44, new44, 4);
140 }
141 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
142 ATA_WDMA2, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
143 if (bootverbose)
144 printf("ata%d: %s: %s setting up WDMA2 mode on PIIX4 chip\n",
145 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
146 (error) ? "failed" : "success");
147 if (error)
148 break;
149 if (device == ATA_MASTER) {
150 mask40 = 0x0000330f;
--- 23 unchanged lines hidden (view full) ---
174 }
175 break;
176
177 case 0x12308086: /* Intel PIIX */
178 /* probably not worth the trouble */
179 break;
180
181 case 0x522910b9: /* AcerLabs Aladdin IV/V */
182 /* the Aladdin has to be setup specially for ATAPI devices */
183 if ((device == ATA_MASTER && scp->devices & ATA_ATAPI_MASTER) ||
184 (device == ATA_SLAVE && scp->devices & ATA_ATAPI_SLAVE)) {
185 int8_t word53 = pci_read_config(scp->dev, 0x53, 1);
186
187 /* set atapi fifo, this should always work */
188 pci_write_config(scp->dev, 0x53, (word53 & ~0x01) | 0x02, 1);
189
190 /* if both master & slave are atapi devices dont allow DMA */
191 if (scp->devices & ATA_ATAPI_MASTER &&
192 scp->devices & ATA_ATAPI_SLAVE) {
193 printf("ata%d: Aladdin: two atapi devices on this channel, "
194 "DMA disabled\n", scp->lun);
195 break;
196 }
197 /* if needed set atapi fifo & dma */
198 if ((udmamode >=2) || (wdmamode >= 2 && apiomode >= 4)) {
199 pci_write_config(scp->dev, 0x53, word53 | 0x03, 1);
200 scp->flags |= ATA_ATAPI_DMA_RO;
201 if (device == ATA_MASTER)
202 outb(scp->bmaddr + ATA_BMSTAT_PORT,
203 inb(scp->bmaddr + ATA_BMSTAT_PORT) |
204 ATA_BMSTAT_DMA_MASTER);
205 else
206 outb(scp->bmaddr + ATA_BMSTAT_PORT,
207 inb(scp->bmaddr + ATA_BMSTAT_PORT) |
208 ATA_BMSTAT_DMA_SLAVE);
209 }
210 }
211 if (udmamode >=2) {
212 int32_t word54 = pci_read_config(scp->dev, 0x54, 4);
213
214 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
215 ATA_UDMA2, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
216 if (bootverbose)
217 printf("ata%d: %s: %s setting up UDMA2 mode on Aladdin chip\n",
218 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
219 (error) ? "failed" : "success");
220 if (error)
221 break;
222 word54 |= 0x5555;
223 word54 |= (0x0a << (16 + (scp->unit << 3) + (device << 2)));
224 pci_write_config(scp->dev, 0x54, word54, 4);
225 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA2;
226 return 0;
227
228 }
229 else if (wdmamode >= 2 && apiomode >= 4) {
230 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
231 ATA_WDMA2, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
232 if (bootverbose)
233 printf("ata%d: %s: %s setting up WDMA2 mode on Aladdin chip\n",
234 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
235 (error) ? "failed" : "success");
236 if (error)
237 break;
238 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_WDMA2;
239 return 0;
240 }
241 break;
242
243 case 0x4d33105a: /* Promise Ultra33 / FastTrak33 controllers */
244 case 0x4d38105a: /* Promise Ultra66 / FastTrak66 controllers */
245 /* the Promise can only do DMA on ATA disks not on ATAPI devices */
246 if ((device == ATA_MASTER && scp->devices & ATA_ATAPI_MASTER) ||
247 (device == ATA_SLAVE && scp->devices & ATA_ATAPI_SLAVE))
248 break;
249
250 devno = (scp->unit << 1) + ((device == ATA_MASTER) ? 0 : 1);
251 if (udmamode >=4 && type == 0x4d38105a &&
252 !(pci_read_config(scp->dev, 0x50, 2)&(scp->unit ? 1<<11 : 1<<10))) {
253 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
254 ATA_UDMA4, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
255 if (bootverbose)
256 printf("ata%d: %s: %s setting up UDMA4 mode on Promise chip\n",
257 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
258 (error) ? "failed" : "success");
259 if (error)
260 break;
261 outb(scp->bmaddr + 0x11, inl(scp->bmaddr + 0x11) | scp->unit ? 8:2);
262 pci_write_config(scp->dev, 0x60 + (devno << 2), 0x004127f3, 4);
263 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA4;
264 return 0;
265 }
266 if (udmamode >=2) {
267 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
268 ATA_UDMA2, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
269 if (bootverbose)
270 printf("ata%d: %s: %s setting up UDMA2 mode on Promise chip\n",
271 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
272 (error) ? "failed" : "success");
273 if (error)
274 break;
275 pci_write_config(scp->dev, 0x60 + (devno << 2), 0x004127f3, 4);
276 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA2;
277 return 0;
278 }
279 else if (wdmamode >= 2 && apiomode >= 4) {
280 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
281 ATA_WDMA2, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
282 if (bootverbose)
283 printf("ata%d: %s: %s setting up WDMA2 mode on Promise chip\n",
284 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
285 (error) ? "failed" : "success");
286 if (error)
287 break;
288 pci_write_config(scp->dev, 0x60 + (devno << 2), 0x004367f3, 4);
289 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_WDMA2;
--- 11 unchanged lines hidden (view full) ---
301 /* punt on ATAPI devices for now */
302 if ((device == ATA_MASTER && scp->devices & ATA_ATAPI_MASTER) ||
303 (device == ATA_SLAVE && scp->devices & ATA_ATAPI_SLAVE))
304 break;
305
306 devno = (device == ATA_MASTER) ? 0 : 1;
307 if (udmamode >=4 && !(pci_read_config(scp->dev, 0x5a, 1) & 0x2)) {
308 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
309 ATA_UDMA4, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
310 if (bootverbose)
311 printf("ata%d: %s: %s setting up UDMA4 mode on HPT366 chip\n",
312 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
313 (error) ? "failed" : "success");
314 if (error)
315 break;
316 hpt366_timing(scp, device, ATA_MODE_UDMA4);
317 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA4;
318 return 0;
319 }
320 if (udmamode >=3 && !(pci_read_config(scp->dev, 0x5a, 1) & 0x2)) {
321 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
322 ATA_UDMA3, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
323 if (bootverbose)
324 printf("ata%d: %s: %s setting up UDMA3 mode on HPT366 chip\n",
325 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
326 (error) ? "failed" : "success");
327 if (error)
328 break;
329 hpt366_timing(scp, device, ATA_MODE_UDMA3);
330 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA3;
331 return 0;
332 }
333 if (udmamode >=2) {
334 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
335 ATA_UDMA2, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
336 if (bootverbose)
337 printf("ata%d: %s: %s setting up UDMA2 mode on HPT366 chip\n",
338 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
339 (error) ? "failed" : "success");
340 if (error)
341 break;
342 hpt366_timing(scp, device, ATA_MODE_UDMA2);
343 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA2;
344 return 0;
345 }
346 else if (wdmamode >= 2 && apiomode >= 4) {
347 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
348 ATA_WDMA2, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
349 if (bootverbose)
350 printf("ata%d: %s: %s setting up WDMA2 mode on HPT366 chip\n",
351 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
352 (error) ? "failed" : "success");
353 if (error)
354 break;
355 hpt366_timing(scp, device, ATA_MODE_WDMA2);
356 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_WDMA2;
--- 14 unchanged lines hidden (view full) ---
371 break;
372
373 /* well, we have no support for this, but try anyways */
374 if (((wdmamode >= 2 && apiomode >= 4) || udmamode >= 2) &&
375 (inb(scp->bmaddr + ATA_BMSTAT_PORT) &
376 ((device == ATA_MASTER) ?
377 ATA_BMSTAT_DMA_SLAVE : ATA_BMSTAT_DMA_MASTER))) {
378 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
379 ATA_WDMA2, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
380 if (bootverbose)
381 printf("ata%d: %s: %s setting up WDMA2 mode on generic chip\n",
382 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
383 (error) ? "failed" : "success");
384 if (error)
385 break;
386 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_WDMA2;
387 return 0;
--- 171 unchanged lines hidden ---
2 * Copyright (c) 1998,1999 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 11 unchanged lines hidden (view full) ---
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $FreeBSD: head/sys/dev/ata/ata-dma.c 52918 1999-11-06 16:50:21Z sos $
29 */
30
31#include "pci.h"
32#include "apm.h"
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/buf.h>
36#include <sys/malloc.h>
--- 58 unchanged lines hidden (view full) ---
95
96 switch (type = pci_get_devid(scp->dev)) {
97
98 case 0x71118086: /* Intel PIIX4 */
99 if (udmamode >= 2) {
100 int32_t mask48, new48;
101
102 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
103 ATA_UDMA2, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
104 if (bootverbose)
105 printf("ata%d: %s: %s setting up UDMA2 mode on PIIX4 chip\n",
106 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
107 (error) ? "failed" : "success");
108 if (error)
109 break;
110 devno = (scp->unit << 1) + ((device == ATA_MASTER) ? 0 : 1);
111 mask48 = (1 << devno) + (3 << (16 + (devno << 2)));
--- 22 unchanged lines hidden (view full) ---
134 new44 &= ~0x000000f0;
135 new44 |= ((new40&0x30000000)>>22)|((new40&0x03000000)>>20);
136 }
137 new40 |= 0x40004000;
138 pci_write_config(scp->dev, 0x40, new40, 4);
139 pci_write_config(scp->dev, 0x44, new44, 4);
140 }
141 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
142 ATA_WDMA2, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
143 if (bootverbose)
144 printf("ata%d: %s: %s setting up WDMA2 mode on PIIX4 chip\n",
145 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
146 (error) ? "failed" : "success");
147 if (error)
148 break;
149 if (device == ATA_MASTER) {
150 mask40 = 0x0000330f;
--- 23 unchanged lines hidden (view full) ---
174 }
175 break;
176
177 case 0x12308086: /* Intel PIIX */
178 /* probably not worth the trouble */
179 break;
180
181 case 0x522910b9: /* AcerLabs Aladdin IV/V */
182 /* the Aladdin has to be setup specially for ATAPI devices */
183 if ((device == ATA_MASTER && scp->devices & ATA_ATAPI_MASTER) ||
184 (device == ATA_SLAVE && scp->devices & ATA_ATAPI_SLAVE)) {
185 int8_t word53 = pci_read_config(scp->dev, 0x53, 1);
186
187 /* set atapi fifo, this should always work */
188 pci_write_config(scp->dev, 0x53, (word53 & ~0x01) | 0x02, 1);
189
190 /* if both master & slave are atapi devices dont allow DMA */
191 if (scp->devices & ATA_ATAPI_MASTER &&
192 scp->devices & ATA_ATAPI_SLAVE) {
193 printf("ata%d: Aladdin: two atapi devices on this channel, "
194 "DMA disabled\n", scp->lun);
195 break;
196 }
197 /* if needed set atapi fifo & dma */
198 if ((udmamode >=2) || (wdmamode >= 2 && apiomode >= 4)) {
199 pci_write_config(scp->dev, 0x53, word53 | 0x03, 1);
200 scp->flags |= ATA_ATAPI_DMA_RO;
201 if (device == ATA_MASTER)
202 outb(scp->bmaddr + ATA_BMSTAT_PORT,
203 inb(scp->bmaddr + ATA_BMSTAT_PORT) |
204 ATA_BMSTAT_DMA_MASTER);
205 else
206 outb(scp->bmaddr + ATA_BMSTAT_PORT,
207 inb(scp->bmaddr + ATA_BMSTAT_PORT) |
208 ATA_BMSTAT_DMA_SLAVE);
209 }
210 }
211 if (udmamode >=2) {
212 int32_t word54 = pci_read_config(scp->dev, 0x54, 4);
213
214 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
215 ATA_UDMA2, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
216 if (bootverbose)
217 printf("ata%d: %s: %s setting up UDMA2 mode on Aladdin chip\n",
218 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
219 (error) ? "failed" : "success");
220 if (error)
221 break;
222 word54 |= 0x5555;
223 word54 |= (0x0a << (16 + (scp->unit << 3) + (device << 2)));
224 pci_write_config(scp->dev, 0x54, word54, 4);
225 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA2;
226 return 0;
227
228 }
229 else if (wdmamode >= 2 && apiomode >= 4) {
230 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
231 ATA_WDMA2, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
232 if (bootverbose)
233 printf("ata%d: %s: %s setting up WDMA2 mode on Aladdin chip\n",
234 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
235 (error) ? "failed" : "success");
236 if (error)
237 break;
238 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_WDMA2;
239 return 0;
240 }
241 break;
242
243 case 0x4d33105a: /* Promise Ultra33 / FastTrak33 controllers */
244 case 0x4d38105a: /* Promise Ultra66 / FastTrak66 controllers */
245 /* the Promise can only do DMA on ATA disks not on ATAPI devices */
246 if ((device == ATA_MASTER && scp->devices & ATA_ATAPI_MASTER) ||
247 (device == ATA_SLAVE && scp->devices & ATA_ATAPI_SLAVE))
248 break;
249
250 devno = (scp->unit << 1) + ((device == ATA_MASTER) ? 0 : 1);
251 if (udmamode >=4 && type == 0x4d38105a &&
252 !(pci_read_config(scp->dev, 0x50, 2)&(scp->unit ? 1<<11 : 1<<10))) {
253 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
254 ATA_UDMA4, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
255 if (bootverbose)
256 printf("ata%d: %s: %s setting up UDMA4 mode on Promise chip\n",
257 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
258 (error) ? "failed" : "success");
259 if (error)
260 break;
261 outb(scp->bmaddr + 0x11, inl(scp->bmaddr + 0x11) | scp->unit ? 8:2);
262 pci_write_config(scp->dev, 0x60 + (devno << 2), 0x004127f3, 4);
263 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA4;
264 return 0;
265 }
266 if (udmamode >=2) {
267 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
268 ATA_UDMA2, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
269 if (bootverbose)
270 printf("ata%d: %s: %s setting up UDMA2 mode on Promise chip\n",
271 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
272 (error) ? "failed" : "success");
273 if (error)
274 break;
275 pci_write_config(scp->dev, 0x60 + (devno << 2), 0x004127f3, 4);
276 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA2;
277 return 0;
278 }
279 else if (wdmamode >= 2 && apiomode >= 4) {
280 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
281 ATA_WDMA2, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
282 if (bootverbose)
283 printf("ata%d: %s: %s setting up WDMA2 mode on Promise chip\n",
284 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
285 (error) ? "failed" : "success");
286 if (error)
287 break;
288 pci_write_config(scp->dev, 0x60 + (devno << 2), 0x004367f3, 4);
289 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_WDMA2;
--- 11 unchanged lines hidden (view full) ---
301 /* punt on ATAPI devices for now */
302 if ((device == ATA_MASTER && scp->devices & ATA_ATAPI_MASTER) ||
303 (device == ATA_SLAVE && scp->devices & ATA_ATAPI_SLAVE))
304 break;
305
306 devno = (device == ATA_MASTER) ? 0 : 1;
307 if (udmamode >=4 && !(pci_read_config(scp->dev, 0x5a, 1) & 0x2)) {
308 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
309 ATA_UDMA4, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
310 if (bootverbose)
311 printf("ata%d: %s: %s setting up UDMA4 mode on HPT366 chip\n",
312 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
313 (error) ? "failed" : "success");
314 if (error)
315 break;
316 hpt366_timing(scp, device, ATA_MODE_UDMA4);
317 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA4;
318 return 0;
319 }
320 if (udmamode >=3 && !(pci_read_config(scp->dev, 0x5a, 1) & 0x2)) {
321 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
322 ATA_UDMA3, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
323 if (bootverbose)
324 printf("ata%d: %s: %s setting up UDMA3 mode on HPT366 chip\n",
325 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
326 (error) ? "failed" : "success");
327 if (error)
328 break;
329 hpt366_timing(scp, device, ATA_MODE_UDMA3);
330 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA3;
331 return 0;
332 }
333 if (udmamode >=2) {
334 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
335 ATA_UDMA2, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
336 if (bootverbose)
337 printf("ata%d: %s: %s setting up UDMA2 mode on HPT366 chip\n",
338 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
339 (error) ? "failed" : "success");
340 if (error)
341 break;
342 hpt366_timing(scp, device, ATA_MODE_UDMA2);
343 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA2;
344 return 0;
345 }
346 else if (wdmamode >= 2 && apiomode >= 4) {
347 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
348 ATA_WDMA2, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
349 if (bootverbose)
350 printf("ata%d: %s: %s setting up WDMA2 mode on HPT366 chip\n",
351 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
352 (error) ? "failed" : "success");
353 if (error)
354 break;
355 hpt366_timing(scp, device, ATA_MODE_WDMA2);
356 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_WDMA2;
--- 14 unchanged lines hidden (view full) ---
371 break;
372
373 /* well, we have no support for this, but try anyways */
374 if (((wdmamode >= 2 && apiomode >= 4) || udmamode >= 2) &&
375 (inb(scp->bmaddr + ATA_BMSTAT_PORT) &
376 ((device == ATA_MASTER) ?
377 ATA_BMSTAT_DMA_SLAVE : ATA_BMSTAT_DMA_MASTER))) {
378 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
379 ATA_WDMA2, ATA_C_FEA_SETXFER, ATA_WAIT_READY);
380 if (bootverbose)
381 printf("ata%d: %s: %s setting up WDMA2 mode on generic chip\n",
382 scp->lun, (device == ATA_MASTER) ? "master" : "slave",
383 (error) ? "failed" : "success");
384 if (error)
385 break;
386 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_WDMA2;
387 return 0;
--- 171 unchanged lines hidden ---