aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci/alim15x3.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/pci/alim15x3.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/pci/alim15x3.c')
-rw-r--r--drivers/ide/pci/alim15x3.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
index 37ecd726aa40..005402ab748b 100644
--- a/drivers/ide/pci/alim15x3.c
+++ b/drivers/ide/pci/alim15x3.c
@@ -283,17 +283,14 @@ static int ali_get_info (char *buffer, char **addr, off_t offset, int count)
283#endif /* defined(DISPLAY_ALI_TIMINGS) && defined(CONFIG_IDE_PROC_FS) */ 283#endif /* defined(DISPLAY_ALI_TIMINGS) && defined(CONFIG_IDE_PROC_FS) */
284 284
285/** 285/**
286 * ali15x3_tune_pio - set up chipset for PIO mode 286 * ali_tune_pio - set host controller for PIO mode
287 * @drive: drive to tune 287 * @drive: drive
288 * @pio: desired mode 288 * @pio: PIO mode number
289 *
290 * Select the best PIO mode for the drive in question.
291 * Then program the controller for this mode.
292 * 289 *
293 * Returns the PIO mode programmed. 290 * Program the controller for the given PIO mode.
294 */ 291 */
295 292
296static u8 ali15x3_tune_pio (ide_drive_t *drive, u8 pio) 293static void ali_tune_pio(ide_drive_t *drive, const u8 pio)
297{ 294{
298 ide_hwif_t *hwif = HWIF(drive); 295 ide_hwif_t *hwif = HWIF(drive);
299 struct pci_dev *dev = hwif->pci_dev; 296 struct pci_dev *dev = hwif->pci_dev;
@@ -306,7 +303,6 @@ static u8 ali15x3_tune_pio (ide_drive_t *drive, u8 pio)
306 u8 cd_dma_fifo = 0; 303 u8 cd_dma_fifo = 0;
307 int unit = drive->select.b.unit & 1; 304 int unit = drive->select.b.unit & 1;
308 305
309 pio = ide_get_best_pio_mode(drive, pio, 5);
310 s_time = ide_pio_timings[pio].setup_time; 306 s_time = ide_pio_timings[pio].setup_time;
311 a_time = ide_pio_timings[pio].active_time; 307 a_time = ide_pio_timings[pio].active_time;
312 if ((s_clc = (s_time * bus_speed + 999) / 1000) >= 8) 308 if ((s_clc = (s_time * bus_speed + 999) / 1000) >= 8)
@@ -359,22 +355,20 @@ static u8 ali15x3_tune_pio (ide_drive_t *drive, u8 pio)
359 * { 25, 70, 25 }, PIO Mode 4 with IORDY ns 355 * { 25, 70, 25 }, PIO Mode 4 with IORDY ns
360 * { 20, 50, 30 } PIO Mode 5 with IORDY (nonstandard) 356 * { 20, 50, 30 } PIO Mode 5 with IORDY (nonstandard)
361 */ 357 */
362
363 return pio;
364} 358}
365 359
366/** 360/**
367 * ali15x3_tune_drive - set up drive for PIO mode 361 * ali_set_pio_mode - set up drive for PIO mode
368 * @drive: drive to tune 362 * @drive: drive to tune
369 * @pio: desired mode 363 * @pio: desired mode
370 * 364 *
371 * Program the controller with the best PIO timing for the given drive. 365 * Program the controller with the desired PIO timing for the given drive.
372 * Then set up the drive itself. 366 * Then set up the drive itself.
373 */ 367 */
374 368
375static void ali15x3_tune_drive (ide_drive_t *drive, u8 pio) 369static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
376{ 370{
377 pio = ali15x3_tune_pio(drive, pio); 371 ali_tune_pio(drive, pio);
378 (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio); 372 (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio);
379} 373}
380 374
@@ -437,7 +431,7 @@ static int ali15x3_tune_chipset(ide_drive_t *drive, const u8 speed)
437 pci_write_config_byte(dev, m5229_udma, tmpbyte); 431 pci_write_config_byte(dev, m5229_udma, tmpbyte);
438 432
439 if (speed < XFER_SW_DMA_0) 433 if (speed < XFER_SW_DMA_0)
440 (void) ali15x3_tune_pio(drive, speed - XFER_PIO_0); 434 ali_tune_pio(drive, speed - XFER_PIO_0);
441 } else { 435 } else {
442 pci_read_config_byte(dev, m5229_udma, &tmpbyte); 436 pci_read_config_byte(dev, m5229_udma, &tmpbyte);
443 tmpbyte &= (0x0f << ((1-unit) << 2)); 437 tmpbyte &= (0x0f << ((1-unit) << 2));
@@ -470,7 +464,7 @@ static int ali15x3_config_drive_for_dma(ide_drive_t *drive)
470 if (ide_tune_dma(drive)) 464 if (ide_tune_dma(drive))
471 return 0; 465 return 0;
472 466
473 ali15x3_tune_drive(drive, 255); 467 ide_set_max_pio(drive);
474 468
475 return -1; 469 return -1;
476} 470}
@@ -700,7 +694,7 @@ static u8 __devinit ata66_ali15x3(ide_hwif_t *hwif)
700static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif) 694static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif)
701{ 695{
702 hwif->autodma = 0; 696 hwif->autodma = 0;
703 hwif->tuneproc = &ali15x3_tune_drive; 697 hwif->set_pio_mode = &ali_set_pio_mode;
704 hwif->speedproc = &ali15x3_tune_chipset; 698 hwif->speedproc = &ali15x3_tune_chipset;
705 hwif->udma_filter = &ali_udma_filter; 699 hwif->udma_filter = &ali_udma_filter;
706 700