aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-lib.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-10-11 17:54:00 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-10-11 17:54:00 -0400
commit26bcb879c03254545a19c6700fe5bcef6f21e7b1 (patch)
treedc35f1a7d7860fe0de268ff92189ff0884b689d3 /drivers/ide/ide-lib.c
parent842c19ad6fc0dbd9ac9d2f8527466201802934cf (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/ide-lib.c')
-rw-r--r--drivers/ide/ide-lib.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index 957618849540..8400b1b4aa1b 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -325,6 +325,35 @@ u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode)
325 325
326EXPORT_SYMBOL_GPL(ide_get_best_pio_mode); 326EXPORT_SYMBOL_GPL(ide_get_best_pio_mode);
327 327
328/* req_pio == "255" for auto-tune */
329void ide_set_pio(ide_drive_t *drive, u8 req_pio)
330{
331 ide_hwif_t *hwif = drive->hwif;
332 u8 host_pio, pio;
333
334 if (hwif->set_pio_mode == NULL)
335 return;
336
337 BUG_ON(hwif->pio_mask == 0x00);
338
339 host_pio = fls(hwif->pio_mask) - 1;
340
341 pio = ide_get_best_pio_mode(drive, req_pio, host_pio);
342
343 /*
344 * TODO:
345 * - report device max PIO mode
346 * - check req_pio != 255 against device max PIO mode
347 */
348 printk(KERN_DEBUG "%s: host max PIO%d wanted PIO%d%s selected PIO%d\n",
349 drive->name, host_pio, req_pio,
350 req_pio == 255 ? "(auto-tune)" : "", pio);
351
352 hwif->set_pio_mode(drive, pio);
353}
354
355EXPORT_SYMBOL_GPL(ide_set_pio);
356
328/** 357/**
329 * ide_toggle_bounce - handle bounce buffering 358 * ide_toggle_bounce - handle bounce buffering
330 * @drive: drive to update 359 * @drive: drive to update