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/cmd640.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/pci/cmd640.c')
-rw-r--r-- | drivers/ide/pci/cmd640.c | 35 |
1 files changed, 17 insertions, 18 deletions
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, |