diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2007-10-11 17:54:00 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2007-10-11 17:54:00 -0400 |
commit | 26bcb879c03254545a19c6700fe5bcef6f21e7b1 (patch) | |
tree | dc35f1a7d7860fe0de268ff92189ff0884b689d3 /drivers/ide/legacy | |
parent | 842c19ad6fc0dbd9ac9d2f8527466201802934cf (diff) |
ide: add ide_set{_max}_pio() (take 4)
* Add IDE_HFLAG_ABUSE_{PREFETCH,FAST_DEVSEL,DMA_MODES} flags
and set them in ht6560, cmd640, cmd64x and sc1200 host drivers.
* Add set_pio_mode_abuse() for checking if host driver has a non-standard
->tuneproc() implementation and use it in do_special().
* Add ide_set_pio() for setting PIO mode (it uses hwif->pio_mask to find
the maximum PIO mode supported by the host), also add ide_set_max_pio()
wrapper for ide_set_pio() to use for auto-tuning. Convert users of
->tuneproc to use ide_set{_max}_pio() where possible. This leaves only
do_special(), set_using_pio(), ide_hwif_restore() and ide_set_pio() as
a direct users of ->tuneproc.
* Remove no longer needed ide_get_best_pio_mode() calls and printk-s
reporting PIO mode selected from ->tuneproc implementations.
* Rename ->tuneproc hook to ->set_pio_mode and make 'pio' argument const.
* Remove stale comment from ide_config_drive_speed().
v2:
* Fix "ata_" prefix (Noticed by Jeff).
v3:
* Minor cleanups/fixups per Sergei's suggestions.
v4:
* Fix compile problem in drivers/ide/pci/cmd640.c
(Noticed by Andrew Morton).
* Improve some ->set_pio_mode comments.
Reviewed-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/legacy')
-rw-r--r-- | drivers/ide/legacy/ali14xx.c | 10 | ||||
-rw-r--r-- | drivers/ide/legacy/dtc2278.c | 6 | ||||
-rw-r--r-- | drivers/ide/legacy/ht6560b.c | 11 | ||||
-rw-r--r-- | drivers/ide/legacy/qd65xx.c | 60 | ||||
-rw-r--r-- | drivers/ide/legacy/umc8672.c | 7 |
5 files changed, 47 insertions, 47 deletions
diff --git a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c index 9b9c4761cb7d..2f0ef9b44033 100644 --- a/drivers/ide/legacy/ali14xx.c +++ b/drivers/ide/legacy/ali14xx.c | |||
@@ -68,8 +68,6 @@ static RegInitializer initData[] __initdata = { | |||
68 | {0x35, 0x03}, {0x00, 0x00} | 68 | {0x35, 0x03}, {0x00, 0x00} |
69 | }; | 69 | }; |
70 | 70 | ||
71 | #define ALI_MAX_PIO 4 | ||
72 | |||
73 | /* timing parameter registers for each drive */ | 71 | /* timing parameter registers for each drive */ |
74 | static struct { u8 reg1, reg2, reg3, reg4; } regTab[4] = { | 72 | static struct { u8 reg1, reg2, reg3, reg4; } regTab[4] = { |
75 | {0x03, 0x26, 0x04, 0x27}, /* drive 0 */ | 73 | {0x03, 0x26, 0x04, 0x27}, /* drive 0 */ |
@@ -109,7 +107,7 @@ static void outReg (u8 data, u8 reg) | |||
109 | * This function computes timing parameters | 107 | * This function computes timing parameters |
110 | * and sets controller registers accordingly. | 108 | * and sets controller registers accordingly. |
111 | */ | 109 | */ |
112 | static void ali14xx_tune_drive (ide_drive_t *drive, u8 pio) | 110 | static void ali14xx_set_pio_mode(ide_drive_t *drive, const u8 pio) |
113 | { | 111 | { |
114 | int driveNum; | 112 | int driveNum; |
115 | int time1, time2; | 113 | int time1, time2; |
@@ -117,8 +115,6 @@ static void ali14xx_tune_drive (ide_drive_t *drive, u8 pio) | |||
117 | unsigned long flags; | 115 | unsigned long flags; |
118 | int bus_speed = system_bus_clock(); | 116 | int bus_speed = system_bus_clock(); |
119 | 117 | ||
120 | pio = ide_get_best_pio_mode(drive, pio, ALI_MAX_PIO); | ||
121 | |||
122 | /* calculate timing, according to PIO mode */ | 118 | /* calculate timing, according to PIO mode */ |
123 | time1 = ide_pio_cycle_time(drive, pio); | 119 | time1 = ide_pio_cycle_time(drive, pio); |
124 | time2 = ide_pio_timings[pio].active_time; | 120 | time2 = ide_pio_timings[pio].active_time; |
@@ -212,12 +208,12 @@ static int __init ali14xx_probe(void) | |||
212 | 208 | ||
213 | hwif->chipset = ide_ali14xx; | 209 | hwif->chipset = ide_ali14xx; |
214 | hwif->pio_mask = ATA_PIO4; | 210 | hwif->pio_mask = ATA_PIO4; |
215 | hwif->tuneproc = &ali14xx_tune_drive; | 211 | hwif->set_pio_mode = &ali14xx_set_pio_mode; |
216 | hwif->mate = mate; | 212 | hwif->mate = mate; |
217 | 213 | ||
218 | mate->chipset = ide_ali14xx; | 214 | mate->chipset = ide_ali14xx; |
219 | mate->pio_mask = ATA_PIO4; | 215 | mate->pio_mask = ATA_PIO4; |
220 | mate->tuneproc = &ali14xx_tune_drive; | 216 | mate->set_pio_mode = &ali14xx_set_pio_mode; |
221 | mate->mate = hwif; | 217 | mate->mate = hwif; |
222 | mate->channel = 1; | 218 | mate->channel = 1; |
223 | 219 | ||
diff --git a/drivers/ide/legacy/dtc2278.c b/drivers/ide/legacy/dtc2278.c index 6c01d951d074..f16521254867 100644 --- a/drivers/ide/legacy/dtc2278.c +++ b/drivers/ide/legacy/dtc2278.c | |||
@@ -67,12 +67,10 @@ static void sub22 (char b, char c) | |||
67 | } | 67 | } |
68 | } | 68 | } |
69 | 69 | ||
70 | static void tune_dtc2278 (ide_drive_t *drive, u8 pio) | 70 | static void dtc2278_set_pio_mode(ide_drive_t *drive, const u8 pio) |
71 | { | 71 | { |
72 | unsigned long flags; | 72 | unsigned long flags; |
73 | 73 | ||
74 | pio = ide_get_best_pio_mode(drive, pio, 4); | ||
75 | |||
76 | if (pio >= 3) { | 74 | if (pio >= 3) { |
77 | spin_lock_irqsave(&ide_lock, flags); | 75 | spin_lock_irqsave(&ide_lock, flags); |
78 | /* | 76 | /* |
@@ -124,7 +122,7 @@ static int __init dtc2278_probe(void) | |||
124 | hwif->serialized = 1; | 122 | hwif->serialized = 1; |
125 | hwif->chipset = ide_dtc2278; | 123 | hwif->chipset = ide_dtc2278; |
126 | hwif->pio_mask = ATA_PIO4; | 124 | hwif->pio_mask = ATA_PIO4; |
127 | hwif->tuneproc = &tune_dtc2278; | 125 | hwif->set_pio_mode = &dtc2278_set_pio_mode; |
128 | hwif->drives[0].no_unmask = 1; | 126 | hwif->drives[0].no_unmask = 1; |
129 | hwif->drives[1].no_unmask = 1; | 127 | hwif->drives[1].no_unmask = 1; |
130 | hwif->mate = mate; | 128 | hwif->mate = mate; |
diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c index bfaa2025173b..2e5a9cc5c0f7 100644 --- a/drivers/ide/legacy/ht6560b.c +++ b/drivers/ide/legacy/ht6560b.c | |||
@@ -199,7 +199,7 @@ static int __init try_to_init_ht6560b(void) | |||
199 | return 1; | 199 | return 1; |
200 | } | 200 | } |
201 | 201 | ||
202 | static u8 ht_pio2timings(ide_drive_t *drive, u8 pio) | 202 | static u8 ht_pio2timings(ide_drive_t *drive, const u8 pio) |
203 | { | 203 | { |
204 | int active_time, recovery_time; | 204 | int active_time, recovery_time; |
205 | int active_cycles, recovery_cycles; | 205 | int active_cycles, recovery_cycles; |
@@ -208,7 +208,6 @@ static u8 ht_pio2timings(ide_drive_t *drive, u8 pio) | |||
208 | if (pio) { | 208 | if (pio) { |
209 | unsigned int cycle_time; | 209 | unsigned int cycle_time; |
210 | 210 | ||
211 | pio = ide_get_best_pio_mode(drive, pio, 5); | ||
212 | cycle_time = ide_pio_cycle_time(drive, pio); | 211 | cycle_time = ide_pio_cycle_time(drive, pio); |
213 | 212 | ||
214 | /* | 213 | /* |
@@ -277,7 +276,7 @@ static void ht_set_prefetch(ide_drive_t *drive, u8 state) | |||
277 | #endif | 276 | #endif |
278 | } | 277 | } |
279 | 278 | ||
280 | static void tune_ht6560b (ide_drive_t *drive, u8 pio) | 279 | static void ht6560b_set_pio_mode(ide_drive_t *drive, const u8 pio) |
281 | { | 280 | { |
282 | unsigned long flags; | 281 | unsigned long flags; |
283 | u8 timing; | 282 | u8 timing; |
@@ -333,15 +332,17 @@ int __init ht6560b_init(void) | |||
333 | 332 | ||
334 | hwif->chipset = ide_ht6560b; | 333 | hwif->chipset = ide_ht6560b; |
335 | hwif->selectproc = &ht6560b_selectproc; | 334 | hwif->selectproc = &ht6560b_selectproc; |
335 | hwif->host_flags = IDE_HFLAG_ABUSE_PREFETCH; | ||
336 | hwif->pio_mask = ATA_PIO5; | 336 | hwif->pio_mask = ATA_PIO5; |
337 | hwif->tuneproc = &tune_ht6560b; | 337 | hwif->set_pio_mode = &ht6560b_set_pio_mode; |
338 | hwif->serialized = 1; /* is this needed? */ | 338 | hwif->serialized = 1; /* is this needed? */ |
339 | hwif->mate = mate; | 339 | hwif->mate = mate; |
340 | 340 | ||
341 | mate->chipset = ide_ht6560b; | 341 | mate->chipset = ide_ht6560b; |
342 | mate->selectproc = &ht6560b_selectproc; | 342 | mate->selectproc = &ht6560b_selectproc; |
343 | mate->host_flags = IDE_HFLAG_ABUSE_PREFETCH; | ||
343 | mate->pio_mask = ATA_PIO5; | 344 | mate->pio_mask = ATA_PIO5; |
344 | mate->tuneproc = &tune_ht6560b; | 345 | mate->set_pio_mode = &ht6560b_set_pio_mode; |
345 | mate->serialized = 1; /* is this needed? */ | 346 | mate->serialized = 1; /* is this needed? */ |
346 | mate->mate = hwif; | 347 | mate->mate = hwif; |
347 | mate->channel = 1; | 348 | mate->channel = 1; |
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c index 8b87a424094a..0c81d2d0b941 100644 --- a/drivers/ide/legacy/qd65xx.c +++ b/drivers/ide/legacy/qd65xx.c | |||
@@ -224,15 +224,14 @@ static void qd_set_timing (ide_drive_t *drive, u8 timing) | |||
224 | printk(KERN_DEBUG "%s: %#x\n", drive->name, timing); | 224 | printk(KERN_DEBUG "%s: %#x\n", drive->name, timing); |
225 | } | 225 | } |
226 | 226 | ||
227 | /* | 227 | static void qd6500_set_pio_mode(ide_drive_t *drive, const u8 pio) |
228 | * qd6500_tune_drive | ||
229 | */ | ||
230 | |||
231 | static void qd6500_tune_drive (ide_drive_t *drive, u8 pio) | ||
232 | { | 228 | { |
233 | int active_time = 175; | 229 | int active_time = 175; |
234 | int recovery_time = 415; /* worst case values from the dos driver */ | 230 | int recovery_time = 415; /* worst case values from the dos driver */ |
235 | 231 | ||
232 | /* | ||
233 | * FIXME: use "pio" value | ||
234 | */ | ||
236 | if (drive->id && !qd_find_disk_type(drive, &active_time, &recovery_time) | 235 | if (drive->id && !qd_find_disk_type(drive, &active_time, &recovery_time) |
237 | && drive->id->tPIO && (drive->id->field_valid & 0x02) | 236 | && drive->id->tPIO && (drive->id->field_valid & 0x02) |
238 | && drive->id->eide_pio >= 240) { | 237 | && drive->id->eide_pio >= 240) { |
@@ -246,11 +245,7 @@ static void qd6500_tune_drive (ide_drive_t *drive, u8 pio) | |||
246 | qd_set_timing(drive, qd6500_compute_timing(HWIF(drive), active_time, recovery_time)); | 245 | qd_set_timing(drive, qd6500_compute_timing(HWIF(drive), active_time, recovery_time)); |
247 | } | 246 | } |
248 | 247 | ||
249 | /* | 248 | static void qd6580_set_pio_mode(ide_drive_t *drive, const u8 pio) |
250 | * qd6580_tune_drive | ||
251 | */ | ||
252 | |||
253 | static void qd6580_tune_drive (ide_drive_t *drive, u8 pio) | ||
254 | { | 249 | { |
255 | int base = HWIF(drive)->select_data; | 250 | int base = HWIF(drive)->select_data; |
256 | unsigned int cycle_time; | 251 | unsigned int cycle_time; |
@@ -258,7 +253,6 @@ static void qd6580_tune_drive (ide_drive_t *drive, u8 pio) | |||
258 | int recovery_time = 415; /* worst case values from the dos driver */ | 253 | int recovery_time = 415; /* worst case values from the dos driver */ |
259 | 254 | ||
260 | if (drive->id && !qd_find_disk_type(drive, &active_time, &recovery_time)) { | 255 | if (drive->id && !qd_find_disk_type(drive, &active_time, &recovery_time)) { |
261 | pio = ide_get_best_pio_mode(drive, pio, 4); | ||
262 | cycle_time = ide_pio_cycle_time(drive, pio); | 256 | cycle_time = ide_pio_cycle_time(drive, pio); |
263 | 257 | ||
264 | switch (pio) { | 258 | switch (pio) { |
@@ -335,8 +329,7 @@ static int __init qd_testreg(int port) | |||
335 | */ | 329 | */ |
336 | 330 | ||
337 | static void __init qd_setup(ide_hwif_t *hwif, int base, int config, | 331 | static void __init qd_setup(ide_hwif_t *hwif, int base, int config, |
338 | unsigned int data0, unsigned int data1, | 332 | unsigned int data0, unsigned int data1) |
339 | void (*tuneproc) (ide_drive_t *, u8 pio)) | ||
340 | { | 333 | { |
341 | hwif->chipset = ide_qd65xx; | 334 | hwif->chipset = ide_qd65xx; |
342 | hwif->channel = hwif->index; | 335 | hwif->channel = hwif->index; |
@@ -347,8 +340,6 @@ static void __init qd_setup(ide_hwif_t *hwif, int base, int config, | |||
347 | hwif->drives[0].io_32bit = | 340 | hwif->drives[0].io_32bit = |
348 | hwif->drives[1].io_32bit = 1; | 341 | hwif->drives[1].io_32bit = 1; |
349 | hwif->pio_mask = ATA_PIO4; | 342 | hwif->pio_mask = ATA_PIO4; |
350 | hwif->tuneproc = tuneproc; | ||
351 | probe_hwif_init(hwif); | ||
352 | } | 343 | } |
353 | 344 | ||
354 | /* | 345 | /* |
@@ -361,7 +352,7 @@ static void __exit qd_unsetup(ide_hwif_t *hwif) | |||
361 | { | 352 | { |
362 | u8 config = hwif->config_data; | 353 | u8 config = hwif->config_data; |
363 | int base = hwif->select_data; | 354 | int base = hwif->select_data; |
364 | void *tuneproc = (void *) hwif->tuneproc; | 355 | void *set_pio_mode = (void *)hwif->set_pio_mode; |
365 | 356 | ||
366 | if (hwif->chipset != ide_qd65xx) | 357 | if (hwif->chipset != ide_qd65xx) |
367 | return; | 358 | return; |
@@ -369,12 +360,12 @@ static void __exit qd_unsetup(ide_hwif_t *hwif) | |||
369 | printk(KERN_NOTICE "%s: back to defaults\n", hwif->name); | 360 | printk(KERN_NOTICE "%s: back to defaults\n", hwif->name); |
370 | 361 | ||
371 | hwif->selectproc = NULL; | 362 | hwif->selectproc = NULL; |
372 | hwif->tuneproc = NULL; | 363 | hwif->set_pio_mode = NULL; |
373 | 364 | ||
374 | if (tuneproc == (void *) qd6500_tune_drive) { | 365 | if (set_pio_mode == (void *)qd6500_set_pio_mode) { |
375 | // will do it for both | 366 | // will do it for both |
376 | qd_write_reg(QD6500_DEF_DATA, QD_TIMREG(&hwif->drives[0])); | 367 | qd_write_reg(QD6500_DEF_DATA, QD_TIMREG(&hwif->drives[0])); |
377 | } else if (tuneproc == (void *) qd6580_tune_drive) { | 368 | } else if (set_pio_mode == (void *)qd6580_set_pio_mode) { |
378 | if (QD_CONTROL(hwif) & QD_CONTR_SEC_DISABLED) { | 369 | if (QD_CONTROL(hwif) & QD_CONTR_SEC_DISABLED) { |
379 | qd_write_reg(QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0])); | 370 | qd_write_reg(QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0])); |
380 | qd_write_reg(QD6580_DEF_DATA2, QD_TIMREG(&hwif->drives[1])); | 371 | qd_write_reg(QD6580_DEF_DATA2, QD_TIMREG(&hwif->drives[1])); |
@@ -424,8 +415,11 @@ static int __init qd_probe(int base) | |||
424 | return 1; | 415 | return 1; |
425 | } | 416 | } |
426 | 417 | ||
427 | qd_setup(hwif, base, config, QD6500_DEF_DATA, QD6500_DEF_DATA, | 418 | qd_setup(hwif, base, config, QD6500_DEF_DATA, QD6500_DEF_DATA); |
428 | &qd6500_tune_drive); | 419 | |
420 | hwif->set_pio_mode = &qd6500_set_pio_mode; | ||
421 | |||
422 | probe_hwif_init(hwif); | ||
429 | 423 | ||
430 | ide_proc_register_port(hwif); | 424 | ide_proc_register_port(hwif); |
431 | 425 | ||
@@ -455,8 +449,12 @@ static int __init qd_probe(int base) | |||
455 | printk(KERN_INFO "%s: qd6580: single IDE board\n", | 449 | printk(KERN_INFO "%s: qd6580: single IDE board\n", |
456 | hwif->name); | 450 | hwif->name); |
457 | qd_setup(hwif, base, config | (control << 8), | 451 | qd_setup(hwif, base, config | (control << 8), |
458 | QD6580_DEF_DATA, QD6580_DEF_DATA2, | 452 | QD6580_DEF_DATA, QD6580_DEF_DATA2); |
459 | &qd6580_tune_drive); | 453 | |
454 | hwif->set_pio_mode = &qd6580_set_pio_mode; | ||
455 | |||
456 | probe_hwif_init(hwif); | ||
457 | |||
460 | qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT); | 458 | qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT); |
461 | 459 | ||
462 | ide_proc_register_port(hwif); | 460 | ide_proc_register_port(hwif); |
@@ -472,11 +470,19 @@ static int __init qd_probe(int base) | |||
472 | hwif->name, mate->name); | 470 | hwif->name, mate->name); |
473 | 471 | ||
474 | qd_setup(hwif, base, config | (control << 8), | 472 | qd_setup(hwif, base, config | (control << 8), |
475 | QD6580_DEF_DATA, QD6580_DEF_DATA, | 473 | QD6580_DEF_DATA, QD6580_DEF_DATA); |
476 | &qd6580_tune_drive); | 474 | |
475 | hwif->set_pio_mode = &qd6580_set_pio_mode; | ||
476 | |||
477 | probe_hwif_init(hwif); | ||
478 | |||
477 | qd_setup(mate, base, config | (control << 8), | 479 | qd_setup(mate, base, config | (control << 8), |
478 | QD6580_DEF_DATA2, QD6580_DEF_DATA2, | 480 | QD6580_DEF_DATA2, QD6580_DEF_DATA2); |
479 | &qd6580_tune_drive); | 481 | |
482 | mate->set_pio_mode = &qd6580_set_pio_mode; | ||
483 | |||
484 | probe_hwif_init(mate); | ||
485 | |||
480 | qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT); | 486 | qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT); |
481 | 487 | ||
482 | ide_proc_register_port(hwif); | 488 | ide_proc_register_port(hwif); |
diff --git a/drivers/ide/legacy/umc8672.c b/drivers/ide/legacy/umc8672.c index d2862e638bc5..1151c92dd531 100644 --- a/drivers/ide/legacy/umc8672.c +++ b/drivers/ide/legacy/umc8672.c | |||
@@ -105,12 +105,11 @@ static void umc_set_speeds (u8 speeds[]) | |||
105 | speeds[0], speeds[1], speeds[2], speeds[3]); | 105 | speeds[0], speeds[1], speeds[2], speeds[3]); |
106 | } | 106 | } |
107 | 107 | ||
108 | static void tune_umc (ide_drive_t *drive, u8 pio) | 108 | static void umc_set_pio_mode(ide_drive_t *drive, const u8 pio) |
109 | { | 109 | { |
110 | unsigned long flags; | 110 | unsigned long flags; |
111 | ide_hwgroup_t *hwgroup = ide_hwifs[HWIF(drive)->index^1].hwgroup; | 111 | ide_hwgroup_t *hwgroup = ide_hwifs[HWIF(drive)->index^1].hwgroup; |
112 | 112 | ||
113 | pio = ide_get_best_pio_mode(drive, pio, 4); | ||
114 | printk("%s: setting umc8672 to PIO mode%d (speed %d)\n", | 113 | printk("%s: setting umc8672 to PIO mode%d (speed %d)\n", |
115 | drive->name, pio, pio_to_umc[pio]); | 114 | drive->name, pio, pio_to_umc[pio]); |
116 | spin_lock_irqsave(&ide_lock, flags); | 115 | spin_lock_irqsave(&ide_lock, flags); |
@@ -150,12 +149,12 @@ static int __init umc8672_probe(void) | |||
150 | 149 | ||
151 | hwif->chipset = ide_umc8672; | 150 | hwif->chipset = ide_umc8672; |
152 | hwif->pio_mask = ATA_PIO4; | 151 | hwif->pio_mask = ATA_PIO4; |
153 | hwif->tuneproc = &tune_umc; | 152 | hwif->set_pio_mode = &umc_set_pio_mode; |
154 | hwif->mate = mate; | 153 | hwif->mate = mate; |
155 | 154 | ||
156 | mate->chipset = ide_umc8672; | 155 | mate->chipset = ide_umc8672; |
157 | mate->pio_mask = ATA_PIO4; | 156 | mate->pio_mask = ATA_PIO4; |
158 | mate->tuneproc = &tune_umc; | 157 | mate->set_pio_mode = &umc_set_pio_mode; |
159 | mate->mate = hwif; | 158 | mate->mate = hwif; |
160 | mate->channel = 1; | 159 | mate->channel = 1; |
161 | 160 | ||