4 * linux/drivers/block/ide_modes.h
6 * Copyright (C) 1996 Linus Torvalds, Igor Abramov, and Mark Lord
9 #include <linux/config.h>
12 * Shared data/functions for determining best PIO mode for an IDE drive.
13 * Most of this stuff originally lived in cmd640.c, and changes to the
14 * ide_pio_blacklist[] table should be made with EXTREME CAUTION to avoid
15 * breaking the fragile cmd640.c support.
18 #ifdef CONFIG_BLK_DEV_IDE_MODES
21 * Standard (generic) timings for PIO modes, from ATA2 specification.
22 * These timings are for access to the IDE data port register *only*.
23 * Some drives may specify a mode, while also specifying a different
24 * value for cycle_time (from drive identification data).
26 typedef struct ide_pio_timings_s
{
27 int setup_time
; /* Address setup (ns) minimum */
28 int active_time
; /* Active pulse (ns) minimum */
29 int cycle_time
; /* Cycle time (ns) minimum = (setup + active + recovery) */
32 typedef struct ide_pio_data_s
{
37 unsigned int cycle_time
;
42 int ide_scan_pio_blacklist (char *model
);
43 byte
ide_get_best_pio_mode (ide_drive_t
*drive
, byte mode_wanted
, byte max_mode
, ide_pio_data_t
*d
);
44 extern const ide_pio_timings_t ide_pio_timings
[6];
48 const ide_pio_timings_t ide_pio_timings
[6] = {
49 { 70, 165, 600 }, /* PIO Mode 0 */
50 { 50, 125, 383 }, /* PIO Mode 1 */
51 { 30, 100, 240 }, /* PIO Mode 2 */
52 { 30, 80, 180 }, /* PIO Mode 3 with IORDY */
53 { 25, 70, 120 }, /* PIO Mode 4 with IORDY */
54 { 20, 50, 100 } /* PIO Mode 5 with IORDY (nonstandard) */
58 * Black list. Some drives incorrectly report their maximal PIO mode,
59 * at least in respect to CMD640. Here we keep info on some known drives.
61 static struct ide_pio_info
{
64 } ide_pio_blacklist
[] = {
65 /* { "Conner Peripherals 1275MB - CFS1275A", 4 }, */
66 { "Conner Peripherals 540MB - CFS540A", 3 },
81 /* { "WDC AC21000", 4 }, */
84 /* { "WDC AC31600", 4 }, */
86 { "Maxtor 7131 AT", 1 },
87 { "Maxtor 7171 AT", 1 },
88 { "Maxtor 7213 AT", 1 },
89 { "Maxtor 7245 AT", 1 },
90 { "Maxtor 7345 AT", 1 },
91 { "Maxtor 7546 AT", 3 },
92 { "Maxtor 7540 AV", 3 },
94 { "SAMSUNG SHD-3121A", 1 },
95 { "SAMSUNG SHD-3122A", 1 },
96 { "SAMSUNG SHD-3172A", 1 },
114 { "ST3491A", 1 }, /* reports 3, should be 1 or 2 (depending on */
115 /* drive) according to Seagates FIND-ATA program */
117 { "QUANTUM ELS127A", 0 },
118 { "QUANTUM ELS170A", 0 },
119 { "QUANTUM LPS240A", 0 },
120 { "QUANTUM LPS210A", 3 },
121 { "QUANTUM LPS270A", 3 },
122 { "QUANTUM LPS365A", 3 },
123 { "QUANTUM LPS540A", 3 },
124 { "QUANTUM LIGHTNING 540A", 3 },
125 { "QUANTUM LIGHTNING 730A", 3 },
126 { "QUANTUM FIREBALL", 3 }, /* For models 540/640/1080/1280 */
127 /* 1080A works fine in mode4 with triton */
132 * This routine searches the ide_pio_blacklist for an entry
133 * matching the start/whole of the supplied model name.
135 * Returns -1 if no match found.
136 * Otherwise returns the recommended PIO mode from ide_pio_blacklist[].
138 int ide_scan_pio_blacklist (char *model
)
140 struct ide_pio_info
*p
;
142 for (p
= ide_pio_blacklist
; p
->name
!= NULL
; p
++) {
143 if (strncmp(p
->name
, model
, strlen(p
->name
)) == 0)
150 * This routine returns the recommended PIO settings for a given drive,
151 * based on the drive->id information and the ide_pio_blacklist[].
152 * This is used by most chipset support modules when "auto-tuning".
156 * Drive PIO mode auto selection
158 byte
ide_get_best_pio_mode (ide_drive_t
*drive
, byte mode_wanted
, byte max_mode
, ide_pio_data_t
*d
)
163 struct hd_driveid
* id
= drive
->id
;
167 if (mode_wanted
!= 255) {
168 pio_mode
= mode_wanted
;
169 } else if (!drive
->id
) {
171 } else if ((pio_mode
= ide_scan_pio_blacklist(id
->model
)) != -1) {
174 use_iordy
= (pio_mode
> 2);
177 if (pio_mode
> 2) { /* 2 is maximum allowed tPIO value */
181 if (id
->field_valid
& 2) { /* drive implements ATA2? */
182 if (id
->capability
& 8) { /* drive supports use_iordy? */
184 cycle_time
= id
->eide_pio_iordy
;
185 if (id
->eide_pio_modes
& 7) {
187 if (id
->eide_pio_modes
& 4)
189 else if (id
->eide_pio_modes
& 2)
195 cycle_time
= id
->eide_pio
;
200 * Conservative "downgrade" for all pre-ATA2 drives
202 if (pio_mode
&& pio_mode
< 4) {
206 use_iordy
= (pio_mode
> 2);
208 if (cycle_time
&& cycle_time
< ide_pio_timings
[pio_mode
].cycle_time
)
209 cycle_time
= 0; /* use standard timing */
212 if (pio_mode
> max_mode
) {
217 d
->pio_mode
= pio_mode
;
218 d
->cycle_time
= cycle_time
? cycle_time
: ide_pio_timings
[pio_mode
].cycle_time
;
219 d
->use_iordy
= use_iordy
;
220 d
->overridden
= overridden
;
221 d
->blacklisted
= blacklisted
;
227 #endif /* CONFIG_BLK_DEV_IDE_MODES */
228 #endif /* _IDE_MODES_H */