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/qd65xx.c | |
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/qd65xx.c')
-rw-r--r-- | drivers/ide/legacy/qd65xx.c | 60 |
1 files changed, 33 insertions, 27 deletions
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); |