Deleted Added
sdiff udiff text old ( 75516 ) new ( 75553 )
full compact
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 75553 2001-04-16 21:22:34Z 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 0x244a8086: /* Intel ICH2 mobile */
111 case 0x244b8086: /* Intel ICH2 */
112 if (udmamode >= 5) {
113 int32_t mask48, new48;
114 int16_t word54;
115
116 word54 = pci_read_config(parent, 0x54, 2);
117 if (word54 & (0x10 << devno)) {
118 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
119 ATA_UDMA5, ATA_C_F_SETXFER,ATA_WAIT_READY);
120 if (bootverbose)
121 ata_printf(scp, device,
122 "%s setting UDMA5 on Intel chip\n",
123 (error) ? "failed" : "success");
124 if (!error) {
125 mask48 = (1 << devno) + (3 << (16 + (devno << 2)));
126 new48 = (1 << devno) + (1 << (16 + (devno << 2)));
127 pci_write_config(parent, 0x48,
128 (pci_read_config(parent, 0x48, 4) &
129 ~mask48) | new48, 4);
130 pci_write_config(parent, 0x54, word54 | (0x1000<<devno), 2);

--- 13 unchanged lines hidden (view full) ---

144 int16_t word54;
145
146 word54 = pci_read_config(parent, 0x54, 2);
147 if (word54 & (0x10 << devno)) {
148 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
149 ATA_UDMA4, ATA_C_F_SETXFER,ATA_WAIT_READY);
150 if (bootverbose)
151 ata_printf(scp, device,
152 "%s setting UDMA4 on Intel chip\n",
153 (error) ? "failed" : "success");
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 Intel chip\n",
181 (error) ? "failed" : "success");
182 if (!error) {
183 mask48 = (1 << devno) + (3 << (16 + (devno << 2)));
184 new48 = (1 << devno) + (2 << (16 + (devno << 2)));
185 pci_write_config(parent, 0x48,
186 (pci_read_config(parent, 0x48, 4) &
187 ~mask48) | new48, 4);
188 scp->mode[ATA_DEV(device)] = ATA_UDMA2;
189 return;

--- 22 unchanged lines hidden (view full) ---

212 }
213 new40 |= 0x40004000;
214 pci_write_config(parent, 0x40, new40, 4);
215 pci_write_config(parent, 0x44, new44, 4);
216 }
217 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
218 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);
219 if (bootverbose)
220 ata_printf(scp, device, "%s setting WDMA2 on Intel chip\n",
221 (error) ? "failed" : "success");
222 if (!error) {
223 if (device == ATA_MASTER) {
224 mask40 = 0x0000330f;
225 new40 = 0x00002307;
226 mask44 = 0;
227 new44 = 0;
228 }
229 else {

--- 32 unchanged lines hidden (view full) ---

262 if (!((word40 & 0x3300) == 0x2300 &&
263 ((word40 >> (device == ATA_MASTER ? 0 : 4)) & 1) == 1))
264 break;
265
266 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
267 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);
268 if (bootverbose)
269 ata_printf(scp, device,
270 "%s setting WDMA2 on Intel chip\n",
271 (error) ? "failed" : "success");
272 if (!error) {
273 scp->mode[ATA_DEV(device)] = ATA_WDMA2;
274 return;
275 }
276 }
277 break;
278

--- 5 unchanged lines hidden (view full) ---

284 "Aladdin: two atapi devices on this channel, no DMA\n");
285 break;
286 }
287 if (udmamode >= 5 && pci_get_revid(parent) >= 0xC4) {
288 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
289 ATA_UDMA5, ATA_C_F_SETXFER, ATA_WAIT_READY);
290 if (bootverbose)
291 ata_printf(scp, device,
292 "%s setting UDMA5 on Acer chip\n",
293 (error) ? "failed" : "success");
294 if (!error) {
295 int32_t word54 = pci_read_config(parent, 0x54, 4);
296
297 pci_write_config(parent, 0x4b,
298 pci_read_config(parent, 0x4b, 1) | 0x01, 1);
299 word54 &= ~(0x000f000f << (devno << 2));
300 word54 |= (0x000f0005 << (devno << 2));

--- 4 unchanged lines hidden (view full) ---

305 return;
306 }
307 }
308 if (udmamode >= 4 && pci_get_revid(parent) >= 0xC2) {
309 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
310 ATA_UDMA4, ATA_C_F_SETXFER, ATA_WAIT_READY);
311 if (bootverbose)
312 ata_printf(scp, device,
313 "%s setting UDMA4 on Acer chip\n",
314 (error) ? "failed" : "success");
315 if (!error) {
316 int32_t word54 = pci_read_config(parent, 0x54, 4);
317
318 pci_write_config(parent, 0x4b,
319 pci_read_config(parent, 0x4b, 1) | 0x01, 1);
320 word54 &= ~(0x000f000f << (devno << 2));
321 word54 |= (0x00080005 << (devno << 2));

--- 4 unchanged lines hidden (view full) ---

326 return;
327 }
328 }
329 if (udmamode >= 2 && pci_get_revid(parent) >= 0x20) {
330 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
331 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);
332 if (bootverbose)
333 ata_printf(scp, device,
334 "%s setting UDMA2 on Acer chip\n",
335 (error) ? "failed" : "success");
336 if (!error) {
337 int32_t word54 = pci_read_config(parent, 0x54, 4);
338
339 word54 &= ~(0x000f000f << (devno << 2));
340 word54 |= (0x000a0005 << (devno << 2));
341 pci_write_config(parent, 0x54, word54, 4);
342 pci_write_config(parent, 0x53,

--- 8 unchanged lines hidden (view full) ---

351 pci_write_config(parent, 0x56, pci_read_config(parent, 0x56, 2) &
352 ~(0x0008 << (devno << 2)), 2);
353
354 if (wdmamode >= 2 && apiomode >= 4) {
355 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0,
356 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);
357 if (bootverbose)
358 ata_printf(scp, device,
359 "%s setting WDMA2 on Acer chip\n",
360 (error) ? "failed" : "success");
361 if (!error) {
362 pci_write_config(parent, 0x53,
363 pci_read_config(parent, 0x53, 1) | 0x03, 1);
364 scp->flags |= ATA_ATAPI_DMA_RO;
365 scp->mode[ATA_DEV(device)] = ATA_WDMA2;
366 return;
367 }

--- 747 unchanged lines hidden ---