diff options
Diffstat (limited to 'drivers/ide/pci/sis5513.c')
-rw-r--r-- | drivers/ide/pci/sis5513.c | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c index 26f24802d3e8..3e18899de631 100644 --- a/drivers/ide/pci/sis5513.c +++ b/drivers/ide/pci/sis5513.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/sis5513.c Version 0.25 Jun 10, 2007 | 2 | * linux/drivers/ide/pci/sis5513.c Version 0.27 Jul 14, 2007 |
3 | * | 3 | * |
4 | * Copyright (C) 1999-2000 Andre Hedrick <andre@linux-ide.org> | 4 | * Copyright (C) 1999-2000 Andre Hedrick <andre@linux-ide.org> |
5 | * Copyright (C) 2002 Lionel Bouton <Lionel.Bouton@inet6.fr>, Maintainer | 5 | * Copyright (C) 2002 Lionel Bouton <Lionel.Bouton@inet6.fr>, Maintainer |
@@ -519,27 +519,18 @@ 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 void sis_set_pio_mode(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 | (void)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 int sis5513_tune_chipset(ide_drive_t *drive, const u8 speed) |
530 | { | ||
531 | (void)sis5513_tune_drive(drive, pio); | ||
532 | } | ||
533 | |||
534 | static int sis5513_tune_chipset (ide_drive_t *drive, u8 xferspeed) | ||
535 | { | 529 | { |
536 | ide_hwif_t *hwif = HWIF(drive); | 530 | ide_hwif_t *hwif = HWIF(drive); |
537 | struct pci_dev *dev = hwif->pci_dev; | 531 | struct pci_dev *dev = hwif->pci_dev; |
538 | |||
539 | u8 drive_pci, reg, speed; | ||
540 | u32 regdw; | 532 | u32 regdw; |
541 | 533 | u8 drive_pci, reg; | |
542 | speed = ide_rate_filter(drive, xferspeed); | ||
543 | 534 | ||
544 | /* See config_art_rwp_pio for drive pci config registers */ | 535 | /* See config_art_rwp_pio for drive pci config registers */ |
545 | drive_pci = 0x40; | 536 | drive_pci = 0x40; |
@@ -582,9 +573,6 @@ static int sis5513_tune_chipset (ide_drive_t *drive, u8 xferspeed) | |||
582 | regdw |= (unsigned long)cycle_time_value[ATA_133][speed-XFER_UDMA_0] << 4; | 573 | regdw |= (unsigned long)cycle_time_value[ATA_133][speed-XFER_UDMA_0] << 4; |
583 | regdw |= (unsigned long)cvs_time_value[ATA_133][speed-XFER_UDMA_0] << 8; | 574 | regdw |= (unsigned long)cvs_time_value[ATA_133][speed-XFER_UDMA_0] << 8; |
584 | } else { | 575 | } else { |
585 | /* if ATA133 disable, we should not set speed above UDMA5 */ | ||
586 | if (speed > XFER_UDMA_5) | ||
587 | speed = XFER_UDMA_5; | ||
588 | regdw |= (unsigned long)cycle_time_value[ATA_100][speed-XFER_UDMA_0] << 4; | 576 | regdw |= (unsigned long)cycle_time_value[ATA_100][speed-XFER_UDMA_0] << 4; |
589 | regdw |= (unsigned long)cvs_time_value[ATA_100][speed-XFER_UDMA_0] << 8; | 577 | regdw |= (unsigned long)cvs_time_value[ATA_100][speed-XFER_UDMA_0] << 8; |
590 | } | 578 | } |
@@ -608,12 +596,6 @@ static int sis5513_tune_chipset (ide_drive_t *drive, u8 xferspeed) | |||
608 | case XFER_SW_DMA_1: | 596 | case XFER_SW_DMA_1: |
609 | case XFER_SW_DMA_0: | 597 | case XFER_SW_DMA_0: |
610 | break; | 598 | break; |
611 | case XFER_PIO_4: | ||
612 | case XFER_PIO_3: | ||
613 | case XFER_PIO_2: | ||
614 | case XFER_PIO_1: | ||
615 | case XFER_PIO_0: | ||
616 | return sis5513_tune_drive(drive, speed - XFER_PIO_0); | ||
617 | default: | 599 | default: |
618 | BUG(); | 600 | BUG(); |
619 | break; | 601 | break; |
@@ -627,7 +609,7 @@ static int sis5513_config_xfer_rate(ide_drive_t *drive) | |||
627 | /* | 609 | /* |
628 | * TODO: always set PIO mode and remove this | 610 | * TODO: always set PIO mode and remove this |
629 | */ | 611 | */ |
630 | sis5513_tuneproc(drive, 255); | 612 | ide_set_max_pio(drive); |
631 | 613 | ||
632 | drive->init_speed = 0; | 614 | drive->init_speed = 0; |
633 | 615 | ||
@@ -635,11 +617,25 @@ static int sis5513_config_xfer_rate(ide_drive_t *drive) | |||
635 | return 0; | 617 | return 0; |
636 | 618 | ||
637 | if (ide_use_fast_pio(drive)) | 619 | if (ide_use_fast_pio(drive)) |
638 | sis5513_tuneproc(drive, 255); | 620 | ide_set_max_pio(drive); |
639 | 621 | ||
640 | return -1; | 622 | return -1; |
641 | } | 623 | } |
642 | 624 | ||
625 | static u8 sis5513_ata133_udma_filter(ide_drive_t *drive) | ||
626 | { | ||
627 | struct pci_dev *dev = drive->hwif->pci_dev; | ||
628 | int drive_pci; | ||
629 | u32 reg54 = 0, regdw = 0; | ||
630 | |||
631 | pci_read_config_dword(dev, 0x54, ®54); | ||
632 | drive_pci = ((reg54 & 0x40000000) ? 0x70 : 0x40) + drive->dn * 4; | ||
633 | pci_read_config_dword(dev, drive_pci, ®dw); | ||
634 | |||
635 | /* if ATA133 disable, we should not set speed above UDMA5 */ | ||
636 | return (regdw & 0x08) ? ATA_UDMA6 : ATA_UDMA5; | ||
637 | } | ||
638 | |||
643 | /* Chip detection and general config */ | 639 | /* Chip detection and general config */ |
644 | static unsigned int __devinit init_chipset_sis5513 (struct pci_dev *dev, const char *name) | 640 | static unsigned int __devinit init_chipset_sis5513 (struct pci_dev *dev, const char *name) |
645 | { | 641 | { |
@@ -844,9 +840,12 @@ static void __devinit init_hwif_sis5513 (ide_hwif_t *hwif) | |||
844 | if (!hwif->irq) | 840 | if (!hwif->irq) |
845 | hwif->irq = hwif->channel ? 15 : 14; | 841 | hwif->irq = hwif->channel ? 15 : 14; |
846 | 842 | ||
847 | hwif->tuneproc = &sis5513_tuneproc; | 843 | hwif->set_pio_mode = &sis_set_pio_mode; |
848 | hwif->speedproc = &sis5513_tune_chipset; | 844 | hwif->speedproc = &sis5513_tune_chipset; |
849 | 845 | ||
846 | if (chipset_family >= ATA_133) | ||
847 | hwif->udma_filter = sis5513_ata133_udma_filter; | ||
848 | |||
850 | if (!(hwif->dma_base)) { | 849 | if (!(hwif->dma_base)) { |
851 | hwif->drives[0].autotune = 1; | 850 | hwif->drives[0].autotune = 1; |
852 | hwif->drives[1].autotune = 1; | 851 | hwif->drives[1].autotune = 1; |