diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2011-10-13 08:54:48 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2011-10-14 13:22:54 -0400 |
commit | d9d579842e9e10a49e1ba6a16be5ce2757d38cc0 (patch) | |
tree | 8303b9d27f3ea8afc484c16f61bf5ee2353260ae /drivers | |
parent | bff00256f1b2d762dea3d6c2c9dc85d453fa3e8f (diff) |
pata_via: add via_fixup()
* Fix via_init_one() to enable clock on 66 MHz devices
(bug introduced in commit 460f531 "pata_via: store UDMA masks
in via_isa_bridges table").
* Factor out common code from via_[re]init_one() to via_fixup().
Acked-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ata/pata_via.c | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c index 8e9f5048a10a..255f336cd7ea 100644 --- a/drivers/ata/pata_via.c +++ b/drivers/ata/pata_via.c | |||
@@ -509,6 +509,27 @@ static void via_config_fifo(struct pci_dev *pdev, unsigned int flags) | |||
509 | } | 509 | } |
510 | } | 510 | } |
511 | 511 | ||
512 | static void via_fixup(struct pci_dev *pdev, const struct via_isa_bridge *config) | ||
513 | { | ||
514 | u32 timing; | ||
515 | |||
516 | /* Initialise the FIFO for the enabled channels. */ | ||
517 | via_config_fifo(pdev, config->flags); | ||
518 | |||
519 | if (config->udma_mask == ATA_UDMA4) { | ||
520 | /* The 66 MHz devices require we enable the clock */ | ||
521 | pci_read_config_dword(pdev, 0x50, &timing); | ||
522 | timing |= 0x80008; | ||
523 | pci_write_config_dword(pdev, 0x50, timing); | ||
524 | } | ||
525 | if (config->flags & VIA_BAD_CLK66) { | ||
526 | /* Disable the 66MHz clock on problem devices */ | ||
527 | pci_read_config_dword(pdev, 0x50, &timing); | ||
528 | timing &= ~0x80008; | ||
529 | pci_write_config_dword(pdev, 0x50, timing); | ||
530 | } | ||
531 | } | ||
532 | |||
512 | /** | 533 | /** |
513 | * via_init_one - discovery callback | 534 | * via_init_one - discovery callback |
514 | * @pdev: PCI device | 535 | * @pdev: PCI device |
@@ -570,7 +591,6 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
570 | struct pci_dev *isa; | 591 | struct pci_dev *isa; |
571 | const struct via_isa_bridge *config; | 592 | const struct via_isa_bridge *config; |
572 | u8 enable; | 593 | u8 enable; |
573 | u32 timing; | ||
574 | unsigned long flags = id->driver_data; | 594 | unsigned long flags = id->driver_data; |
575 | int rc; | 595 | int rc; |
576 | 596 | ||
@@ -609,9 +629,6 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
609 | return -ENODEV; | 629 | return -ENODEV; |
610 | } | 630 | } |
611 | 631 | ||
612 | /* Initialise the FIFO for the enabled channels. */ | ||
613 | via_config_fifo(pdev, config->flags); | ||
614 | |||
615 | /* Clock set up */ | 632 | /* Clock set up */ |
616 | switch (config->udma_mask) { | 633 | switch (config->udma_mask) { |
617 | case 0x00: | 634 | case 0x00: |
@@ -637,12 +654,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
637 | return -ENODEV; | 654 | return -ENODEV; |
638 | } | 655 | } |
639 | 656 | ||
640 | if (config->flags & VIA_BAD_CLK66) { | 657 | via_fixup(pdev, config); |
641 | /* Disable the 66MHz clock on problem devices */ | ||
642 | pci_read_config_dword(pdev, 0x50, &timing); | ||
643 | timing &= ~0x80008; | ||
644 | pci_write_config_dword(pdev, 0x50, timing); | ||
645 | } | ||
646 | 658 | ||
647 | /* We have established the device type, now fire it up */ | 659 | /* We have established the device type, now fire it up */ |
648 | return ata_pci_bmdma_init_one(pdev, ppi, &via_sht, (void *)config, 0); | 660 | return ata_pci_bmdma_init_one(pdev, ppi, &via_sht, (void *)config, 0); |
@@ -661,29 +673,14 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
661 | 673 | ||
662 | static int via_reinit_one(struct pci_dev *pdev) | 674 | static int via_reinit_one(struct pci_dev *pdev) |
663 | { | 675 | { |
664 | u32 timing; | ||
665 | struct ata_host *host = dev_get_drvdata(&pdev->dev); | 676 | struct ata_host *host = dev_get_drvdata(&pdev->dev); |
666 | const struct via_isa_bridge *config = host->private_data; | ||
667 | int rc; | 677 | int rc; |
668 | 678 | ||
669 | rc = ata_pci_device_do_resume(pdev); | 679 | rc = ata_pci_device_do_resume(pdev); |
670 | if (rc) | 680 | if (rc) |
671 | return rc; | 681 | return rc; |
672 | 682 | ||
673 | via_config_fifo(pdev, config->flags); | 683 | via_fixup(pdev, host->private_data); |
674 | |||
675 | if (config->udma_mask == ATA_UDMA4) { | ||
676 | /* The 66 MHz devices require we enable the clock */ | ||
677 | pci_read_config_dword(pdev, 0x50, &timing); | ||
678 | timing |= 0x80008; | ||
679 | pci_write_config_dword(pdev, 0x50, timing); | ||
680 | } | ||
681 | if (config->flags & VIA_BAD_CLK66) { | ||
682 | /* Disable the 66MHz clock on problem devices */ | ||
683 | pci_read_config_dword(pdev, 0x50, &timing); | ||
684 | timing &= ~0x80008; | ||
685 | pci_write_config_dword(pdev, 0x50, timing); | ||
686 | } | ||
687 | 684 | ||
688 | ata_host_resume(host); | 685 | ata_host_resume(host); |
689 | return 0; | 686 | return 0; |