More meth updates.
[linux-2.6/linux-mips.git] / drivers / ide / quirks.c
blob740cfe5632fee1f45684ec1faff2dee50d5c3293
1 /**** vi:set ts=8 sts=8 sw=8:************************************************
3 * Copyright (C) 2002 Marcin Dalecki <martin@dalecki.de>
5 * Copyright (c) 1999-2000 Andre Hedrick <andre@linux-ide.org>
6 * Copyright (c) 1995-1998 Mark Lord
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published by
10 * the Free Software Foundation.
14 * Just the black and white list handling for BM-DMA operation.
17 #include <linux/config.h>
18 #define __NO_VERSION__
19 #include <linux/module.h>
20 #include <linux/types.h>
21 #include <linux/kernel.h>
22 #include <linux/timer.h>
23 #include <linux/mm.h>
24 #include <linux/interrupt.h>
25 #include <linux/pci.h>
26 #include <linux/init.h>
27 #include <linux/delay.h>
28 #include <linux/hdreg.h>
29 #include <linux/ide.h>
31 #include <asm/io.h>
32 #include <asm/irq.h>
34 #ifdef CONFIG_IDEDMA_NEW_DRIVE_LISTINGS
36 struct drive_list_entry {
37 char * id_model;
38 char * id_firmware;
41 struct drive_list_entry drive_whitelist[] = {
42 { "Micropolis 2112A", NULL },
43 { "CONNER CTMA 4000", NULL },
44 { "CONNER CTT8000-A", NULL },
45 { "ST34342A", NULL },
46 { NULL, NULL }
49 struct drive_list_entry drive_blacklist[] = {
51 { "WDC AC11000H", NULL },
52 { "WDC AC22100H", NULL },
53 { "WDC AC32500H", NULL },
54 { "WDC AC33100H", NULL },
55 { "WDC AC31600H", NULL },
56 { "WDC AC32100H", "24.09P07" },
57 { "WDC AC23200L", "21.10N21" },
58 { "Compaq CRD-8241B", NULL },
59 { "CRD-8400B", NULL },
60 { "CRD-8480B", NULL },
61 { "CRD-8480C", NULL },
62 { "CRD-8482B", NULL },
63 { "CRD-84", NULL },
64 { "SanDisk SDP3B", NULL },
65 { "SanDisk SDP3B-64", NULL },
66 { "SANYO CD-ROM CRD", NULL },
67 { "HITACHI CDR-8", NULL },
68 { "HITACHI CDR-8335", NULL },
69 { "HITACHI CDR-8435", NULL },
70 { "Toshiba CD-ROM XM-6202B", NULL },
71 { "CD-532E-A", NULL },
72 { "E-IDE CD-ROM CR-840", NULL },
73 { "CD-ROM Drive/F5A", NULL },
74 { "RICOH CD-R/RW MP7083A", NULL },
75 { "WPI CDD-820", NULL },
76 { "SAMSUNG CD-ROM SC-148C", NULL },
77 { "SAMSUNG CD-ROM SC-148F", NULL },
78 { "SAMSUNG CD-ROM SC", NULL },
79 { "SanDisk SDP3B-64", NULL },
80 { "SAMSUNG CD-ROM SN-124", NULL },
81 { "PLEXTOR CD-R PX-W8432T", NULL },
82 { "ATAPI CD-ROM DRIVE 40X MAXIMUM", NULL },
83 { "_NEC DV5800A", NULL },
84 { NULL, NULL }
88 static int in_drive_list(struct hd_driveid *id, struct drive_list_entry * drive_table)
90 for ( ; drive_table->id_model ; drive_table++)
91 if ((!strcmp(drive_table->id_model, id->model)) &&
92 ((drive_table->id_firmware && !strstr(drive_table->id_firmware, id->fw_rev)) ||
93 (!drive_table->id_firmware)))
94 return 1;
95 return 0;
98 #else
101 * good_dma_drives() lists the model names (from "hdparm -i")
102 * of drives which do not support mode2 DMA but which are
103 * known to work fine with this interface under Linux.
105 const char *good_dma_drives[] = {"Micropolis 2112A",
106 "CONNER CTMA 4000",
107 "CONNER CTT8000-A",
108 "ST34342A", /* for Sun Ultra */
109 NULL};
112 * bad_dma_drives() lists the model names (from "hdparm -i")
113 * of drives which supposedly support (U)DMA but which are
114 * known to corrupt data with this interface under Linux.
116 * This is an empirical list. Its generated from bug reports. That means
117 * while it reflects actual problem distributions it doesn't answer whether
118 * the drive or the controller, or cabling, or software, or some combination
119 * thereof is the fault. If you don't happen to agree with the kernel's
120 * opinion of your drive - use hdparm to turn DMA on.
122 const char *bad_dma_drives[] = {"WDC AC11000H",
123 "WDC AC22100H",
124 "WDC AC32100H",
125 "WDC AC32500H",
126 "WDC AC33100H",
127 "WDC AC31600H",
128 NULL};
130 #endif
133 * For both Blacklisted and Whitelisted drives.
134 * This is setup to be called as an extern for future support
135 * to other special driver code.
137 int check_drive_lists(struct ata_device *drive, int good_bad)
139 struct hd_driveid *id = drive->id;
141 #ifdef CONFIG_IDEDMA_NEW_DRIVE_LISTINGS
142 if (good_bad) {
143 return in_drive_list(id, drive_whitelist);
144 } else {
145 int blacklist = in_drive_list(id, drive_blacklist);
146 if (blacklist)
147 printk("%s: Disabling (U)DMA for %s\n", drive->name, id->model);
148 return(blacklist);
150 #else
151 const char **list;
153 if (good_bad) {
154 /* Consult the list of known "good" drives */
155 list = good_dma_drives;
156 while (*list) {
157 if (!strcmp(*list++, id->model))
158 return 1;
160 } else {
161 /* Consult the list of known "bad" drives */
162 list = bad_dma_drives;
163 while (*list) {
164 if (!strcmp(*list++, id->model)) {
165 printk("%s: Disabling (U)DMA for %s\n",
166 drive->name, id->model);
167 return 1;
171 #endif
172 return 0;
175 void udma_print(struct ata_device *drive)
177 #ifdef CONFIG_ARCH_ACORN
178 printk(", DMA");
179 #else
180 struct hd_driveid *id = drive->id;
181 char *str = NULL;
183 if ((id->field_valid & 4) && (eighty_ninty_three(drive)) &&
184 (id->dma_ultra & (id->dma_ultra >> 14) & 3)) {
185 if ((id->dma_ultra >> 15) & 1)
186 str = ", UDMA(mode 7)"; /* UDMA BIOS-enabled! */
187 else
188 str = ", UDMA(133)"; /* UDMA BIOS-enabled! */
189 } else if ((id->field_valid & 4) && (eighty_ninty_three(drive)) &&
190 (id->dma_ultra & (id->dma_ultra >> 11) & 7)) {
191 if ((id->dma_ultra >> 13) & 1) {
192 str = ", UDMA(100)"; /* UDMA BIOS-enabled! */
193 } else if ((id->dma_ultra >> 12) & 1) {
194 str = ", UDMA(66)"; /* UDMA BIOS-enabled! */
195 } else {
196 str = ", UDMA(44)"; /* UDMA BIOS-enabled! */
198 } else if ((id->field_valid & 4) &&
199 (id->dma_ultra & (id->dma_ultra >> 8) & 7)) {
200 if ((id->dma_ultra >> 10) & 1) {
201 str = ", UDMA(33)"; /* UDMA BIOS-enabled! */
202 } else if ((id->dma_ultra >> 9) & 1) {
203 str = ", UDMA(25)"; /* UDMA BIOS-enabled! */
204 } else {
205 str = ", UDMA(16)"; /* UDMA BIOS-enabled! */
207 } else if (id->field_valid & 4)
208 str = ", (U)DMA"; /* Can be BIOS-enabled! */
209 else
210 str = ", DMA";
212 printk(str);
213 #endif
217 * Drive back/white list handling for UDMA capability:
220 int udma_black_list(struct ata_device *drive)
222 return check_drive_lists(drive, 0);
225 int udma_white_list(struct ata_device *drive)
227 return check_drive_lists(drive, 1);
230 EXPORT_SYMBOL(udma_print);
231 EXPORT_SYMBOL(udma_black_list);
232 EXPORT_SYMBOL(udma_white_list);