1 /*
2 * linux/drivers/ide/ide_modes.h
3 *
4 * Copyright (C) 1996 Linus Torvalds, Igor Abramov, and Mark Lord
5 */
6
7 #ifndef _IDE_MODES_H
8 #define _IDE_MODES_H
9
10 #include <linux/config.h>
11
12 /*
13 * Shared data/functions for determining best PIO mode for an IDE drive.
14 * Most of this stuff originally lived in cmd640.c, and changes to the
15 * ide_pio_blacklist[] table should be made with EXTREME CAUTION to avoid
16 * breaking the fragile cmd640.c support.
17 */
18
19 #ifdef CONFIG_BLK_DEV_IDE_MODES
20
21 /*
22 * Standard (generic) timings for PIO modes, from ATA2 specification.
23 * These timings are for access to the IDE data port register *only*.
24 * Some drives may specify a mode, while also specifying a different
25 * value for cycle_time (from drive identification data).
26 */
27 typedef struct ide_pio_timings_s {
28 int setup_time; /* Address setup (ns) minimum */
29 int active_time; /* Active pulse (ns) minimum */
30 int cycle_time; /* Cycle time (ns) minimum = (setup + active + recovery) */
31 } ide_pio_timings_t;
32
33 typedef struct ide_pio_data_s {
34 byte pio_mode;
35 byte use_iordy;
36 byte overridden;
37 byte blacklisted;
38 unsigned int cycle_time;
39 } ide_pio_data_t;
40
41 #ifndef _IDE_C
42
43 int ide_scan_pio_blacklist (char *model);
44 byte ide_get_best_pio_mode (ide_drive_t *drive, byte mode_wanted, byte max_mode, ide_pio_data_t *d);
45 extern const ide_pio_timings_t ide_pio_timings[6];
46
47 #else /* _IDE_C */
48
49 const ide_pio_timings_t ide_pio_timings[6] = {
50 { 70, 165, 600 }, /* PIO Mode 0 */
51 { 50, 125, 383 }, /* PIO Mode 1 */
52 { 30, 100, 240 }, /* PIO Mode 2 */
53 { 30, 80, 180 }, /* PIO Mode 3 with IORDY */
54 { 25, 70, 120 }, /* PIO Mode 4 with IORDY */
55 { 20, 50, 100 } /* PIO Mode 5 with IORDY (nonstandard) */
56 };
57
58 /*
59 * Black list. Some drives incorrectly report their maximal PIO mode,
60 * at least in respect to CMD640. Here we keep info on some known drives.
61 */
62 static struct ide_pio_info {
63 const char *name;
64 int pio;
65 } ide_pio_blacklist [] = {
66 /* { "Conner Peripherals 1275MB - CFS1275A", 4 }, */
67 { "Conner Peripherals 540MB - CFS540A", 3 },
68
69 { "WDC AC2700", 3 },
70 { "WDC AC2540", 3 },
71 { "WDC AC2420", 3 },
72 { "WDC AC2340", 3 },
73 { "WDC AC2250", 0 },
74 { "WDC AC2200", 0 },
75 { "WDC AC21200", 4 },
76 { "WDC AC2120", 0 },
77 { "WDC AC2850", 3 },
78 { "WDC AC1270", 3 },
79 { "WDC AC1170", 1 },
80 { "WDC AC1210", 1 },
81 { "WDC AC280", 0 },
82 /* { "WDC AC21000", 4 }, */
83 { "WDC AC31000", 3 },
84 { "WDC AC31200", 3 },
85 /* { "WDC AC31600", 4 }, */
86
87 { "Maxtor 7131 AT", 1 },
88 { "Maxtor 7171 AT", 1 },
89 { "Maxtor 7213 AT", 1 },
90 { "Maxtor 7245 AT", 1 },
91 { "Maxtor 7345 AT", 1 },
92 { "Maxtor 7546 AT", 3 },
93 { "Maxtor 7540 AV", 3 },
94
95 { "SAMSUNG SHD-3121A", 1 },
96 { "SAMSUNG SHD-3122A", 1 },
97 { "SAMSUNG SHD-3172A", 1 },
98
99 /* { "ST51080A", 4 },
100 * { "ST51270A", 4 },
101 * { "ST31220A", 4 },
102 * { "ST31640A", 4 },
103 * { "ST32140A", 4 },
104 * { "ST3780A", 4 },
105 */
106 { "ST5660A", 3 },
107 { "ST3660A", 3 },
108 { "ST3630A", 3 },
109 { "ST3655A", 3 },
110 { "ST3391A", 3 },
111 { "ST3390A", 1 },
112 { "ST3600A", 1 },
113 { "ST3290A", 0 },
114 { "ST3144A", 0 },
115 { "ST3491A", 1 }, /* reports 3, should be 1 or 2 (depending on */
116 /* drive) according to Seagates FIND-ATA program */
117
118 { "QUANTUM ELS127A", 0 },
119 { "QUANTUM ELS170A", 0 },
120 { "QUANTUM LPS240A", 0 },
121 { "QUANTUM LPS210A", 3 },
122 { "QUANTUM LPS270A", 3 },
123 { "QUANTUM LPS365A", 3 },
124 { "QUANTUM LPS540A", 3 },
125 { "QUANTUM LIGHTNING 540A", 3 },
126 { "QUANTUM LIGHTNING 730A", 3 },
127
128 { "QUANTUM FIREBALL_540", 3 }, /* Older Quantum Fireballs don't work */
129 { "QUANTUM FIREBALL_640", 3 },
130 { "QUANTUM FIREBALL_1080", 3 },
131 { "QUANTUM FIREBALL_1280", 3 },
132 { NULL, 0 }
133 };
134
135 /*
136 * This routine searches the ide_pio_blacklist for an entry
137 * matching the start/whole of the supplied model name.
138 *
139 * Returns -1 if no match found.
140 * Otherwise returns the recommended PIO mode from ide_pio_blacklist[].
141 */
142 int ide_scan_pio_blacklist (char *model)
143 {
144 struct ide_pio_info *p;
145
146 for (p = ide_pio_blacklist; p->name != NULL; p++) {
147 if (strncmp(p->name, model, strlen(p->name)) == 0)
148 return p->pio;
149 }
150 return -1;
151 }
152
153 /*
154 * This routine returns the recommended PIO settings for a given drive,
155 * based on the drive->id information and the ide_pio_blacklist[].
156 * This is used by most chipset support modules when "auto-tuning".
157 */
158
159 /*
160 * Drive PIO mode auto selection
161 */
162 byte ide_get_best_pio_mode (ide_drive_t *drive, byte mode_wanted, byte max_mode, ide_pio_data_t *d)
163 {
164 int pio_mode;
165 int cycle_time = 0;
166 int use_iordy = 0;
167 struct hd_driveid* id = drive->id;
168 int overridden = 0;
169 int blacklisted = 0;
170
171 if (mode_wanted != 255) {
172 pio_mode = mode_wanted;
173 } else if (!drive->id) {
174 pio_mode = 0;
175 } else if ((pio_mode = ide_scan_pio_blacklist(id->model)) != -1) {
176 overridden = 1;
177 blacklisted = 1;
178 use_iordy = (pio_mode > 2);
179 } else {
180 pio_mode = id->tPIO;
181 if (pio_mode > 2) { /* 2 is maximum allowed tPIO value */
182 pio_mode = 2;
183 overridden = 1;
184 }
185 if (id->field_valid & 2) { /* drive implements ATA2? */
186 if (id->capability & 8) { /* drive supports use_iordy? */
187 use_iordy = 1;
188 cycle_time = id->eide_pio_iordy;
189 if (id->eide_pio_modes & 7) {
190 overridden = 0;
191 if (id->eide_pio_modes & 4)
192 pio_mode = 5;
193 else if (id->eide_pio_modes & 2)
194 pio_mode = 4;
195 else
196 pio_mode = 3;
197 }
198 } else {
199 cycle_time = id->eide_pio;
200 }
201 }
202
203 #if 0
204 if (drive->id->major_rev_num & 0x0004) printf("ATA-2 ");
205 #endif
206
207 /*
208 * Conservative "downgrade" for all pre-ATA2 drives
209 */
210 if (pio_mode && pio_mode < 4) {
211 pio_mode--;
212 overridden = 1;
213 #if 0
214 use_iordy = (pio_mode > 2);
215 #endif
216 if (cycle_time && cycle_time < ide_pio_timings[pio_mode].cycle_time)
217 cycle_time = 0; /* use standard timing */
218 }
219 }
220 if (pio_mode > max_mode) {
221 pio_mode = max_mode;
222 cycle_time = 0;
223 }
224 if (d) {
225 d->pio_mode = pio_mode;
226 d->cycle_time = cycle_time ? cycle_time : ide_pio_timings[pio_mode].cycle_time;
227 d->use_iordy = use_iordy;
228 d->overridden = overridden;
229 d->blacklisted = blacklisted;
230 }
231 return pio_mode;
232 }
233
234 #endif /* _IDE_C */
235 #endif /* CONFIG_BLK_DEV_IDE_MODES */
236 #endif /* _IDE_MODES_H */
237
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.