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/pci | |
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/pci')
30 files changed, 174 insertions, 224 deletions
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c index a827ea2ab989..0d5f62c5dfae 100644 --- a/drivers/ide/pci/aec62xx.c +++ b/drivers/ide/pci/aec62xx.c | |||
@@ -138,9 +138,8 @@ static int aec6260_tune_chipset(ide_drive_t *drive, const u8 speed) | |||
138 | return(ide_config_drive_speed(drive, speed)); | 138 | return(ide_config_drive_speed(drive, speed)); |
139 | } | 139 | } |
140 | 140 | ||
141 | static void aec62xx_tune_drive (ide_drive_t *drive, u8 pio) | 141 | static void aec_set_pio_mode(ide_drive_t *drive, const u8 pio) |
142 | { | 142 | { |
143 | pio = ide_get_best_pio_mode(drive, pio, 4); | ||
144 | (void) HWIF(drive)->speedproc(drive, pio + XFER_PIO_0); | 143 | (void) HWIF(drive)->speedproc(drive, pio + XFER_PIO_0); |
145 | } | 144 | } |
146 | 145 | ||
@@ -150,7 +149,7 @@ static int aec62xx_config_drive_xfer_rate (ide_drive_t *drive) | |||
150 | return 0; | 149 | return 0; |
151 | 150 | ||
152 | if (ide_use_fast_pio(drive)) | 151 | if (ide_use_fast_pio(drive)) |
153 | aec62xx_tune_drive(drive, 255); | 152 | ide_set_max_pio(drive); |
154 | 153 | ||
155 | return -1; | 154 | return -1; |
156 | } | 155 | } |
@@ -201,7 +200,7 @@ static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif) | |||
201 | u8 reg54 = 0, mask = hwif->channel ? 0xf0 : 0x0f; | 200 | u8 reg54 = 0, mask = hwif->channel ? 0xf0 : 0x0f; |
202 | unsigned long flags; | 201 | unsigned long flags; |
203 | 202 | ||
204 | hwif->tuneproc = &aec62xx_tune_drive; | 203 | hwif->set_pio_mode = &aec_set_pio_mode; |
205 | 204 | ||
206 | if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) { | 205 | if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) { |
207 | if(hwif->mate) | 206 | if(hwif->mate) |
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 | ||
296 | static u8 ali15x3_tune_pio (ide_drive_t *drive, u8 pio) | 293 | static 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 | ||
375 | static void ali15x3_tune_drive (ide_drive_t *drive, u8 pio) | 369 | static 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) | |||
700 | static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif) | 694 | static 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 | ||
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c index 9abbde3c7984..1088ba86cd1d 100644 --- a/drivers/ide/pci/amd74xx.c +++ b/drivers/ide/pci/amd74xx.c | |||
@@ -266,16 +266,12 @@ static int amd_set_drive(ide_drive_t *drive, const u8 speed) | |||
266 | } | 266 | } |
267 | 267 | ||
268 | /* | 268 | /* |
269 | * amd74xx_tune_drive() is a callback from upper layers for | 269 | * amd_set_pio_mode() is a callback from upper layers for PIO-only tuning. |
270 | * PIO-only tuning. | ||
271 | */ | 270 | */ |
272 | 271 | ||
273 | static void amd74xx_tune_drive(ide_drive_t *drive, u8 pio) | 272 | static void amd_set_pio_mode(ide_drive_t *drive, const u8 pio) |
274 | { | 273 | { |
275 | if (pio == 255) | 274 | amd_set_drive(drive, XFER_PIO_0 + pio); |
276 | pio = ide_get_best_pio_mode(drive, 255, 5); | ||
277 | |||
278 | amd_set_drive(drive, XFER_PIO_0 + min_t(byte, pio, 5)); | ||
279 | } | 275 | } |
280 | 276 | ||
281 | static int amd74xx_ide_dma_check(ide_drive_t *drive) | 277 | static int amd74xx_ide_dma_check(ide_drive_t *drive) |
@@ -283,7 +279,7 @@ static int amd74xx_ide_dma_check(ide_drive_t *drive) | |||
283 | u8 speed = ide_max_dma_mode(drive); | 279 | u8 speed = ide_max_dma_mode(drive); |
284 | 280 | ||
285 | if (speed == 0) { | 281 | if (speed == 0) { |
286 | amd74xx_tune_drive(drive, 255); | 282 | ide_set_max_pio(drive); |
287 | return -1; | 283 | return -1; |
288 | } | 284 | } |
289 | 285 | ||
@@ -409,7 +405,7 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) | |||
409 | 405 | ||
410 | hwif->autodma = 0; | 406 | hwif->autodma = 0; |
411 | 407 | ||
412 | hwif->tuneproc = &amd74xx_tune_drive; | 408 | hwif->set_pio_mode = &amd_set_pio_mode; |
413 | hwif->speedproc = &amd_set_drive; | 409 | hwif->speedproc = &amd_set_drive; |
414 | 410 | ||
415 | for (i = 0; i < 2; i++) { | 411 | for (i = 0; i < 2; i++) { |
diff --git a/drivers/ide/pci/atiixp.c b/drivers/ide/pci/atiixp.c index e05e88298500..b9f66f53f9a6 100644 --- a/drivers/ide/pci/atiixp.c +++ b/drivers/ide/pci/atiixp.c | |||
@@ -153,9 +153,8 @@ static void atiixp_tune_pio(ide_drive_t *drive, u8 pio) | |||
153 | spin_unlock_irqrestore(&atiixp_lock, flags); | 153 | spin_unlock_irqrestore(&atiixp_lock, flags); |
154 | } | 154 | } |
155 | 155 | ||
156 | static void atiixp_tuneproc(ide_drive_t *drive, u8 pio) | 156 | static void atiixp_set_pio_mode(ide_drive_t *drive, const u8 pio) |
157 | { | 157 | { |
158 | pio = ide_get_best_pio_mode(drive, pio, 4); | ||
159 | atiixp_tune_pio(drive, pio); | 158 | atiixp_tune_pio(drive, pio); |
160 | (void)ide_config_drive_speed(drive, XFER_PIO_0 + pio); | 159 | (void)ide_config_drive_speed(drive, XFER_PIO_0 + pio); |
161 | } | 160 | } |
@@ -231,7 +230,7 @@ static int atiixp_dma_check(ide_drive_t *drive) | |||
231 | return 0; | 230 | return 0; |
232 | 231 | ||
233 | if (ide_use_fast_pio(drive)) | 232 | if (ide_use_fast_pio(drive)) |
234 | atiixp_tuneproc(drive, 255); | 233 | ide_set_max_pio(drive); |
235 | 234 | ||
236 | return -1; | 235 | return -1; |
237 | } | 236 | } |
@@ -254,7 +253,7 @@ static void __devinit init_hwif_atiixp(ide_hwif_t *hwif) | |||
254 | hwif->irq = ch ? 15 : 14; | 253 | hwif->irq = ch ? 15 : 14; |
255 | 254 | ||
256 | hwif->autodma = 0; | 255 | hwif->autodma = 0; |
257 | hwif->tuneproc = &atiixp_tuneproc; | 256 | hwif->set_pio_mode = &atiixp_set_pio_mode; |
258 | hwif->speedproc = &atiixp_speedproc; | 257 | hwif->speedproc = &atiixp_speedproc; |
259 | hwif->drives[0].autotune = 1; | 258 | hwif->drives[0].autotune = 1; |
260 | hwif->drives[1].autotune = 1; | 259 | hwif->drives[1].autotune = 1; |
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c index 9689494efa24..f369645e4d16 100644 --- a/drivers/ide/pci/cmd640.c +++ b/drivers/ide/pci/cmd640.c | |||
@@ -628,45 +628,40 @@ static void cmd640_set_mode (unsigned int index, u8 pio_mode, unsigned int cycle | |||
628 | program_drive_counts (index); | 628 | program_drive_counts (index); |
629 | } | 629 | } |
630 | 630 | ||
631 | /* | 631 | static void cmd640_set_pio_mode(ide_drive_t *drive, const u8 pio) |
632 | * Drive PIO mode selection: | ||
633 | */ | ||
634 | static void cmd640_tune_drive (ide_drive_t *drive, u8 mode_wanted) | ||
635 | { | 632 | { |
636 | unsigned int index = 0, cycle_time; | 633 | unsigned int index = 0, cycle_time; |
637 | u8 b; | 634 | u8 b; |
638 | 635 | ||
639 | while (drive != cmd_drives[index]) { | 636 | while (drive != cmd_drives[index]) { |
640 | if (++index > 3) { | 637 | if (++index > 3) { |
641 | printk("%s: bad news in cmd640_tune_drive\n", drive->name); | 638 | printk(KERN_ERR "%s: bad news in %s\n", |
639 | drive->name, __FUNCTION__); | ||
642 | return; | 640 | return; |
643 | } | 641 | } |
644 | } | 642 | } |
645 | switch (mode_wanted) { | 643 | switch (pio) { |
646 | case 6: /* set fast-devsel off */ | 644 | case 6: /* set fast-devsel off */ |
647 | case 7: /* set fast-devsel on */ | 645 | case 7: /* set fast-devsel on */ |
648 | mode_wanted &= 1; | ||
649 | b = get_cmd640_reg(CNTRL) & ~0x27; | 646 | b = get_cmd640_reg(CNTRL) & ~0x27; |
650 | if (mode_wanted) | 647 | if (pio & 1) |
651 | b |= 0x27; | 648 | b |= 0x27; |
652 | put_cmd640_reg(CNTRL, b); | 649 | put_cmd640_reg(CNTRL, b); |
653 | printk("%s: %sabled cmd640 fast host timing (devsel)\n", drive->name, mode_wanted ? "en" : "dis"); | 650 | printk("%s: %sabled cmd640 fast host timing (devsel)\n", drive->name, (pio & 1) ? "en" : "dis"); |
654 | return; | 651 | return; |
655 | 652 | ||
656 | case 8: /* set prefetch off */ | 653 | case 8: /* set prefetch off */ |
657 | case 9: /* set prefetch on */ | 654 | case 9: /* set prefetch on */ |
658 | mode_wanted &= 1; | 655 | set_prefetch_mode(index, pio & 1); |
659 | set_prefetch_mode(index, mode_wanted); | 656 | printk("%s: %sabled cmd640 prefetch\n", drive->name, (pio & 1) ? "en" : "dis"); |
660 | printk("%s: %sabled cmd640 prefetch\n", drive->name, mode_wanted ? "en" : "dis"); | ||
661 | return; | 657 | return; |
662 | } | 658 | } |
663 | 659 | ||
664 | mode_wanted = ide_get_best_pio_mode(drive, mode_wanted, 5); | 660 | cycle_time = ide_pio_cycle_time(drive, pio); |
665 | cycle_time = ide_pio_cycle_time(drive, mode_wanted); | 661 | cmd640_set_mode(index, pio, cycle_time); |
666 | cmd640_set_mode(index, mode_wanted, cycle_time); | ||
667 | 662 | ||
668 | printk("%s: selected cmd640 PIO mode%d (%dns)", | 663 | printk("%s: selected cmd640 PIO mode%d (%dns)", |
669 | drive->name, mode_wanted, cycle_time); | 664 | drive->name, pio, cycle_time); |
670 | 665 | ||
671 | display_clocks(index); | 666 | display_clocks(index); |
672 | } | 667 | } |
@@ -766,8 +761,10 @@ int __init ide_probe_for_cmd640x (void) | |||
766 | cmd_hwif0->name, 'a' + cmd640_chip_version - 1, bus_type, cfr); | 761 | cmd_hwif0->name, 'a' + cmd640_chip_version - 1, bus_type, cfr); |
767 | cmd_hwif0->chipset = ide_cmd640; | 762 | cmd_hwif0->chipset = ide_cmd640; |
768 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | 763 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED |
764 | cmd_hwif0->host_flags = IDE_HFLAG_ABUSE_PREFETCH | | ||
765 | IDE_HFLAG_ABUSE_FAST_DEVSEL; | ||
769 | cmd_hwif0->pio_mask = ATA_PIO5; | 766 | cmd_hwif0->pio_mask = ATA_PIO5; |
770 | cmd_hwif0->tuneproc = &cmd640_tune_drive; | 767 | cmd_hwif0->set_pio_mode = &cmd640_set_pio_mode; |
771 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ | 768 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ |
772 | 769 | ||
773 | /* | 770 | /* |
@@ -822,8 +819,10 @@ int __init ide_probe_for_cmd640x (void) | |||
822 | cmd_hwif1->mate = cmd_hwif0; | 819 | cmd_hwif1->mate = cmd_hwif0; |
823 | cmd_hwif1->channel = 1; | 820 | cmd_hwif1->channel = 1; |
824 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | 821 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED |
822 | cmd_hwif1->host_flags = IDE_HFLAG_ABUSE_PREFETCH | | ||
823 | IDE_HFLAG_ABUSE_FAST_DEVSEL; | ||
825 | cmd_hwif1->pio_mask = ATA_PIO5; | 824 | cmd_hwif1->pio_mask = ATA_PIO5; |
826 | cmd_hwif1->tuneproc = &cmd640_tune_drive; | 825 | cmd_hwif1->set_pio_mode = &cmd640_set_pio_mode; |
827 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ | 826 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ |
828 | } | 827 | } |
829 | printk(KERN_INFO "%s: %sserialized, secondary interface %s\n", cmd_hwif1->name, | 828 | printk(KERN_INFO "%s: %sserialized, secondary interface %s\n", cmd_hwif1->name, |
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c index 5fe50a234ce1..85f5e42eb831 100644 --- a/drivers/ide/pci/cmd64x.c +++ b/drivers/ide/pci/cmd64x.c | |||
@@ -214,28 +214,25 @@ static void program_cycle_times (ide_drive_t *drive, int cycle_time, int active_ | |||
214 | } | 214 | } |
215 | 215 | ||
216 | /* | 216 | /* |
217 | * This routine selects drive's best PIO mode and writes into the chipset | 217 | * This routine writes into the chipset registers |
218 | * registers setup/active/recovery timings. | 218 | * PIO setup/active/recovery timings. |
219 | */ | 219 | */ |
220 | static u8 cmd64x_tune_pio (ide_drive_t *drive, u8 mode_wanted) | 220 | static void cmd64x_tune_pio(ide_drive_t *drive, const u8 pio) |
221 | { | 221 | { |
222 | ide_hwif_t *hwif = HWIF(drive); | 222 | ide_hwif_t *hwif = HWIF(drive); |
223 | struct pci_dev *dev = hwif->pci_dev; | 223 | struct pci_dev *dev = hwif->pci_dev; |
224 | unsigned int cycle_time; | 224 | unsigned int cycle_time; |
225 | u8 pio_mode, setup_count, arttim = 0; | 225 | u8 setup_count, arttim = 0; |
226 | |||
226 | static const u8 setup_values[] = {0x40, 0x40, 0x40, 0x80, 0, 0xc0}; | 227 | static const u8 setup_values[] = {0x40, 0x40, 0x40, 0x80, 0, 0xc0}; |
227 | static const u8 arttim_regs[4] = {ARTTIM0, ARTTIM1, ARTTIM23, ARTTIM23}; | 228 | static const u8 arttim_regs[4] = {ARTTIM0, ARTTIM1, ARTTIM23, ARTTIM23}; |
228 | 229 | ||
229 | pio_mode = ide_get_best_pio_mode(drive, mode_wanted, 5); | 230 | cycle_time = ide_pio_cycle_time(drive, pio); |
230 | cycle_time = ide_pio_cycle_time(drive, pio_mode); | ||
231 | |||
232 | cmdprintk("%s: PIO mode wanted %d, selected %d (%d ns)\n", | ||
233 | drive->name, mode_wanted, pio_mode, cycle_time); | ||
234 | 231 | ||
235 | program_cycle_times(drive, cycle_time, | 232 | program_cycle_times(drive, cycle_time, |
236 | ide_pio_timings[pio_mode].active_time); | 233 | ide_pio_timings[pio].active_time); |
237 | 234 | ||
238 | setup_count = quantize_timing(ide_pio_timings[pio_mode].setup_time, | 235 | setup_count = quantize_timing(ide_pio_timings[pio].setup_time, |
239 | 1000 / system_bus_clock()); | 236 | 1000 / system_bus_clock()); |
240 | 237 | ||
241 | /* | 238 | /* |
@@ -266,16 +263,14 @@ static u8 cmd64x_tune_pio (ide_drive_t *drive, u8 mode_wanted) | |||
266 | arttim |= setup_values[setup_count]; | 263 | arttim |= setup_values[setup_count]; |
267 | (void) pci_write_config_byte(dev, arttim_regs[drive->dn], arttim); | 264 | (void) pci_write_config_byte(dev, arttim_regs[drive->dn], arttim); |
268 | cmdprintk("Write 0x%02x to reg 0x%x\n", arttim, arttim_regs[drive->dn]); | 265 | cmdprintk("Write 0x%02x to reg 0x%x\n", arttim, arttim_regs[drive->dn]); |
269 | |||
270 | return pio_mode; | ||
271 | } | 266 | } |
272 | 267 | ||
273 | /* | 268 | /* |
274 | * Attempts to set drive's PIO mode. | 269 | * Attempts to set drive's PIO mode. |
275 | * Special cases are 8: prefetch off, 9: prefetch on (both never worked), | 270 | * Special cases are 8: prefetch off, 9: prefetch on (both never worked) |
276 | * and 255: auto-select best mode (used at boot time). | ||
277 | */ | 271 | */ |
278 | static void cmd64x_tune_drive (ide_drive_t *drive, u8 pio) | 272 | |
273 | static void cmd64x_set_pio_mode(ide_drive_t *drive, const u8 pio) | ||
279 | { | 274 | { |
280 | /* | 275 | /* |
281 | * Filter out the prefetch control values | 276 | * Filter out the prefetch control values |
@@ -284,7 +279,7 @@ static void cmd64x_tune_drive (ide_drive_t *drive, u8 pio) | |||
284 | if (pio == 8 || pio == 9) | 279 | if (pio == 8 || pio == 9) |
285 | return; | 280 | return; |
286 | 281 | ||
287 | pio = cmd64x_tune_pio(drive, pio); | 282 | cmd64x_tune_pio(drive, pio); |
288 | (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio); | 283 | (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio); |
289 | } | 284 | } |
290 | 285 | ||
@@ -334,7 +329,7 @@ static int cmd64x_tune_chipset(ide_drive_t *drive, const u8 speed) | |||
334 | case XFER_PIO_2: | 329 | case XFER_PIO_2: |
335 | case XFER_PIO_1: | 330 | case XFER_PIO_1: |
336 | case XFER_PIO_0: | 331 | case XFER_PIO_0: |
337 | (void) cmd64x_tune_pio(drive, speed - XFER_PIO_0); | 332 | cmd64x_tune_pio(drive, speed - XFER_PIO_0); |
338 | break; | 333 | break; |
339 | default: | 334 | default: |
340 | return 1; | 335 | return 1; |
@@ -352,7 +347,7 @@ static int cmd64x_config_drive_for_dma (ide_drive_t *drive) | |||
352 | return 0; | 347 | return 0; |
353 | 348 | ||
354 | if (ide_use_fast_pio(drive)) | 349 | if (ide_use_fast_pio(drive)) |
355 | cmd64x_tune_drive(drive, 255); | 350 | ide_set_max_pio(drive); |
356 | 351 | ||
357 | return -1; | 352 | return -1; |
358 | } | 353 | } |
@@ -536,7 +531,7 @@ static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif) | |||
536 | 531 | ||
537 | pci_read_config_byte(dev, PCI_REVISION_ID, &rev); | 532 | pci_read_config_byte(dev, PCI_REVISION_ID, &rev); |
538 | 533 | ||
539 | hwif->tuneproc = &cmd64x_tune_drive; | 534 | hwif->set_pio_mode = &cmd64x_set_pio_mode; |
540 | hwif->speedproc = &cmd64x_tune_chipset; | 535 | hwif->speedproc = &cmd64x_tune_chipset; |
541 | 536 | ||
542 | hwif->drives[0].autotune = hwif->drives[1].autotune = 1; | 537 | hwif->drives[0].autotune = hwif->drives[1].autotune = 1; |
@@ -620,6 +615,7 @@ static ide_pci_device_t cmd64x_chipsets[] __devinitdata = { | |||
620 | .autodma = AUTODMA, | 615 | .autodma = AUTODMA, |
621 | .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}}, | 616 | .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}}, |
622 | .bootable = ON_BOARD, | 617 | .bootable = ON_BOARD, |
618 | .host_flags = IDE_HFLAG_ABUSE_PREFETCH, | ||
623 | .pio_mask = ATA_PIO5, | 619 | .pio_mask = ATA_PIO5, |
624 | .udma_mask = 0x00, /* no udma */ | 620 | .udma_mask = 0x00, /* no udma */ |
625 | },{ /* 1 */ | 621 | },{ /* 1 */ |
@@ -630,6 +626,7 @@ static ide_pci_device_t cmd64x_chipsets[] __devinitdata = { | |||
630 | .autodma = AUTODMA, | 626 | .autodma = AUTODMA, |
631 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, | 627 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, |
632 | .bootable = ON_BOARD, | 628 | .bootable = ON_BOARD, |
629 | .host_flags = IDE_HFLAG_ABUSE_PREFETCH, | ||
633 | .pio_mask = ATA_PIO5, | 630 | .pio_mask = ATA_PIO5, |
634 | .udma_mask = 0x07, /* udma0-2 */ | 631 | .udma_mask = 0x07, /* udma0-2 */ |
635 | },{ /* 2 */ | 632 | },{ /* 2 */ |
@@ -640,6 +637,7 @@ static ide_pci_device_t cmd64x_chipsets[] __devinitdata = { | |||
640 | .autodma = AUTODMA, | 637 | .autodma = AUTODMA, |
641 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, | 638 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, |
642 | .bootable = ON_BOARD, | 639 | .bootable = ON_BOARD, |
640 | .host_flags = IDE_HFLAG_ABUSE_PREFETCH, | ||
643 | .pio_mask = ATA_PIO5, | 641 | .pio_mask = ATA_PIO5, |
644 | .udma_mask = 0x1f, /* udma0-4 */ | 642 | .udma_mask = 0x1f, /* udma0-4 */ |
645 | },{ /* 3 */ | 643 | },{ /* 3 */ |
@@ -650,6 +648,7 @@ static ide_pci_device_t cmd64x_chipsets[] __devinitdata = { | |||
650 | .autodma = AUTODMA, | 648 | .autodma = AUTODMA, |
651 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, | 649 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, |
652 | .bootable = ON_BOARD, | 650 | .bootable = ON_BOARD, |
651 | .host_flags = IDE_HFLAG_ABUSE_PREFETCH, | ||
653 | .pio_mask = ATA_PIO5, | 652 | .pio_mask = ATA_PIO5, |
654 | .udma_mask = 0x3f, /* udma0-5 */ | 653 | .udma_mask = 0x3f, /* udma0-5 */ |
655 | } | 654 | } |
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c index af67438328a8..a73c318ff086 100644 --- a/drivers/ide/pci/cs5520.c +++ b/drivers/ide/pci/cs5520.c | |||
@@ -122,17 +122,16 @@ static int cs5520_tune_chipset(ide_drive_t *drive, const u8 speed) | |||
122 | 122 | ||
123 | return error; | 123 | return error; |
124 | } | 124 | } |
125 | 125 | ||
126 | static void cs5520_tune_drive(ide_drive_t *drive, u8 pio) | 126 | static void cs5520_set_pio_mode(ide_drive_t *drive, const u8 pio) |
127 | { | 127 | { |
128 | pio = ide_get_best_pio_mode(drive, pio, 4); | 128 | cs5520_tune_chipset(drive, XFER_PIO_0 + pio); |
129 | cs5520_tune_chipset(drive, (XFER_PIO_0 + pio)); | ||
130 | } | 129 | } |
131 | 130 | ||
132 | static int cs5520_config_drive_xfer_rate(ide_drive_t *drive) | 131 | static int cs5520_config_drive_xfer_rate(ide_drive_t *drive) |
133 | { | 132 | { |
134 | /* Tune the drive for PIO modes up to PIO 4 */ | 133 | /* Tune the drive for PIO modes up to PIO 4 */ |
135 | cs5520_tune_drive(drive, 255); | 134 | ide_set_max_pio(drive); |
136 | 135 | ||
137 | /* Then tell the core to use DMA operations */ | 136 | /* Then tell the core to use DMA operations */ |
138 | return 0; | 137 | return 0; |
@@ -164,7 +163,7 @@ static int cs5520_dma_on(ide_drive_t *drive) | |||
164 | 163 | ||
165 | static void __devinit init_hwif_cs5520(ide_hwif_t *hwif) | 164 | static void __devinit init_hwif_cs5520(ide_hwif_t *hwif) |
166 | { | 165 | { |
167 | hwif->tuneproc = &cs5520_tune_drive; | 166 | hwif->set_pio_mode = &cs5520_set_pio_mode; |
168 | hwif->speedproc = &cs5520_tune_chipset; | 167 | hwif->speedproc = &cs5520_tune_chipset; |
169 | hwif->ide_dma_check = &cs5520_config_drive_xfer_rate; | 168 | hwif->ide_dma_check = &cs5520_config_drive_xfer_rate; |
170 | hwif->ide_dma_on = &cs5520_dma_on; | 169 | hwif->ide_dma_on = &cs5520_dma_on; |
diff --git a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c index 518f430c1529..1588a323c5d0 100644 --- a/drivers/ide/pci/cs5530.c +++ b/drivers/ide/pci/cs5530.c | |||
@@ -71,19 +71,18 @@ static void cs5530_tunepio(ide_drive_t *drive, u8 pio) | |||
71 | } | 71 | } |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * cs5530_tuneproc - select/set PIO modes | 74 | * cs5530_set_pio_mode - set PIO mode |
75 | * @drive: drive | ||
76 | * @pio: PIO mode number | ||
75 | * | 77 | * |
76 | * cs5530_tuneproc() handles selection/setting of PIO modes | 78 | * Handles setting of PIO mode for both the chipset and drive. |
77 | * for both the chipset and drive. | ||
78 | * | 79 | * |
79 | * The ide_init_cs5530() routine guarantees that all drives | 80 | * The init_hwif_cs5530() routine guarantees that all drives |
80 | * will have valid default PIO timings set up before we get here. | 81 | * will have valid default PIO timings set up before we get here. |
81 | */ | 82 | */ |
82 | 83 | ||
83 | static void cs5530_tuneproc (ide_drive_t *drive, u8 pio) /* pio=255 means "autotune" */ | 84 | static void cs5530_set_pio_mode(ide_drive_t *drive, const u8 pio) |
84 | { | 85 | { |
85 | pio = ide_get_best_pio_mode(drive, pio, 4); | ||
86 | |||
87 | if (cs5530_set_xfer_mode(drive, XFER_PIO_0 + pio) == 0) | 86 | if (cs5530_set_xfer_mode(drive, XFER_PIO_0 + pio) == 0) |
88 | cs5530_tunepio(drive, pio); | 87 | cs5530_tunepio(drive, pio); |
89 | } | 88 | } |
@@ -306,7 +305,7 @@ static void __devinit init_hwif_cs5530 (ide_hwif_t *hwif) | |||
306 | if (hwif->mate) | 305 | if (hwif->mate) |
307 | hwif->serialized = hwif->mate->serialized = 1; | 306 | hwif->serialized = hwif->mate->serialized = 1; |
308 | 307 | ||
309 | hwif->tuneproc = &cs5530_tuneproc; | 308 | hwif->set_pio_mode = &cs5530_set_pio_mode; |
310 | hwif->speedproc = &cs5530_tune_chipset; | 309 | hwif->speedproc = &cs5530_tune_chipset; |
311 | 310 | ||
312 | basereg = CS5530_BASEREG(hwif); | 311 | basereg = CS5530_BASEREG(hwif); |
diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/pci/cs5535.c index bc00e7b62151..383b7eccbcbb 100644 --- a/drivers/ide/pci/cs5535.c +++ b/drivers/ide/pci/cs5535.c | |||
@@ -147,16 +147,16 @@ static int cs5535_set_drive(ide_drive_t *drive, u8 speed) | |||
147 | return 0; | 147 | return 0; |
148 | } | 148 | } |
149 | 149 | ||
150 | /**** | 150 | /** |
151 | * cs5535_tuneproc - PIO setup | 151 | * cs5535_set_pio_mode - PIO setup |
152 | * @drive: drive to set up | 152 | * @drive: drive |
153 | * @pio: mode to use (255 for 'best possible') | 153 | * @pio: PIO mode number |
154 | * | 154 | * |
155 | * A callback from the upper layers for PIO-only tuning. | 155 | * A callback from the upper layers for PIO-only tuning. |
156 | */ | 156 | */ |
157 | static void cs5535_tuneproc(ide_drive_t *drive, u8 pio) | 157 | |
158 | static void cs5535_set_pio_mode(ide_drive_t *drive, const u8 pio) | ||
158 | { | 159 | { |
159 | pio = ide_get_best_pio_mode(drive, pio, 4); | ||
160 | ide_config_drive_speed(drive, XFER_PIO_0 + pio); | 160 | ide_config_drive_speed(drive, XFER_PIO_0 + pio); |
161 | cs5535_set_speed(drive, XFER_PIO_0 + pio); | 161 | cs5535_set_speed(drive, XFER_PIO_0 + pio); |
162 | } | 162 | } |
@@ -169,7 +169,7 @@ static int cs5535_dma_check(ide_drive_t *drive) | |||
169 | return 0; | 169 | return 0; |
170 | 170 | ||
171 | if (ide_use_fast_pio(drive)) | 171 | if (ide_use_fast_pio(drive)) |
172 | cs5535_tuneproc(drive, 255); | 172 | ide_set_max_pio(drive); |
173 | 173 | ||
174 | return -1; | 174 | return -1; |
175 | } | 175 | } |
@@ -198,7 +198,7 @@ static void __devinit init_hwif_cs5535(ide_hwif_t *hwif) | |||
198 | 198 | ||
199 | hwif->autodma = 0; | 199 | hwif->autodma = 0; |
200 | 200 | ||
201 | hwif->tuneproc = &cs5535_tuneproc; | 201 | hwif->set_pio_mode = &cs5535_set_pio_mode; |
202 | hwif->speedproc = &cs5535_set_drive; | 202 | hwif->speedproc = &cs5535_set_drive; |
203 | hwif->ide_dma_check = &cs5535_dma_check; | 203 | hwif->ide_dma_check = &cs5535_dma_check; |
204 | 204 | ||
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c index daa36fcbc8ef..dc278025d318 100644 --- a/drivers/ide/pci/cy82c693.c +++ b/drivers/ide/pci/cy82c693.c | |||
@@ -97,9 +97,6 @@ | |||
97 | #define CY82_INDEX_CHANNEL1 0x31 | 97 | #define CY82_INDEX_CHANNEL1 0x31 |
98 | #define CY82_INDEX_TIMEOUT 0x32 | 98 | #define CY82_INDEX_TIMEOUT 0x32 |
99 | 99 | ||
100 | /* the max PIO mode - from datasheet */ | ||
101 | #define CY82C693_MAX_PIO 4 | ||
102 | |||
103 | /* the min and max PCI bus speed in MHz - from datasheet */ | 100 | /* the min and max PCI bus speed in MHz - from datasheet */ |
104 | #define CY82C963_MIN_BUS_SPEED 25 | 101 | #define CY82C963_MIN_BUS_SPEED 25 |
105 | #define CY82C963_MAX_BUS_SPEED 33 | 102 | #define CY82C963_MAX_BUS_SPEED 33 |
@@ -148,9 +145,6 @@ static void compute_clocks (u8 pio, pio_clocks_t *p_pclk) | |||
148 | * so you can play with the idebus=xx parameter | 145 | * so you can play with the idebus=xx parameter |
149 | */ | 146 | */ |
150 | 147 | ||
151 | if (pio > CY82C693_MAX_PIO) | ||
152 | pio = CY82C693_MAX_PIO; | ||
153 | |||
154 | /* let's calc the address setup time clocks */ | 148 | /* let's calc the address setup time clocks */ |
155 | p_pclk->address_time = (u8)calc_clk(ide_pio_timings[pio].setup_time, bus_speed); | 149 | p_pclk->address_time = (u8)calc_clk(ide_pio_timings[pio].setup_time, bus_speed); |
156 | 150 | ||
@@ -269,10 +263,7 @@ static int cy82c693_ide_dma_on (ide_drive_t *drive) | |||
269 | return __ide_dma_on(drive); | 263 | return __ide_dma_on(drive); |
270 | } | 264 | } |
271 | 265 | ||
272 | /* | 266 | static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio) |
273 | * tune ide drive - set PIO mode | ||
274 | */ | ||
275 | static void cy82c693_tune_drive (ide_drive_t *drive, u8 pio) | ||
276 | { | 267 | { |
277 | ide_hwif_t *hwif = HWIF(drive); | 268 | ide_hwif_t *hwif = HWIF(drive); |
278 | struct pci_dev *dev = hwif->pci_dev; | 269 | struct pci_dev *dev = hwif->pci_dev; |
@@ -329,13 +320,6 @@ static void cy82c693_tune_drive (ide_drive_t *drive, u8 pio) | |||
329 | addrCtrl, pclk.time_16r, pclk.time_16w, pclk.time_8); | 320 | addrCtrl, pclk.time_16r, pclk.time_16w, pclk.time_8); |
330 | #endif /* CY82C693_DEBUG_LOGS */ | 321 | #endif /* CY82C693_DEBUG_LOGS */ |
331 | 322 | ||
332 | /* first let's calc the pio modes */ | ||
333 | pio = ide_get_best_pio_mode(drive, pio, CY82C693_MAX_PIO); | ||
334 | |||
335 | #if CY82C693_DEBUG_INFO | ||
336 | printk (KERN_INFO "%s: Selected PIO mode %d\n", drive->name, pio); | ||
337 | #endif /* CY82C693_DEBUG_INFO */ | ||
338 | |||
339 | /* let's calc the values for this PIO mode */ | 323 | /* let's calc the values for this PIO mode */ |
340 | compute_clocks(pio, &pclk); | 324 | compute_clocks(pio, &pclk); |
341 | 325 | ||
@@ -447,7 +431,7 @@ static void __devinit init_hwif_cy82c693(ide_hwif_t *hwif) | |||
447 | hwif->autodma = 0; | 431 | hwif->autodma = 0; |
448 | 432 | ||
449 | hwif->chipset = ide_cy82c693; | 433 | hwif->chipset = ide_cy82c693; |
450 | hwif->tuneproc = &cy82c693_tune_drive; | 434 | hwif->set_pio_mode = &cy82c693_set_pio_mode; |
451 | 435 | ||
452 | if (!hwif->dma_base) { | 436 | if (!hwif->dma_base) { |
453 | hwif->drives[0].autotune = 1; | 437 | hwif->drives[0].autotune = 1; |
diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c index ba982d66ff73..a1bb10188fe5 100644 --- a/drivers/ide/pci/hpt34x.c +++ b/drivers/ide/pci/hpt34x.c | |||
@@ -77,9 +77,8 @@ static int hpt34x_tune_chipset(ide_drive_t *drive, const u8 speed) | |||
77 | return(ide_config_drive_speed(drive, speed)); | 77 | return(ide_config_drive_speed(drive, speed)); |
78 | } | 78 | } |
79 | 79 | ||
80 | static void hpt34x_tune_drive (ide_drive_t *drive, u8 pio) | 80 | static void hpt34x_set_pio_mode(ide_drive_t *drive, const u8 pio) |
81 | { | 81 | { |
82 | pio = ide_get_best_pio_mode(drive, pio, 5); | ||
83 | (void) hpt34x_tune_chipset(drive, (XFER_PIO_0 + pio)); | 82 | (void) hpt34x_tune_chipset(drive, (XFER_PIO_0 + pio)); |
84 | } | 83 | } |
85 | 84 | ||
@@ -91,7 +90,7 @@ static int hpt34x_config_drive_xfer_rate (ide_drive_t *drive) | |||
91 | return -1; | 90 | return -1; |
92 | 91 | ||
93 | if (ide_use_fast_pio(drive)) | 92 | if (ide_use_fast_pio(drive)) |
94 | hpt34x_tune_drive(drive, 255); | 93 | ide_set_max_pio(drive); |
95 | 94 | ||
96 | return -1; | 95 | return -1; |
97 | } | 96 | } |
@@ -145,7 +144,7 @@ static void __devinit init_hwif_hpt34x(ide_hwif_t *hwif) | |||
145 | 144 | ||
146 | hwif->autodma = 0; | 145 | hwif->autodma = 0; |
147 | 146 | ||
148 | hwif->tuneproc = &hpt34x_tune_drive; | 147 | hwif->set_pio_mode = &hpt34x_set_pio_mode; |
149 | hwif->speedproc = &hpt34x_tune_chipset; | 148 | hwif->speedproc = &hpt34x_tune_chipset; |
150 | hwif->drives[0].autotune = 1; | 149 | hwif->drives[0].autotune = 1; |
151 | hwif->drives[1].autotune = 1; | 150 | hwif->drives[1].autotune = 1; |
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index 67127ac3a14a..0e7d3b60d43c 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c | |||
@@ -662,9 +662,8 @@ static int hpt3xx_tune_chipset(ide_drive_t *drive, u8 speed) | |||
662 | return hpt36x_tune_chipset(drive, speed); | 662 | return hpt36x_tune_chipset(drive, speed); |
663 | } | 663 | } |
664 | 664 | ||
665 | static void hpt3xx_tune_drive(ide_drive_t *drive, u8 pio) | 665 | static void hpt3xx_set_pio_mode(ide_drive_t *drive, const u8 pio) |
666 | { | 666 | { |
667 | pio = ide_get_best_pio_mode(drive, pio, 4); | ||
668 | (void) hpt3xx_tune_chipset (drive, XFER_PIO_0 + pio); | 667 | (void) hpt3xx_tune_chipset (drive, XFER_PIO_0 + pio); |
669 | } | 668 | } |
670 | 669 | ||
@@ -726,7 +725,7 @@ static int hpt366_config_drive_xfer_rate(ide_drive_t *drive) | |||
726 | return 0; | 725 | return 0; |
727 | 726 | ||
728 | if (ide_use_fast_pio(drive)) | 727 | if (ide_use_fast_pio(drive)) |
729 | hpt3xx_tune_drive(drive, 255); | 728 | ide_set_max_pio(drive); |
730 | 729 | ||
731 | return -1; | 730 | return -1; |
732 | } | 731 | } |
@@ -1257,7 +1256,7 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) | |||
1257 | /* Cache the channel's MISC. control registers' offset */ | 1256 | /* Cache the channel's MISC. control registers' offset */ |
1258 | hwif->select_data = hwif->channel ? 0x54 : 0x50; | 1257 | hwif->select_data = hwif->channel ? 0x54 : 0x50; |
1259 | 1258 | ||
1260 | hwif->tuneproc = &hpt3xx_tune_drive; | 1259 | hwif->set_pio_mode = &hpt3xx_set_pio_mode; |
1261 | hwif->speedproc = &hpt3xx_tune_chipset; | 1260 | hwif->speedproc = &hpt3xx_tune_chipset; |
1262 | hwif->quirkproc = &hpt3xx_quirkproc; | 1261 | hwif->quirkproc = &hpt3xx_quirkproc; |
1263 | hwif->intrproc = &hpt3xx_intrproc; | 1262 | hwif->intrproc = &hpt3xx_intrproc; |
diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/pci/it8213.c index 6fa955749aec..d07771e06b2d 100644 --- a/drivers/ide/pci/it8213.c +++ b/drivers/ide/pci/it8213.c | |||
@@ -105,9 +105,8 @@ static void it8213_tune_pio(ide_drive_t *drive, const u8 pio) | |||
105 | spin_unlock_irqrestore(&tune_lock, flags); | 105 | spin_unlock_irqrestore(&tune_lock, flags); |
106 | } | 106 | } |
107 | 107 | ||
108 | static void it8213_tuneproc(ide_drive_t *drive, u8 pio) | 108 | static void it8213_set_pio_mode(ide_drive_t *drive, const u8 pio) |
109 | { | 109 | { |
110 | pio = ide_get_best_pio_mode(drive, pio, 4); | ||
111 | it8213_tune_pio(drive, pio); | 110 | it8213_tune_pio(drive, pio); |
112 | ide_config_drive_speed(drive, XFER_PIO_0 + pio); | 111 | ide_config_drive_speed(drive, XFER_PIO_0 + pio); |
113 | } | 112 | } |
@@ -212,7 +211,7 @@ static int it8213_config_drive_for_dma (ide_drive_t *drive) | |||
212 | if (ide_tune_dma(drive)) | 211 | if (ide_tune_dma(drive)) |
213 | return 0; | 212 | return 0; |
214 | 213 | ||
215 | it8213_tuneproc(drive, 255); | 214 | ide_set_max_pio(drive); |
216 | 215 | ||
217 | return -1; | 216 | return -1; |
218 | } | 217 | } |
@@ -231,7 +230,7 @@ static void __devinit init_hwif_it8213(ide_hwif_t *hwif) | |||
231 | u8 reg42h = 0; | 230 | u8 reg42h = 0; |
232 | 231 | ||
233 | hwif->speedproc = &it8213_tune_chipset; | 232 | hwif->speedproc = &it8213_tune_chipset; |
234 | hwif->tuneproc = &it8213_tuneproc; | 233 | hwif->set_pio_mode = &it8213_set_pio_mode; |
235 | 234 | ||
236 | hwif->autodma = 0; | 235 | hwif->autodma = 0; |
237 | 236 | ||
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c index a756e61bcb32..0cce4a7f5e46 100644 --- a/drivers/ide/pci/it821x.c +++ b/drivers/ide/pci/it821x.c | |||
@@ -274,9 +274,8 @@ static int it821x_tunepio(ide_drive_t *drive, u8 set_pio) | |||
274 | return ide_config_drive_speed(drive, XFER_PIO_0 + set_pio); | 274 | return ide_config_drive_speed(drive, XFER_PIO_0 + set_pio); |
275 | } | 275 | } |
276 | 276 | ||
277 | static void it821x_tuneproc(ide_drive_t *drive, u8 pio) | 277 | static void it821x_set_pio_mode(ide_drive_t *drive, const u8 pio) |
278 | { | 278 | { |
279 | pio = ide_get_best_pio_mode(drive, pio, 4); | ||
280 | (void)it821x_tunepio(drive, pio); | 279 | (void)it821x_tunepio(drive, pio); |
281 | } | 280 | } |
282 | 281 | ||
@@ -473,7 +472,7 @@ static int it821x_config_drive_for_dma (ide_drive_t *drive) | |||
473 | if (ide_tune_dma(drive)) | 472 | if (ide_tune_dma(drive)) |
474 | return 0; | 473 | return 0; |
475 | 474 | ||
476 | it821x_tuneproc(drive, 255); | 475 | ide_set_max_pio(drive); |
477 | 476 | ||
478 | return -1; | 477 | return -1; |
479 | } | 478 | } |
@@ -640,7 +639,7 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif) | |||
640 | } | 639 | } |
641 | 640 | ||
642 | hwif->speedproc = &it821x_tune_chipset; | 641 | hwif->speedproc = &it821x_tune_chipset; |
643 | hwif->tuneproc = &it821x_tuneproc; | 642 | hwif->set_pio_mode = &it821x_set_pio_mode; |
644 | 643 | ||
645 | /* MWDMA/PIO clock switching for pass through mode */ | 644 | /* MWDMA/PIO clock switching for pass through mode */ |
646 | if(!idev->smart) { | 645 | if(!idev->smart) { |
diff --git a/drivers/ide/pci/jmicron.c b/drivers/ide/pci/jmicron.c index 7bac87fb481a..d379fbaf6743 100644 --- a/drivers/ide/pci/jmicron.c +++ b/drivers/ide/pci/jmicron.c | |||
@@ -83,9 +83,8 @@ static u8 __devinit ata66_jmicron(ide_hwif_t *hwif) | |||
83 | return ATA_CBL_PATA80; | 83 | return ATA_CBL_PATA80; |
84 | } | 84 | } |
85 | 85 | ||
86 | static void jmicron_tuneproc(ide_drive_t *drive, u8 pio) | 86 | static void jmicron_set_pio_mode(ide_drive_t *drive, const u8 pio) |
87 | { | 87 | { |
88 | pio = ide_get_best_pio_mode(drive, pio, 5); | ||
89 | ide_config_drive_speed(drive, XFER_PIO_0 + pio); | 88 | ide_config_drive_speed(drive, XFER_PIO_0 + pio); |
90 | } | 89 | } |
91 | 90 | ||
@@ -116,7 +115,7 @@ static int jmicron_config_drive_for_dma (ide_drive_t *drive) | |||
116 | if (ide_tune_dma(drive)) | 115 | if (ide_tune_dma(drive)) |
117 | return 0; | 116 | return 0; |
118 | 117 | ||
119 | jmicron_tuneproc(drive, 255); | 118 | ide_set_max_pio(drive); |
120 | 119 | ||
121 | return -1; | 120 | return -1; |
122 | } | 121 | } |
@@ -131,7 +130,7 @@ static int jmicron_config_drive_for_dma (ide_drive_t *drive) | |||
131 | static void __devinit init_hwif_jmicron(ide_hwif_t *hwif) | 130 | static void __devinit init_hwif_jmicron(ide_hwif_t *hwif) |
132 | { | 131 | { |
133 | hwif->speedproc = &jmicron_tune_chipset; | 132 | hwif->speedproc = &jmicron_tune_chipset; |
134 | hwif->tuneproc = &jmicron_tuneproc; | 133 | hwif->set_pio_mode = &jmicron_set_pio_mode; |
135 | 134 | ||
136 | hwif->drives[0].autotune = 1; | 135 | hwif->drives[0].autotune = 1; |
137 | hwif->drives[1].autotune = 1; | 136 | hwif->drives[1].autotune = 1; |
diff --git a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c index 3a2bb2723515..9fa06393469a 100644 --- a/drivers/ide/pci/opti621.c +++ b/drivers/ide/pci/opti621.c | |||
@@ -47,7 +47,7 @@ | |||
47 | * The main problem with OPTi is that some timings for master | 47 | * The main problem with OPTi is that some timings for master |
48 | * and slave must be the same. For example, if you have master | 48 | * and slave must be the same. For example, if you have master |
49 | * PIO 3 and slave PIO 0, driver have to set some timings of | 49 | * PIO 3 and slave PIO 0, driver have to set some timings of |
50 | * master for PIO 0. Second problem is that opti621_tune_drive | 50 | * master for PIO 0. Second problem is that opti621_set_pio_mode |
51 | * got only one drive to set, but have to set both drives. | 51 | * got only one drive to set, but have to set both drives. |
52 | * This is solved in compute_pios. If you don't set | 52 | * This is solved in compute_pios. If you don't set |
53 | * the second drive, compute_pios use ide_get_best_pio_mode | 53 | * the second drive, compute_pios use ide_get_best_pio_mode |
@@ -103,7 +103,7 @@ | |||
103 | 103 | ||
104 | #include <asm/io.h> | 104 | #include <asm/io.h> |
105 | 105 | ||
106 | #define OPTI621_MAX_PIO 3 | 106 | //#define OPTI621_MAX_PIO 3 |
107 | /* In fact, I do not have any PIO 4 drive | 107 | /* In fact, I do not have any PIO 4 drive |
108 | * (address: 25 ns, data: 70 ns, recovery: 35 ns), | 108 | * (address: 25 ns, data: 70 ns, recovery: 35 ns), |
109 | * but OPTi 82C621 is programmable and it can do (minimal values): | 109 | * but OPTi 82C621 is programmable and it can do (minimal values): |
@@ -136,8 +136,8 @@ static int reg_base; | |||
136 | #define PIO_NOT_EXIST 254 | 136 | #define PIO_NOT_EXIST 254 |
137 | #define PIO_DONT_KNOW 255 | 137 | #define PIO_DONT_KNOW 255 |
138 | 138 | ||
139 | /* there are stored pio numbers from other calls of opti621_tune_drive */ | 139 | /* there are stored pio numbers from other calls of opti621_set_pio_mode */ |
140 | static void compute_pios(ide_drive_t *drive, u8 pio) | 140 | static void compute_pios(ide_drive_t *drive, const u8 pio) |
141 | /* Store values into drive->drive_data | 141 | /* Store values into drive->drive_data |
142 | * second_contr - 0 for primary controller, 1 for secondary | 142 | * second_contr - 0 for primary controller, 1 for secondary |
143 | * slave_drive - 0 -> pio is for master, 1 -> pio is for slave | 143 | * slave_drive - 0 -> pio is for master, 1 -> pio is for slave |
@@ -147,12 +147,13 @@ static void compute_pios(ide_drive_t *drive, u8 pio) | |||
147 | int d; | 147 | int d; |
148 | ide_hwif_t *hwif = HWIF(drive); | 148 | ide_hwif_t *hwif = HWIF(drive); |
149 | 149 | ||
150 | drive->drive_data = ide_get_best_pio_mode(drive, pio, OPTI621_MAX_PIO); | 150 | drive->drive_data = pio; |
151 | |||
151 | for (d = 0; d < 2; ++d) { | 152 | for (d = 0; d < 2; ++d) { |
152 | drive = &hwif->drives[d]; | 153 | drive = &hwif->drives[d]; |
153 | if (drive->present) { | 154 | if (drive->present) { |
154 | if (drive->drive_data == PIO_DONT_KNOW) | 155 | if (drive->drive_data == PIO_DONT_KNOW) |
155 | drive->drive_data = ide_get_best_pio_mode(drive, 255, OPTI621_MAX_PIO); | 156 | drive->drive_data = ide_get_best_pio_mode(drive, 255, 3); |
156 | #ifdef OPTI621_DEBUG | 157 | #ifdef OPTI621_DEBUG |
157 | printk("%s: Selected PIO mode %d\n", | 158 | printk("%s: Selected PIO mode %d\n", |
158 | drive->name, drive->drive_data); | 159 | drive->name, drive->drive_data); |
@@ -240,8 +241,7 @@ static void compute_clocks(int pio, pio_clocks_t *clks) | |||
240 | 241 | ||
241 | } | 242 | } |
242 | 243 | ||
243 | /* Main tune procedure, called from tuneproc. */ | 244 | static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio) |
244 | static void opti621_tune_drive (ide_drive_t *drive, u8 pio) | ||
245 | { | 245 | { |
246 | /* primary and secondary drives share some registers, | 246 | /* primary and secondary drives share some registers, |
247 | * so we have to program both drives | 247 | * so we have to program both drives |
@@ -331,7 +331,8 @@ static void __devinit init_hwif_opti621 (ide_hwif_t *hwif) | |||
331 | hwif->autodma = 0; | 331 | hwif->autodma = 0; |
332 | hwif->drives[0].drive_data = PIO_DONT_KNOW; | 332 | hwif->drives[0].drive_data = PIO_DONT_KNOW; |
333 | hwif->drives[1].drive_data = PIO_DONT_KNOW; | 333 | hwif->drives[1].drive_data = PIO_DONT_KNOW; |
334 | hwif->tuneproc = &opti621_tune_drive; | 334 | |
335 | hwif->set_pio_mode = &opti621_set_pio_mode; | ||
335 | 336 | ||
336 | if (!(hwif->dma_base)) | 337 | if (!(hwif->dma_base)) |
337 | return; | 338 | return; |
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c index 3787194a2249..5fb1eedc8194 100644 --- a/drivers/ide/pci/pdc202xx_new.c +++ b/drivers/ide/pci/pdc202xx_new.c | |||
@@ -215,9 +215,8 @@ static int pdcnew_tune_chipset(ide_drive_t *drive, const u8 speed) | |||
215 | return err; | 215 | return err; |
216 | } | 216 | } |
217 | 217 | ||
218 | static void pdcnew_tune_drive(ide_drive_t *drive, u8 pio) | 218 | static void pdcnew_set_pio_mode(ide_drive_t *drive, const u8 pio) |
219 | { | 219 | { |
220 | pio = ide_get_best_pio_mode(drive, pio, 4); | ||
221 | (void)pdcnew_tune_chipset(drive, XFER_PIO_0 + pio); | 220 | (void)pdcnew_tune_chipset(drive, XFER_PIO_0 + pio); |
222 | } | 221 | } |
223 | 222 | ||
@@ -237,7 +236,7 @@ static int pdcnew_config_drive_xfer_rate(ide_drive_t *drive) | |||
237 | return 0; | 236 | return 0; |
238 | 237 | ||
239 | if (ide_use_fast_pio(drive)) | 238 | if (ide_use_fast_pio(drive)) |
240 | pdcnew_tune_drive(drive, 255); | 239 | ide_set_max_pio(drive); |
241 | 240 | ||
242 | return -1; | 241 | return -1; |
243 | } | 242 | } |
@@ -490,7 +489,8 @@ static void __devinit init_hwif_pdc202new(ide_hwif_t *hwif) | |||
490 | { | 489 | { |
491 | hwif->autodma = 0; | 490 | hwif->autodma = 0; |
492 | 491 | ||
493 | hwif->tuneproc = &pdcnew_tune_drive; | 492 | hwif->set_pio_mode = &pdcnew_set_pio_mode; |
493 | |||
494 | hwif->quirkproc = &pdcnew_quirkproc; | 494 | hwif->quirkproc = &pdcnew_quirkproc; |
495 | hwif->speedproc = &pdcnew_tune_chipset; | 495 | hwif->speedproc = &pdcnew_tune_chipset; |
496 | hwif->resetproc = &pdcnew_reset; | 496 | hwif->resetproc = &pdcnew_reset; |
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c index e7a5e3014c09..b578307fad51 100644 --- a/drivers/ide/pci/pdc202xx_old.c +++ b/drivers/ide/pci/pdc202xx_old.c | |||
@@ -142,9 +142,8 @@ static int pdc202xx_tune_chipset(ide_drive_t *drive, const u8 speed) | |||
142 | return ide_config_drive_speed(drive, speed); | 142 | return ide_config_drive_speed(drive, speed); |
143 | } | 143 | } |
144 | 144 | ||
145 | static void pdc202xx_tune_drive(ide_drive_t *drive, u8 pio) | 145 | static void pdc202xx_set_pio_mode(ide_drive_t *drive, const u8 pio) |
146 | { | 146 | { |
147 | pio = ide_get_best_pio_mode(drive, pio, 4); | ||
148 | pdc202xx_tune_chipset(drive, XFER_PIO_0 + pio); | 147 | pdc202xx_tune_chipset(drive, XFER_PIO_0 + pio); |
149 | } | 148 | } |
150 | 149 | ||
@@ -190,7 +189,7 @@ static int pdc202xx_config_drive_xfer_rate (ide_drive_t *drive) | |||
190 | return 0; | 189 | return 0; |
191 | 190 | ||
192 | if (ide_use_fast_pio(drive)) | 191 | if (ide_use_fast_pio(drive)) |
193 | pdc202xx_tune_drive(drive, 255); | 192 | ide_set_max_pio(drive); |
194 | 193 | ||
195 | return -1; | 194 | return -1; |
196 | } | 195 | } |
@@ -306,10 +305,11 @@ static void pdc202xx_reset (ide_drive_t *drive) | |||
306 | { | 305 | { |
307 | ide_hwif_t *hwif = HWIF(drive); | 306 | ide_hwif_t *hwif = HWIF(drive); |
308 | ide_hwif_t *mate = hwif->mate; | 307 | ide_hwif_t *mate = hwif->mate; |
309 | 308 | ||
310 | pdc202xx_reset_host(hwif); | 309 | pdc202xx_reset_host(hwif); |
311 | pdc202xx_reset_host(mate); | 310 | pdc202xx_reset_host(mate); |
312 | pdc202xx_tune_drive(drive, 255); | 311 | |
312 | ide_set_max_pio(drive); | ||
313 | } | 313 | } |
314 | 314 | ||
315 | static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev, | 315 | static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev, |
@@ -328,7 +328,9 @@ static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif) | |||
328 | hwif->rqsize = 256; | 328 | hwif->rqsize = 256; |
329 | 329 | ||
330 | hwif->autodma = 0; | 330 | hwif->autodma = 0; |
331 | hwif->tuneproc = &pdc202xx_tune_drive; | 331 | |
332 | hwif->set_pio_mode = &pdc202xx_set_pio_mode; | ||
333 | |||
332 | hwif->quirkproc = &pdc202xx_quirkproc; | 334 | hwif->quirkproc = &pdc202xx_quirkproc; |
333 | 335 | ||
334 | if (hwif->pci_dev->device != PCI_DEVICE_ID_PROMISE_20246) | 336 | if (hwif->pci_dev->device != PCI_DEVICE_ID_PROMISE_20246) |
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c index b66f9d1411b3..07492d71c602 100644 --- a/drivers/ide/pci/piix.c +++ b/drivers/ide/pci/piix.c | |||
@@ -17,11 +17,11 @@ | |||
17 | * 41 | 17 | * 41 |
18 | * 43 | 18 | * 43 |
19 | * | 19 | * |
20 | * | PIO 0 | c0 | 80 | 0 | piix_tune_drive(drive, 0); | 20 | * | PIO 0 | c0 | 80 | 0 | |
21 | * | PIO 2 | SW2 | d0 | 90 | 4 | piix_tune_drive(drive, 2); | 21 | * | PIO 2 | SW2 | d0 | 90 | 4 | |
22 | * | PIO 3 | MW1 | e1 | a1 | 9 | piix_tune_drive(drive, 3); | 22 | * | PIO 3 | MW1 | e1 | a1 | 9 | |
23 | * | PIO 4 | MW2 | e3 | a3 | b | piix_tune_drive(drive, 4); | 23 | * | PIO 4 | MW2 | e3 | a3 | b | |
24 | * | 24 | * |
25 | * sitre = word40 & 0x4000; primary | 25 | * sitre = word40 & 0x4000; primary |
26 | * sitre = word42 & 0x4000; secondary | 26 | * sitre = word42 & 0x4000; secondary |
27 | * | 27 | * |
@@ -204,16 +204,16 @@ static void piix_tune_pio (ide_drive_t *drive, u8 pio) | |||
204 | } | 204 | } |
205 | 205 | ||
206 | /** | 206 | /** |
207 | * piix_tune_drive - tune a drive attached to PIIX | 207 | * piix_set_pio_mode - set PIO mode |
208 | * @drive: drive to tune | 208 | * @drive: drive to tune |
209 | * @pio: desired PIO mode | 209 | * @pio: desired PIO mode |
210 | * | 210 | * |
211 | * Set the drive's PIO mode (might be useful if drive is not registered | 211 | * Set the drive's PIO mode (might be useful if drive is not registered |
212 | * in CMOS for any reason). | 212 | * in CMOS for any reason). |
213 | */ | 213 | */ |
214 | static void piix_tune_drive (ide_drive_t *drive, u8 pio) | 214 | |
215 | static void piix_set_pio_mode(ide_drive_t *drive, const u8 pio) | ||
215 | { | 216 | { |
216 | pio = ide_get_best_pio_mode(drive, pio, 4); | ||
217 | piix_tune_pio(drive, pio); | 217 | piix_tune_pio(drive, pio); |
218 | (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio); | 218 | (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio); |
219 | } | 219 | } |
@@ -317,7 +317,7 @@ static int piix_config_drive_xfer_rate (ide_drive_t *drive) | |||
317 | return 0; | 317 | return 0; |
318 | 318 | ||
319 | if (ide_use_fast_pio(drive)) | 319 | if (ide_use_fast_pio(drive)) |
320 | piix_tune_drive(drive, 255); | 320 | ide_set_max_pio(drive); |
321 | 321 | ||
322 | return -1; | 322 | return -1; |
323 | } | 323 | } |
@@ -454,7 +454,8 @@ static void __devinit init_hwif_piix(ide_hwif_t *hwif) | |||
454 | } | 454 | } |
455 | 455 | ||
456 | hwif->autodma = 0; | 456 | hwif->autodma = 0; |
457 | hwif->tuneproc = &piix_tune_drive; | 457 | |
458 | hwif->set_pio_mode = &piix_set_pio_mode; | ||
458 | hwif->speedproc = &piix_tune_chipset; | 459 | hwif->speedproc = &piix_tune_chipset; |
459 | hwif->drives[0].autotune = 1; | 460 | hwif->drives[0].autotune = 1; |
460 | hwif->drives[1].autotune = 1; | 461 | hwif->drives[1].autotune = 1; |
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c index 059071cd2d49..f9f5ed906577 100644 --- a/drivers/ide/pci/sc1200.c +++ b/drivers/ide/pci/sc1200.c | |||
@@ -272,19 +272,20 @@ static int sc1200_ide_dma_end (ide_drive_t *drive) | |||
272 | } | 272 | } |
273 | 273 | ||
274 | /* | 274 | /* |
275 | * sc1200_tuneproc() handles selection/setting of PIO modes | 275 | * sc1200_set_pio_mode() handles setting of PIO modes |
276 | * for both the chipset and drive. | 276 | * for both the chipset and drive. |
277 | * | 277 | * |
278 | * All existing BIOSs for this chipset guarantee that all drives | 278 | * All existing BIOSs for this chipset guarantee that all drives |
279 | * will have valid default PIO timings set up before we get here. | 279 | * will have valid default PIO timings set up before we get here. |
280 | */ | 280 | */ |
281 | static void sc1200_tuneproc (ide_drive_t *drive, byte pio) /* mode=255 means "autotune" */ | 281 | |
282 | static void sc1200_set_pio_mode(ide_drive_t *drive, const u8 pio) | ||
282 | { | 283 | { |
283 | ide_hwif_t *hwif = HWIF(drive); | 284 | ide_hwif_t *hwif = HWIF(drive); |
284 | int mode = -1; | 285 | int mode = -1; |
285 | 286 | ||
286 | /* | 287 | /* |
287 | * bad abuse of ->tuneproc interface | 288 | * bad abuse of ->set_pio_mode interface |
288 | */ | 289 | */ |
289 | switch (pio) { | 290 | switch (pio) { |
290 | case 200: mode = XFER_UDMA_0; break; | 291 | case 200: mode = XFER_UDMA_0; break; |
@@ -302,9 +303,6 @@ static void sc1200_tuneproc (ide_drive_t *drive, byte pio) /* mode=255 means "au | |||
302 | return; | 303 | return; |
303 | } | 304 | } |
304 | 305 | ||
305 | pio = ide_get_best_pio_mode(drive, pio, 4); | ||
306 | printk("SC1200: %s: setting PIO mode%d\n", drive->name, pio); | ||
307 | |||
308 | if (sc1200_set_xfer_mode(drive, XFER_PIO_0 + pio) == 0) | 306 | if (sc1200_set_xfer_mode(drive, XFER_PIO_0 + pio) == 0) |
309 | sc1200_tunepio(drive, pio); | 307 | sc1200_tunepio(drive, pio); |
310 | } | 308 | } |
@@ -420,7 +418,8 @@ static void __devinit init_hwif_sc1200 (ide_hwif_t *hwif) | |||
420 | hwif->ide_dma_end = &sc1200_ide_dma_end; | 418 | hwif->ide_dma_end = &sc1200_ide_dma_end; |
421 | if (!noautodma) | 419 | if (!noautodma) |
422 | hwif->autodma = 1; | 420 | hwif->autodma = 1; |
423 | hwif->tuneproc = &sc1200_tuneproc; | 421 | |
422 | hwif->set_pio_mode = &sc1200_set_pio_mode; | ||
424 | hwif->speedproc = &sc1200_tune_chipset; | 423 | hwif->speedproc = &sc1200_tune_chipset; |
425 | } | 424 | } |
426 | hwif->atapi_dma = 1; | 425 | hwif->atapi_dma = 1; |
@@ -436,6 +435,7 @@ static ide_pci_device_t sc1200_chipset __devinitdata = { | |||
436 | .init_hwif = init_hwif_sc1200, | 435 | .init_hwif = init_hwif_sc1200, |
437 | .autodma = AUTODMA, | 436 | .autodma = AUTODMA, |
438 | .bootable = ON_BOARD, | 437 | .bootable = ON_BOARD, |
438 | .host_flags = IDE_HFLAG_ABUSE_DMA_MODES, | ||
439 | .pio_mask = ATA_PIO4, | 439 | .pio_mask = ATA_PIO4, |
440 | }; | 440 | }; |
441 | 441 | ||
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c index a19687caf65a..3505d57eda18 100644 --- a/drivers/ide/pci/scc_pata.c +++ b/drivers/ide/pci/scc_pata.c | |||
@@ -221,9 +221,8 @@ static void scc_tune_pio(ide_drive_t *drive, const u8 pio) | |||
221 | out_be32((void __iomem *)pioct_port, reg); | 221 | out_be32((void __iomem *)pioct_port, reg); |
222 | } | 222 | } |
223 | 223 | ||
224 | static void scc_tuneproc(ide_drive_t *drive, u8 pio) | 224 | static void scc_set_pio_mode(ide_drive_t *drive, const u8 pio) |
225 | { | 225 | { |
226 | pio = ide_get_best_pio_mode(drive, pio, 4); | ||
227 | scc_tune_pio(drive, pio); | 226 | scc_tune_pio(drive, pio); |
228 | ide_config_drive_speed(drive, XFER_PIO_0 + pio); | 227 | ide_config_drive_speed(drive, XFER_PIO_0 + pio); |
229 | } | 228 | } |
@@ -316,7 +315,7 @@ static int scc_config_drive_for_dma(ide_drive_t *drive) | |||
316 | return 0; | 315 | return 0; |
317 | 316 | ||
318 | if (ide_use_fast_pio(drive)) | 317 | if (ide_use_fast_pio(drive)) |
319 | scc_tuneproc(drive, 255); | 318 | ide_set_max_pio(drive); |
320 | 319 | ||
321 | return -1; | 320 | return -1; |
322 | } | 321 | } |
@@ -717,7 +716,7 @@ static void __devinit init_hwif_scc(ide_hwif_t *hwif) | |||
717 | hwif->dma_setup = scc_dma_setup; | 716 | hwif->dma_setup = scc_dma_setup; |
718 | hwif->ide_dma_end = scc_ide_dma_end; | 717 | hwif->ide_dma_end = scc_ide_dma_end; |
719 | hwif->speedproc = scc_tune_chipset; | 718 | hwif->speedproc = scc_tune_chipset; |
720 | hwif->tuneproc = scc_tuneproc; | 719 | hwif->set_pio_mode = scc_set_pio_mode; |
721 | hwif->ide_dma_check = scc_config_drive_for_dma; | 720 | hwif->ide_dma_check = scc_config_drive_for_dma; |
722 | hwif->ide_dma_test_irq = scc_dma_test_irq; | 721 | hwif->ide_dma_test_irq = scc_dma_test_irq; |
723 | hwif->udma_filter = scc_udma_filter; | 722 | hwif->udma_filter = scc_udma_filter; |
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c index b51133bb58af..f4e08abf0fee 100644 --- a/drivers/ide/pci/serverworks.c +++ b/drivers/ide/pci/serverworks.c | |||
@@ -202,9 +202,8 @@ static int svwks_tune_chipset(ide_drive_t *drive, const u8 speed) | |||
202 | return (ide_config_drive_speed(drive, speed)); | 202 | return (ide_config_drive_speed(drive, speed)); |
203 | } | 203 | } |
204 | 204 | ||
205 | static void svwks_tune_drive (ide_drive_t *drive, u8 pio) | 205 | static void svwks_set_pio_mode(ide_drive_t *drive, const u8 pio) |
206 | { | 206 | { |
207 | pio = ide_get_best_pio_mode(drive, pio, 4); | ||
208 | svwks_tune_pio(drive, pio); | 207 | svwks_tune_pio(drive, pio); |
209 | (void)ide_config_drive_speed(drive, XFER_PIO_0 + pio); | 208 | (void)ide_config_drive_speed(drive, XFER_PIO_0 + pio); |
210 | } | 209 | } |
@@ -217,7 +216,7 @@ static int svwks_config_drive_xfer_rate (ide_drive_t *drive) | |||
217 | return 0; | 216 | return 0; |
218 | 217 | ||
219 | if (ide_use_fast_pio(drive)) | 218 | if (ide_use_fast_pio(drive)) |
220 | svwks_tune_drive(drive, 255); | 219 | ide_set_max_pio(drive); |
221 | 220 | ||
222 | return -1; | 221 | return -1; |
223 | } | 222 | } |
@@ -389,7 +388,7 @@ static void __devinit init_hwif_svwks (ide_hwif_t *hwif) | |||
389 | if (!hwif->irq) | 388 | if (!hwif->irq) |
390 | hwif->irq = hwif->channel ? 15 : 14; | 389 | hwif->irq = hwif->channel ? 15 : 14; |
391 | 390 | ||
392 | hwif->tuneproc = &svwks_tune_drive; | 391 | hwif->set_pio_mode = &svwks_set_pio_mode; |
393 | hwif->speedproc = &svwks_tune_chipset; | 392 | hwif->speedproc = &svwks_tune_chipset; |
394 | hwif->udma_filter = &svwks_udma_filter; | 393 | hwif->udma_filter = &svwks_udma_filter; |
395 | 394 | ||
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c index 57145767c3df..38f63d19c3b9 100644 --- a/drivers/ide/pci/sgiioc4.c +++ b/drivers/ide/pci/sgiioc4.c | |||
@@ -587,7 +587,7 @@ ide_init_sgiioc4(ide_hwif_t * hwif) | |||
587 | hwif->mwdma_mask = 0x2; /* Multimode-2 DMA */ | 587 | hwif->mwdma_mask = 0x2; /* Multimode-2 DMA */ |
588 | hwif->swdma_mask = 0x2; | 588 | hwif->swdma_mask = 0x2; |
589 | hwif->pio_mask = 0x00; | 589 | hwif->pio_mask = 0x00; |
590 | hwif->tuneproc = NULL; /* Sets timing for PIO mode */ | 590 | hwif->set_pio_mode = NULL; /* Sets timing for PIO mode */ |
591 | hwif->speedproc = NULL; /* Sets timing for DMA &/or PIO modes */ | 591 | hwif->speedproc = NULL; /* Sets timing for DMA &/or PIO modes */ |
592 | hwif->selectproc = NULL;/* Use the default routine to select drive */ | 592 | hwif->selectproc = NULL;/* Use the default routine to select drive */ |
593 | hwif->reset_poll = NULL;/* No HBA specific reset_poll needed */ | 593 | hwif->reset_poll = NULL;/* No HBA specific reset_poll needed */ |
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c index 4c1f3bc7e179..e07c991d91b9 100644 --- a/drivers/ide/pci/siimage.c +++ b/drivers/ide/pci/siimage.c | |||
@@ -219,9 +219,8 @@ static void sil_tune_pio(ide_drive_t *drive, u8 pio) | |||
219 | } | 219 | } |
220 | } | 220 | } |
221 | 221 | ||
222 | static void sil_tuneproc(ide_drive_t *drive, u8 pio) | 222 | static void sil_set_pio_mode(ide_drive_t *drive, const u8 pio) |
223 | { | 223 | { |
224 | pio = ide_get_best_pio_mode(drive, pio, 4); | ||
225 | sil_tune_pio(drive, pio); | 224 | sil_tune_pio(drive, pio); |
226 | (void)ide_config_drive_speed(drive, XFER_PIO_0 + pio); | 225 | (void)ide_config_drive_speed(drive, XFER_PIO_0 + pio); |
227 | } | 226 | } |
@@ -328,7 +327,7 @@ static int siimage_config_drive_for_dma (ide_drive_t *drive) | |||
328 | return 0; | 327 | return 0; |
329 | 328 | ||
330 | if (ide_use_fast_pio(drive)) | 329 | if (ide_use_fast_pio(drive)) |
331 | sil_tuneproc(drive, 255); | 330 | ide_set_max_pio(drive); |
332 | 331 | ||
333 | return -1; | 332 | return -1; |
334 | } | 333 | } |
@@ -899,7 +898,7 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif) | |||
899 | 898 | ||
900 | hwif->resetproc = &siimage_reset; | 899 | hwif->resetproc = &siimage_reset; |
901 | hwif->speedproc = &siimage_tune_chipset; | 900 | hwif->speedproc = &siimage_tune_chipset; |
902 | hwif->tuneproc = &sil_tuneproc; | 901 | hwif->set_pio_mode = &sil_set_pio_mode; |
903 | hwif->reset_poll = &siimage_reset_poll; | 902 | hwif->reset_poll = &siimage_reset_poll; |
904 | hwif->pre_reset = &siimage_pre_reset; | 903 | hwif->pre_reset = &siimage_pre_reset; |
905 | hwif->udma_filter = &sil_udma_filter; | 904 | hwif->udma_filter = &sil_udma_filter; |
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c index fed582b4b32f..7455bf357ed9 100644 --- a/drivers/ide/pci/sis5513.c +++ b/drivers/ide/pci/sis5513.c | |||
@@ -519,14 +519,13 @@ static void config_art_rwp_pio (ide_drive_t *drive, u8 pio) | |||
519 | } | 519 | } |
520 | } | 520 | } |
521 | 521 | ||
522 | static int sis5513_tune_drive(ide_drive_t *drive, u8 pio) | 522 | static int sis5513_tune_drive(ide_drive_t *drive, const u8 pio) |
523 | { | 523 | { |
524 | pio = ide_get_best_pio_mode(drive, pio, 4); | ||
525 | config_art_rwp_pio(drive, pio); | 524 | config_art_rwp_pio(drive, pio); |
526 | return ide_config_drive_speed(drive, XFER_PIO_0 + pio); | 525 | return ide_config_drive_speed(drive, XFER_PIO_0 + pio); |
527 | } | 526 | } |
528 | 527 | ||
529 | static void sis5513_tuneproc(ide_drive_t *drive, u8 pio) | 528 | static void sis_set_pio_mode(ide_drive_t *drive, const u8 pio) |
530 | { | 529 | { |
531 | (void)sis5513_tune_drive(drive, pio); | 530 | (void)sis5513_tune_drive(drive, pio); |
532 | } | 531 | } |
@@ -621,7 +620,7 @@ static int sis5513_config_xfer_rate(ide_drive_t *drive) | |||
621 | /* | 620 | /* |
622 | * TODO: always set PIO mode and remove this | 621 | * TODO: always set PIO mode and remove this |
623 | */ | 622 | */ |
624 | sis5513_tuneproc(drive, 255); | 623 | ide_set_max_pio(drive); |
625 | 624 | ||
626 | drive->init_speed = 0; | 625 | drive->init_speed = 0; |
627 | 626 | ||
@@ -629,7 +628,7 @@ static int sis5513_config_xfer_rate(ide_drive_t *drive) | |||
629 | return 0; | 628 | return 0; |
630 | 629 | ||
631 | if (ide_use_fast_pio(drive)) | 630 | if (ide_use_fast_pio(drive)) |
632 | sis5513_tuneproc(drive, 255); | 631 | ide_set_max_pio(drive); |
633 | 632 | ||
634 | return -1; | 633 | return -1; |
635 | } | 634 | } |
@@ -852,7 +851,7 @@ static void __devinit init_hwif_sis5513 (ide_hwif_t *hwif) | |||
852 | if (!hwif->irq) | 851 | if (!hwif->irq) |
853 | hwif->irq = hwif->channel ? 15 : 14; | 852 | hwif->irq = hwif->channel ? 15 : 14; |
854 | 853 | ||
855 | hwif->tuneproc = &sis5513_tuneproc; | 854 | hwif->set_pio_mode = &sis_set_pio_mode; |
856 | hwif->speedproc = &sis5513_tune_chipset; | 855 | hwif->speedproc = &sis5513_tune_chipset; |
857 | 856 | ||
858 | if (chipset_family >= ATA_133) | 857 | if (chipset_family >= ATA_133) |
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c index 9f425b0b5721..131e91ca1d82 100644 --- a/drivers/ide/pci/sl82c105.c +++ b/drivers/ide/pci/sl82c105.c | |||
@@ -75,16 +75,12 @@ static unsigned int get_pio_timings(ide_drive_t *drive, u8 pio) | |||
75 | /* | 75 | /* |
76 | * Configure the chipset for PIO mode. | 76 | * Configure the chipset for PIO mode. |
77 | */ | 77 | */ |
78 | static u8 sl82c105_tune_pio(ide_drive_t *drive, u8 pio) | 78 | static void sl82c105_tune_pio(ide_drive_t *drive, const u8 pio) |
79 | { | 79 | { |
80 | struct pci_dev *dev = HWIF(drive)->pci_dev; | 80 | struct pci_dev *dev = HWIF(drive)->pci_dev; |
81 | int reg = 0x44 + drive->dn * 4; | 81 | int reg = 0x44 + drive->dn * 4; |
82 | u16 drv_ctrl; | 82 | u16 drv_ctrl; |
83 | 83 | ||
84 | DBG(("sl82c105_tune_pio(drive:%s, pio:%u)\n", drive->name, pio)); | ||
85 | |||
86 | pio = ide_get_best_pio_mode(drive, pio, 5); | ||
87 | |||
88 | drv_ctrl = get_pio_timings(drive, pio); | 84 | drv_ctrl = get_pio_timings(drive, pio); |
89 | 85 | ||
90 | /* | 86 | /* |
@@ -106,8 +102,6 @@ static u8 sl82c105_tune_pio(ide_drive_t *drive, u8 pio) | |||
106 | printk(KERN_DEBUG "%s: selected %s (%dns) (%04X)\n", drive->name, | 102 | printk(KERN_DEBUG "%s: selected %s (%dns) (%04X)\n", drive->name, |
107 | ide_xfer_verbose(pio + XFER_PIO_0), | 103 | ide_xfer_verbose(pio + XFER_PIO_0), |
108 | ide_pio_cycle_time(drive, pio), drv_ctrl); | 104 | ide_pio_cycle_time(drive, pio), drv_ctrl); |
109 | |||
110 | return pio; | ||
111 | } | 105 | } |
112 | 106 | ||
113 | /* | 107 | /* |
@@ -151,7 +145,7 @@ static int sl82c105_tune_chipset(ide_drive_t *drive, const u8 speed) | |||
151 | case XFER_PIO_2: | 145 | case XFER_PIO_2: |
152 | case XFER_PIO_1: | 146 | case XFER_PIO_1: |
153 | case XFER_PIO_0: | 147 | case XFER_PIO_0: |
154 | (void) sl82c105_tune_pio(drive, speed - XFER_PIO_0); | 148 | sl82c105_tune_pio(drive, speed - XFER_PIO_0); |
155 | break; | 149 | break; |
156 | default: | 150 | default: |
157 | return -1; | 151 | return -1; |
@@ -325,11 +319,10 @@ static void sl82c105_resetproc(ide_drive_t *drive) | |||
325 | * We only deal with PIO mode here - DMA mode 'using_dma' is not | 319 | * We only deal with PIO mode here - DMA mode 'using_dma' is not |
326 | * initialised at the point that this function is called. | 320 | * initialised at the point that this function is called. |
327 | */ | 321 | */ |
328 | static void sl82c105_tune_drive(ide_drive_t *drive, u8 pio) | 322 | static void sl82c105_set_pio_mode(ide_drive_t *drive, const u8 pio) |
329 | { | 323 | { |
330 | DBG(("sl82c105_tune_drive(drive:%s, pio:%u)\n", drive->name, pio)); | 324 | sl82c105_tune_pio(drive, pio); |
331 | 325 | ||
332 | pio = sl82c105_tune_pio(drive, pio); | ||
333 | (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio); | 326 | (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio); |
334 | } | 327 | } |
335 | 328 | ||
@@ -397,7 +390,7 @@ static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif) | |||
397 | 390 | ||
398 | DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index)); | 391 | DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index)); |
399 | 392 | ||
400 | hwif->tuneproc = &sl82c105_tune_drive; | 393 | hwif->set_pio_mode = &sl82c105_set_pio_mode; |
401 | hwif->speedproc = &sl82c105_tune_chipset; | 394 | hwif->speedproc = &sl82c105_tune_chipset; |
402 | hwif->selectproc = &sl82c105_selectproc; | 395 | hwif->selectproc = &sl82c105_selectproc; |
403 | hwif->resetproc = &sl82c105_resetproc; | 396 | hwif->resetproc = &sl82c105_resetproc; |
diff --git a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c index cc9353565070..214d396fc31f 100644 --- a/drivers/ide/pci/slc90e66.c +++ b/drivers/ide/pci/slc90e66.c | |||
@@ -95,9 +95,8 @@ static void slc90e66_tune_pio (ide_drive_t *drive, u8 pio) | |||
95 | spin_unlock_irqrestore(&ide_lock, flags); | 95 | spin_unlock_irqrestore(&ide_lock, flags); |
96 | } | 96 | } |
97 | 97 | ||
98 | static void slc90e66_tune_drive (ide_drive_t *drive, u8 pio) | 98 | static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) |
99 | { | 99 | { |
100 | pio = ide_get_best_pio_mode(drive, pio, 4); | ||
101 | slc90e66_tune_pio(drive, pio); | 100 | slc90e66_tune_pio(drive, pio); |
102 | (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio); | 101 | (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio); |
103 | } | 102 | } |
@@ -166,7 +165,7 @@ static int slc90e66_config_drive_xfer_rate (ide_drive_t *drive) | |||
166 | return 0; | 165 | return 0; |
167 | 166 | ||
168 | if (ide_use_fast_pio(drive)) | 167 | if (ide_use_fast_pio(drive)) |
169 | slc90e66_tune_drive(drive, 255); | 168 | ide_set_max_pio(drive); |
170 | 169 | ||
171 | return -1; | 170 | return -1; |
172 | } | 171 | } |
@@ -182,7 +181,7 @@ static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif) | |||
182 | hwif->irq = hwif->channel ? 15 : 14; | 181 | hwif->irq = hwif->channel ? 15 : 14; |
183 | 182 | ||
184 | hwif->speedproc = &slc90e66_tune_chipset; | 183 | hwif->speedproc = &slc90e66_tune_chipset; |
185 | hwif->tuneproc = &slc90e66_tune_drive; | 184 | hwif->set_pio_mode = &slc90e66_set_pio_mode; |
186 | 185 | ||
187 | pci_read_config_byte(hwif->pci_dev, 0x47, ®47); | 186 | pci_read_config_byte(hwif->pci_dev, 0x47, ®47); |
188 | 187 | ||
diff --git a/drivers/ide/pci/tc86c001.c b/drivers/ide/pci/tc86c001.c index e5425772622f..e23b9cfb6eb4 100644 --- a/drivers/ide/pci/tc86c001.c +++ b/drivers/ide/pci/tc86c001.c | |||
@@ -43,9 +43,8 @@ static int tc86c001_tune_chipset(ide_drive_t *drive, const u8 speed) | |||
43 | return ide_config_drive_speed(drive, speed); | 43 | return ide_config_drive_speed(drive, speed); |
44 | } | 44 | } |
45 | 45 | ||
46 | static void tc86c001_tune_drive(ide_drive_t *drive, u8 pio) | 46 | static void tc86c001_set_pio_mode(ide_drive_t *drive, const u8 pio) |
47 | { | 47 | { |
48 | pio = ide_get_best_pio_mode(drive, pio, 4); | ||
49 | (void) tc86c001_tune_chipset(drive, XFER_PIO_0 + pio); | 48 | (void) tc86c001_tune_chipset(drive, XFER_PIO_0 + pio); |
50 | } | 49 | } |
51 | 50 | ||
@@ -171,7 +170,7 @@ static int tc86c001_config_drive_xfer_rate(ide_drive_t *drive) | |||
171 | return 0; | 170 | return 0; |
172 | 171 | ||
173 | if (ide_use_fast_pio(drive)) | 172 | if (ide_use_fast_pio(drive)) |
174 | tc86c001_tune_drive(drive, 255); | 173 | ide_set_max_pio(drive); |
175 | 174 | ||
176 | return -1; | 175 | return -1; |
177 | } | 176 | } |
@@ -193,7 +192,7 @@ static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif) | |||
193 | /* Store the system control register base for convenience... */ | 192 | /* Store the system control register base for convenience... */ |
194 | hwif->config_data = sc_base; | 193 | hwif->config_data = sc_base; |
195 | 194 | ||
196 | hwif->tuneproc = &tc86c001_tune_drive; | 195 | hwif->set_pio_mode = &tc86c001_set_pio_mode; |
197 | hwif->speedproc = &tc86c001_tune_chipset; | 196 | hwif->speedproc = &tc86c001_tune_chipset; |
198 | hwif->busproc = &tc86c001_busproc; | 197 | hwif->busproc = &tc86c001_busproc; |
199 | 198 | ||
diff --git a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c index 47cf89be4dfc..c3ff066eea5a 100644 --- a/drivers/ide/pci/triflex.c +++ b/drivers/ide/pci/triflex.c | |||
@@ -93,10 +93,9 @@ static int triflex_tune_chipset(ide_drive_t *drive, const u8 speed) | |||
93 | return (ide_config_drive_speed(drive, speed)); | 93 | return (ide_config_drive_speed(drive, speed)); |
94 | } | 94 | } |
95 | 95 | ||
96 | static void triflex_tune_drive(ide_drive_t *drive, u8 pio) | 96 | static void triflex_set_pio_mode(ide_drive_t *drive, const u8 pio) |
97 | { | 97 | { |
98 | int use_pio = ide_get_best_pio_mode(drive, pio, 4); | 98 | (void)triflex_tune_chipset(drive, XFER_PIO_0 + pio); |
99 | (void) triflex_tune_chipset(drive, (XFER_PIO_0 + use_pio)); | ||
100 | } | 99 | } |
101 | 100 | ||
102 | static int triflex_config_drive_xfer_rate(ide_drive_t *drive) | 101 | static int triflex_config_drive_xfer_rate(ide_drive_t *drive) |
@@ -104,14 +103,14 @@ static int triflex_config_drive_xfer_rate(ide_drive_t *drive) | |||
104 | if (ide_tune_dma(drive)) | 103 | if (ide_tune_dma(drive)) |
105 | return 0; | 104 | return 0; |
106 | 105 | ||
107 | triflex_tune_drive(drive, 255); | 106 | ide_set_max_pio(drive); |
108 | 107 | ||
109 | return -1; | 108 | return -1; |
110 | } | 109 | } |
111 | 110 | ||
112 | static void __devinit init_hwif_triflex(ide_hwif_t *hwif) | 111 | static void __devinit init_hwif_triflex(ide_hwif_t *hwif) |
113 | { | 112 | { |
114 | hwif->tuneproc = &triflex_tune_drive; | 113 | hwif->set_pio_mode = &triflex_set_pio_mode; |
115 | hwif->speedproc = &triflex_tune_chipset; | 114 | hwif->speedproc = &triflex_tune_chipset; |
116 | 115 | ||
117 | if (hwif->dma_base == 0) | 116 | if (hwif->dma_base == 0) |
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c index e3bf90736332..2fc4f8835f19 100644 --- a/drivers/ide/pci/via82cxxx.c +++ b/drivers/ide/pci/via82cxxx.c | |||
@@ -195,19 +195,16 @@ static int via_set_drive(ide_drive_t *drive, const u8 speed) | |||
195 | } | 195 | } |
196 | 196 | ||
197 | /** | 197 | /** |
198 | * via82cxxx_tune_drive - PIO setup | 198 | * via_set_pio_mode - PIO setup |
199 | * @drive: drive to set up | 199 | * @drive: drive |
200 | * @pio: mode to use (255 for 'best possible') | 200 | * @pio: PIO mode number |
201 | * | 201 | * |
202 | * A callback from the upper layers for PIO-only tuning. | 202 | * A callback from the upper layers for PIO-only tuning. |
203 | */ | 203 | */ |
204 | 204 | ||
205 | static void via82cxxx_tune_drive(ide_drive_t *drive, u8 pio) | 205 | static void via_set_pio_mode(ide_drive_t *drive, const u8 pio) |
206 | { | 206 | { |
207 | if (pio == 255) | 207 | via_set_drive(drive, XFER_PIO_0 + pio); |
208 | pio = ide_get_best_pio_mode(drive, 255, 5); | ||
209 | |||
210 | via_set_drive(drive, XFER_PIO_0 + min_t(u8, pio, 5)); | ||
211 | } | 208 | } |
212 | 209 | ||
213 | /** | 210 | /** |
@@ -223,7 +220,7 @@ static int via82cxxx_ide_dma_check (ide_drive_t *drive) | |||
223 | u8 speed = ide_max_dma_mode(drive); | 220 | u8 speed = ide_max_dma_mode(drive); |
224 | 221 | ||
225 | if (speed == 0) { | 222 | if (speed == 0) { |
226 | via82cxxx_tune_drive(drive, 255); | 223 | ide_set_max_pio(drive); |
227 | return -1; | 224 | return -1; |
228 | } | 225 | } |
229 | 226 | ||
@@ -465,7 +462,7 @@ static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif) | |||
465 | 462 | ||
466 | hwif->autodma = 0; | 463 | hwif->autodma = 0; |
467 | 464 | ||
468 | hwif->tuneproc = &via82cxxx_tune_drive; | 465 | hwif->set_pio_mode = &via_set_pio_mode; |
469 | hwif->speedproc = &via_set_drive; | 466 | hwif->speedproc = &via_set_drive; |
470 | 467 | ||
471 | 468 | ||