1/*-
2 * Copyright (c) 1998,1999,2000,2001 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 75516 2001-04-14 18:33:08Z sos $
29 */
30
31#include "pci.h"
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/ata.h>
35#include <sys/bio.h>
36#include <sys/malloc.h>
--- 65 unchanged lines hidden (view full) ---
102 if (udmamode > 2 && !ATA_PARAM(scp, device)->cblid) {
103 ata_printf(scp, device,
104 "DMA limited to UDMA33, non-ATA66 compliant cable\n");
105 udmamode = 2;
106 }
107
108 switch (scp->chiptype) {
109
110 case 0x244b8086: /* Intel ICH2 */
111 if (udmamode >= 5) {
112 int32_t mask48, new48;
113 int16_t word54;
114
115 word54 = pci_read_config(parent, 0x54, 2);
116 if (word54 & (0x10 << devno)) {
117 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
118 ATA_UDMA5, ATA_C_F_SETXFER,ATA_WAIT_READY);
119 if (bootverbose)
120 ata_printf(scp, device,
121 "%s setting UDMA5 on ICH2 chip\n",
122 (error) ? "failed" : "success");
123 if (!error) {
124 mask48 = (1 << devno) + (3 << (16 + (devno << 2)));
125 new48 = (1 << devno) + (1 << (16 + (devno << 2)));
126 pci_write_config(parent, 0x48,
127 (pci_read_config(parent, 0x48, 4) &
128 ~mask48) | new48, 4);
129 pci_write_config(parent, 0x54, word54 | (0x1000<<devno), 2);
--- 13 unchanged lines hidden (view full) ---
143 int16_t word54;
144
145 word54 = pci_read_config(parent, 0x54, 2);
146 if (word54 & (0x10 << devno)) {
147 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
148 ATA_UDMA4, ATA_C_F_SETXFER,ATA_WAIT_READY);
149 if (bootverbose)
150 ata_printf(scp, device,
151 "%s setting UDMA4 on ICH%s chip\n",
152 (error) ? "failed" : "success",
153 (scp->chiptype == 0x244b8086) ? "2" : "");
154 if (!error) {
155 mask48 = (1 << devno) + (3 << (16 + (devno << 2)));
156 new48 = (1 << devno) + (2 << (16 + (devno << 2)));
157 pci_write_config(parent, 0x48,
158 (pci_read_config(parent, 0x48, 4) &
159 ~mask48) | new48, 4);
160 pci_write_config(parent, 0x54, word54 | (1 << devno), 2);
161 scp->mode[ATA_DEV(device)] = ATA_UDMA4;
--- 10 unchanged lines hidden (view full) ---
172 case 0x71998086: /* Intel PIIX4e */
173 case 0x24218086: /* Intel ICH0 */
174 if (udmamode >= 2) {
175 int32_t mask48, new48;
176
177 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
178 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);
179 if (bootverbose)
180 ata_printf(scp, device, "%s setting UDMA2 on %s chip\n",
181 (error) ? "failed" : "success",
182 (scp->chiptype == 0x244b8086) ? "ICH2" :
183 (scp->chiptype == 0x24118086) ? "ICH" :
184 (scp->chiptype == 0x24218086) ? "ICH0" :"PIIX4");
185 if (!error) {
186 mask48 = (1 << devno) + (3 << (16 + (devno << 2)));
187 new48 = (1 << devno) + (2 << (16 + (devno << 2)));
188 pci_write_config(parent, 0x48,
189 (pci_read_config(parent, 0x48, 4) &
190 ~mask48) | new48, 4);
191 scp->mode[ATA_DEV(device)] = ATA_UDMA2;
192 return;
--- 22 unchanged lines hidden (view full) ---
215 }
216 new40 |= 0x40004000;
217 pci_write_config(parent, 0x40, new40, 4);
218 pci_write_config(parent, 0x44, new44, 4);
219 }
220 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
221 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);
222 if (bootverbose)
223 ata_printf(scp, device, "%s setting WDMA2 on %s chip\n",
224 (error) ? "failed" : "success",
225 (scp->chiptype == 0x244b8086) ? "ICH2" :
226 (scp->chiptype == 0x24118086) ? "ICH" :
227 (scp->chiptype == 0x24218086) ? "ICH0" :
228 (scp->chiptype == 0x70108086) ? "PIIX3":"PIIX4");
229 if (!error) {
230 if (device == ATA_MASTER) {
231 mask40 = 0x0000330f;
232 new40 = 0x00002307;
233 mask44 = 0;
234 new44 = 0;
235 }
236 else {
--- 32 unchanged lines hidden (view full) ---
269 if (!((word40 & 0x3300) == 0x2300 &&
270 ((word40 >> (device == ATA_MASTER ? 0 : 4)) & 1) == 1))
271 break;
272
273 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
274 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);
275 if (bootverbose)
276 ata_printf(scp, device,
277 "%s setting WDMA2 on PIIX chip\n",
278 (error) ? "failed" : "success");
279 if (!error) {
280 scp->mode[ATA_DEV(device)] = ATA_WDMA2;
281 return;
282 }
283 }
284 break;
285
--- 5 unchanged lines hidden (view full) ---
291 "Aladdin: two atapi devices on this channel, no DMA\n");
292 break;
293 }
294 if (udmamode >= 5 && pci_get_revid(parent) >= 0xC4) {
295 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
296 ATA_UDMA5, ATA_C_F_SETXFER, ATA_WAIT_READY);
297 if (bootverbose)
298 ata_printf(scp, device,
299 "%s setting UDMA5 on Aladdin chip\n",
300 (error) ? "failed" : "success");
301 if (!error) {
302 int32_t word54 = pci_read_config(parent, 0x54, 4);
303
304 pci_write_config(parent, 0x4b,
305 pci_read_config(parent, 0x4b, 1) | 0x01, 1);
306 word54 &= ~(0x000f000f << (devno << 2));
307 word54 |= (0x000f0005 << (devno << 2));
--- 4 unchanged lines hidden (view full) ---
312 return;
313 }
314 }
315 if (udmamode >= 4 && pci_get_revid(parent) >= 0xC2) {
316 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
317 ATA_UDMA4, ATA_C_F_SETXFER, ATA_WAIT_READY);
318 if (bootverbose)
319 ata_printf(scp, device,
320 "%s setting UDMA4 on Aladdin chip\n",
321 (error) ? "failed" : "success");
322 if (!error) {
323 int32_t word54 = pci_read_config(parent, 0x54, 4);
324
325 pci_write_config(parent, 0x4b,
326 pci_read_config(parent, 0x4b, 1) | 0x01, 1);
327 word54 &= ~(0x000f000f << (devno << 2));
328 word54 |= (0x00080005 << (devno << 2));
--- 4 unchanged lines hidden (view full) ---
333 return;
334 }
335 }
336 if (udmamode >= 2 && pci_get_revid(parent) >= 0x20) {
337 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
338 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);
339 if (bootverbose)
340 ata_printf(scp, device,
341 "%s setting UDMA2 on Aladdin chip\n",
342 (error) ? "failed" : "success");
343 if (!error) {
344 int32_t word54 = pci_read_config(parent, 0x54, 4);
345
346 word54 &= ~(0x000f000f << (devno << 2));
347 word54 |= (0x000a0005 << (devno << 2));
348 pci_write_config(parent, 0x54, word54, 4);
349 pci_write_config(parent, 0x53,
--- 8 unchanged lines hidden (view full) ---
358 pci_write_config(parent, 0x56, pci_read_config(parent, 0x56, 2) &
359 ~(0x0008 << (devno << 2)), 2);
360
361 if (wdmamode >= 2 && apiomode >= 4) {
362 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
363 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);
364 if (bootverbose)
365 ata_printf(scp, device,
366 "%s setting WDMA2 on Aladdin chip\n",
367 (error) ? "failed" : "success");
368 if (!error) {
369 pci_write_config(parent, 0x53,
370 pci_read_config(parent, 0x53, 1) | 0x03, 1);
371 scp->flags |= ATA_ATAPI_DMA_RO;
372 scp->mode[ATA_DEV(device)] = ATA_WDMA2;
373 return;
374 }
--- 747 unchanged lines hidden ---
2 * Copyright (c) 1998,1999,2000,2001 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 75516 2001-04-14 18:33:08Z sos $
29 */
30
31#include "pci.h"
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/ata.h>
35#include <sys/bio.h>
36#include <sys/malloc.h>
--- 65 unchanged lines hidden (view full) ---
102 if (udmamode > 2 && !ATA_PARAM(scp, device)->cblid) {
103 ata_printf(scp, device,
104 "DMA limited to UDMA33, non-ATA66 compliant cable\n");
105 udmamode = 2;
106 }
107
108 switch (scp->chiptype) {
109
110 case 0x244b8086: /* Intel ICH2 */
111 if (udmamode >= 5) {
112 int32_t mask48, new48;
113 int16_t word54;
114
115 word54 = pci_read_config(parent, 0x54, 2);
116 if (word54 & (0x10 << devno)) {
117 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
118 ATA_UDMA5, ATA_C_F_SETXFER,ATA_WAIT_READY);
119 if (bootverbose)
120 ata_printf(scp, device,
121 "%s setting UDMA5 on ICH2 chip\n",
122 (error) ? "failed" : "success");
123 if (!error) {
124 mask48 = (1 << devno) + (3 << (16 + (devno << 2)));
125 new48 = (1 << devno) + (1 << (16 + (devno << 2)));
126 pci_write_config(parent, 0x48,
127 (pci_read_config(parent, 0x48, 4) &
128 ~mask48) | new48, 4);
129 pci_write_config(parent, 0x54, word54 | (0x1000<<devno), 2);
--- 13 unchanged lines hidden (view full) ---
143 int16_t word54;
144
145 word54 = pci_read_config(parent, 0x54, 2);
146 if (word54 & (0x10 << devno)) {
147 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
148 ATA_UDMA4, ATA_C_F_SETXFER,ATA_WAIT_READY);
149 if (bootverbose)
150 ata_printf(scp, device,
151 "%s setting UDMA4 on ICH%s chip\n",
152 (error) ? "failed" : "success",
153 (scp->chiptype == 0x244b8086) ? "2" : "");
154 if (!error) {
155 mask48 = (1 << devno) + (3 << (16 + (devno << 2)));
156 new48 = (1 << devno) + (2 << (16 + (devno << 2)));
157 pci_write_config(parent, 0x48,
158 (pci_read_config(parent, 0x48, 4) &
159 ~mask48) | new48, 4);
160 pci_write_config(parent, 0x54, word54 | (1 << devno), 2);
161 scp->mode[ATA_DEV(device)] = ATA_UDMA4;
--- 10 unchanged lines hidden (view full) ---
172 case 0x71998086: /* Intel PIIX4e */
173 case 0x24218086: /* Intel ICH0 */
174 if (udmamode >= 2) {
175 int32_t mask48, new48;
176
177 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
178 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);
179 if (bootverbose)
180 ata_printf(scp, device, "%s setting UDMA2 on %s chip\n",
181 (error) ? "failed" : "success",
182 (scp->chiptype == 0x244b8086) ? "ICH2" :
183 (scp->chiptype == 0x24118086) ? "ICH" :
184 (scp->chiptype == 0x24218086) ? "ICH0" :"PIIX4");
185 if (!error) {
186 mask48 = (1 << devno) + (3 << (16 + (devno << 2)));
187 new48 = (1 << devno) + (2 << (16 + (devno << 2)));
188 pci_write_config(parent, 0x48,
189 (pci_read_config(parent, 0x48, 4) &
190 ~mask48) | new48, 4);
191 scp->mode[ATA_DEV(device)] = ATA_UDMA2;
192 return;
--- 22 unchanged lines hidden (view full) ---
215 }
216 new40 |= 0x40004000;
217 pci_write_config(parent, 0x40, new40, 4);
218 pci_write_config(parent, 0x44, new44, 4);
219 }
220 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
221 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);
222 if (bootverbose)
223 ata_printf(scp, device, "%s setting WDMA2 on %s chip\n",
224 (error) ? "failed" : "success",
225 (scp->chiptype == 0x244b8086) ? "ICH2" :
226 (scp->chiptype == 0x24118086) ? "ICH" :
227 (scp->chiptype == 0x24218086) ? "ICH0" :
228 (scp->chiptype == 0x70108086) ? "PIIX3":"PIIX4");
229 if (!error) {
230 if (device == ATA_MASTER) {
231 mask40 = 0x0000330f;
232 new40 = 0x00002307;
233 mask44 = 0;
234 new44 = 0;
235 }
236 else {
--- 32 unchanged lines hidden (view full) ---
269 if (!((word40 & 0x3300) == 0x2300 &&
270 ((word40 >> (device == ATA_MASTER ? 0 : 4)) & 1) == 1))
271 break;
272
273 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
274 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);
275 if (bootverbose)
276 ata_printf(scp, device,
277 "%s setting WDMA2 on PIIX chip\n",
278 (error) ? "failed" : "success");
279 if (!error) {
280 scp->mode[ATA_DEV(device)] = ATA_WDMA2;
281 return;
282 }
283 }
284 break;
285
--- 5 unchanged lines hidden (view full) ---
291 "Aladdin: two atapi devices on this channel, no DMA\n");
292 break;
293 }
294 if (udmamode >= 5 && pci_get_revid(parent) >= 0xC4) {
295 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
296 ATA_UDMA5, ATA_C_F_SETXFER, ATA_WAIT_READY);
297 if (bootverbose)
298 ata_printf(scp, device,
299 "%s setting UDMA5 on Aladdin chip\n",
300 (error) ? "failed" : "success");
301 if (!error) {
302 int32_t word54 = pci_read_config(parent, 0x54, 4);
303
304 pci_write_config(parent, 0x4b,
305 pci_read_config(parent, 0x4b, 1) | 0x01, 1);
306 word54 &= ~(0x000f000f << (devno << 2));
307 word54 |= (0x000f0005 << (devno << 2));
--- 4 unchanged lines hidden (view full) ---
312 return;
313 }
314 }
315 if (udmamode >= 4 && pci_get_revid(parent) >= 0xC2) {
316 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
317 ATA_UDMA4, ATA_C_F_SETXFER, ATA_WAIT_READY);
318 if (bootverbose)
319 ata_printf(scp, device,
320 "%s setting UDMA4 on Aladdin chip\n",
321 (error) ? "failed" : "success");
322 if (!error) {
323 int32_t word54 = pci_read_config(parent, 0x54, 4);
324
325 pci_write_config(parent, 0x4b,
326 pci_read_config(parent, 0x4b, 1) | 0x01, 1);
327 word54 &= ~(0x000f000f << (devno << 2));
328 word54 |= (0x00080005 << (devno << 2));
--- 4 unchanged lines hidden (view full) ---
333 return;
334 }
335 }
336 if (udmamode >= 2 && pci_get_revid(parent) >= 0x20) {
337 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
338 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);
339 if (bootverbose)
340 ata_printf(scp, device,
341 "%s setting UDMA2 on Aladdin chip\n",
342 (error) ? "failed" : "success");
343 if (!error) {
344 int32_t word54 = pci_read_config(parent, 0x54, 4);
345
346 word54 &= ~(0x000f000f << (devno << 2));
347 word54 |= (0x000a0005 << (devno << 2));
348 pci_write_config(parent, 0x54, word54, 4);
349 pci_write_config(parent, 0x53,
--- 8 unchanged lines hidden (view full) ---
358 pci_write_config(parent, 0x56, pci_read_config(parent, 0x56, 2) &
359 ~(0x0008 << (devno << 2)), 2);
360
361 if (wdmamode >= 2 && apiomode >= 4) {
362 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
363 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);
364 if (bootverbose)
365 ata_printf(scp, device,
366 "%s setting WDMA2 on Aladdin chip\n",
367 (error) ? "failed" : "success");
368 if (!error) {
369 pci_write_config(parent, 0x53,
370 pci_read_config(parent, 0x53, 1) | 0x03, 1);
371 scp->flags |= ATA_ATAPI_DMA_RO;
372 scp->mode[ATA_DEV(device)] = ATA_WDMA2;
373 return;
374 }
--- 747 unchanged lines hidden ---