Import 2.3.51
[davej-history.git] / drivers / block / ide_modes.h
blobf94d9131389e8136e7281de16041bea3689c43e2
1 /*
2 * linux/drivers/block/ide_modes.h
4 * Copyright (C) 1996 Linus Torvalds, Igor Abramov, and Mark Lord
5 */
7 #ifndef _IDE_MODES_H
8 #define _IDE_MODES_H
10 #include <linux/config.h>
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.
19 #ifdef CONFIG_BLK_DEV_IDE_MODES
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).
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;
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;
41 #ifndef _IDE_C
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];
47 #else /* _IDE_C */
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) */
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.
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 },
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 }, */
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 },
95 { "SAMSUNG SHD-3121A", 1 },
96 { "SAMSUNG SHD-3122A", 1 },
97 { "SAMSUNG SHD-3172A", 1 },
99 /* { "ST51080A", 4 },
100 * { "ST51270A", 4 },
101 * { "ST31220A", 4 },
102 * { "ST31640A", 4 },
103 * { "ST32140A", 4 },
104 * { "ST3780A", 4 },
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 */
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 { "QUANTUM FIREBALL", 3 }, /* For models 540/640/1080/1280 */
128 /* 1080A works fine in mode4 with triton */
129 { NULL, 0 }
133 * This routine searches the ide_pio_blacklist for an entry
134 * matching the start/whole of the supplied model name.
136 * Returns -1 if no match found.
137 * Otherwise returns the recommended PIO mode from ide_pio_blacklist[].
139 int ide_scan_pio_blacklist (char *model)
141 struct ide_pio_info *p;
143 for (p = ide_pio_blacklist; p->name != NULL; p++) {
144 if (strncmp(p->name, model, strlen(p->name)) == 0)
145 return p->pio;
147 return -1;
151 * This routine returns the recommended PIO settings for a given drive,
152 * based on the drive->id information and the ide_pio_blacklist[].
153 * This is used by most chipset support modules when "auto-tuning".
157 * Drive PIO mode auto selection
159 byte ide_get_best_pio_mode (ide_drive_t *drive, byte mode_wanted, byte max_mode, ide_pio_data_t *d)
161 int pio_mode;
162 int cycle_time = 0;
163 int use_iordy = 0;
164 struct hd_driveid* id = drive->id;
165 int overridden = 0;
166 int blacklisted = 0;
168 if (mode_wanted != 255) {
169 pio_mode = mode_wanted;
170 } else if (!drive->id) {
171 pio_mode = 0;
172 } else if ((pio_mode = ide_scan_pio_blacklist(id->model)) != -1) {
173 overridden = 1;
174 blacklisted = 1;
175 use_iordy = (pio_mode > 2);
176 } else {
177 pio_mode = id->tPIO;
178 if (pio_mode > 2) { /* 2 is maximum allowed tPIO value */
179 pio_mode = 2;
180 overridden = 1;
182 if (id->field_valid & 2) { /* drive implements ATA2? */
183 if (id->capability & 8) { /* drive supports use_iordy? */
184 use_iordy = 1;
185 cycle_time = id->eide_pio_iordy;
186 if (id->eide_pio_modes & 7) {
187 overridden = 0;
188 if (id->eide_pio_modes & 4)
189 pio_mode = 5;
190 else if (id->eide_pio_modes & 2)
191 pio_mode = 4;
192 else
193 pio_mode = 3;
195 } else {
196 cycle_time = id->eide_pio;
200 #if 0
201 if (drive->id->major_rev_num & 0x0004) printf("ATA-2 ");
202 #endif
205 * Conservative "downgrade" for all pre-ATA2 drives
207 if (pio_mode && pio_mode < 4) {
208 pio_mode--;
209 overridden = 1;
210 #if 0
211 use_iordy = (pio_mode > 2);
212 #endif
213 if (cycle_time && cycle_time < ide_pio_timings[pio_mode].cycle_time)
214 cycle_time = 0; /* use standard timing */
217 if (pio_mode > max_mode) {
218 pio_mode = max_mode;
219 cycle_time = 0;
221 if (d) {
222 d->pio_mode = pio_mode;
223 d->cycle_time = cycle_time ? cycle_time : ide_pio_timings[pio_mode].cycle_time;
224 d->use_iordy = use_iordy;
225 d->overridden = overridden;
226 d->blacklisted = blacklisted;
228 return pio_mode;
231 #endif /* _IDE_C */
232 #endif /* CONFIG_BLK_DEV_IDE_MODES */
233 #endif /* _IDE_MODES_H */