diff options
Diffstat (limited to 'drivers/ata/ata_piix.c')
| -rw-r--r-- | drivers/ata/ata_piix.c | 153 |
1 files changed, 73 insertions, 80 deletions
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c index 43107e9415da..69ac373c72ab 100644 --- a/drivers/ata/ata_piix.c +++ b/drivers/ata/ata_piix.c | |||
| @@ -113,6 +113,8 @@ enum { | |||
| 113 | PIIX_PATA_FLAGS = ATA_FLAG_SLAVE_POSS, | 113 | PIIX_PATA_FLAGS = ATA_FLAG_SLAVE_POSS, |
| 114 | PIIX_SATA_FLAGS = ATA_FLAG_SATA | PIIX_FLAG_CHECKINTR, | 114 | PIIX_SATA_FLAGS = ATA_FLAG_SATA | PIIX_FLAG_CHECKINTR, |
| 115 | 115 | ||
| 116 | PIIX_FLAG_PIO16 = (1 << 30), /*support 16bit PIO only*/ | ||
| 117 | |||
| 116 | PIIX_80C_PRI = (1 << 5) | (1 << 4), | 118 | PIIX_80C_PRI = (1 << 5) | (1 << 4), |
| 117 | PIIX_80C_SEC = (1 << 7) | (1 << 6), | 119 | PIIX_80C_SEC = (1 << 7) | (1 << 6), |
| 118 | 120 | ||
| @@ -147,6 +149,7 @@ enum piix_controller_ids { | |||
| 147 | ich8m_apple_sata, /* locks up on second port enable */ | 149 | ich8m_apple_sata, /* locks up on second port enable */ |
| 148 | tolapai_sata, | 150 | tolapai_sata, |
| 149 | piix_pata_vmw, /* PIIX4 for VMware, spurious DMA_ERR */ | 151 | piix_pata_vmw, /* PIIX4 for VMware, spurious DMA_ERR */ |
| 152 | ich8_sata_snb, | ||
| 150 | }; | 153 | }; |
| 151 | 154 | ||
| 152 | struct piix_map_db { | 155 | struct piix_map_db { |
| @@ -177,6 +180,7 @@ static int piix_sidpr_scr_write(struct ata_link *link, | |||
| 177 | static int piix_sidpr_set_lpm(struct ata_link *link, enum ata_lpm_policy policy, | 180 | static int piix_sidpr_set_lpm(struct ata_link *link, enum ata_lpm_policy policy, |
| 178 | unsigned hints); | 181 | unsigned hints); |
| 179 | static bool piix_irq_check(struct ata_port *ap); | 182 | static bool piix_irq_check(struct ata_port *ap); |
| 183 | static int piix_port_start(struct ata_port *ap); | ||
| 180 | #ifdef CONFIG_PM | 184 | #ifdef CONFIG_PM |
| 181 | static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); | 185 | static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); |
| 182 | static int piix_pci_device_resume(struct pci_dev *pdev); | 186 | static int piix_pci_device_resume(struct pci_dev *pdev); |
| @@ -298,21 +302,21 @@ static const struct pci_device_id piix_pci_tbl[] = { | |||
| 298 | /* SATA Controller IDE (PCH) */ | 302 | /* SATA Controller IDE (PCH) */ |
| 299 | { 0x8086, 0x3b2e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, | 303 | { 0x8086, 0x3b2e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, |
| 300 | /* SATA Controller IDE (CPT) */ | 304 | /* SATA Controller IDE (CPT) */ |
| 301 | { 0x8086, 0x1c00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, | 305 | { 0x8086, 0x1c00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb }, |
| 302 | /* SATA Controller IDE (CPT) */ | 306 | /* SATA Controller IDE (CPT) */ |
| 303 | { 0x8086, 0x1c01, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, | 307 | { 0x8086, 0x1c01, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb }, |
| 304 | /* SATA Controller IDE (CPT) */ | 308 | /* SATA Controller IDE (CPT) */ |
| 305 | { 0x8086, 0x1c08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, | 309 | { 0x8086, 0x1c08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, |
| 306 | /* SATA Controller IDE (CPT) */ | 310 | /* SATA Controller IDE (CPT) */ |
| 307 | { 0x8086, 0x1c09, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, | 311 | { 0x8086, 0x1c09, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, |
| 308 | /* SATA Controller IDE (PBG) */ | 312 | /* SATA Controller IDE (PBG) */ |
| 309 | { 0x8086, 0x1d00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, | 313 | { 0x8086, 0x1d00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb }, |
| 310 | /* SATA Controller IDE (PBG) */ | 314 | /* SATA Controller IDE (PBG) */ |
| 311 | { 0x8086, 0x1d08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, | 315 | { 0x8086, 0x1d08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, |
| 312 | /* SATA Controller IDE (Panther Point) */ | 316 | /* SATA Controller IDE (Panther Point) */ |
| 313 | { 0x8086, 0x1e00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, | 317 | { 0x8086, 0x1e00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb }, |
| 314 | /* SATA Controller IDE (Panther Point) */ | 318 | /* SATA Controller IDE (Panther Point) */ |
| 315 | { 0x8086, 0x1e01, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, | 319 | { 0x8086, 0x1e01, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb }, |
| 316 | /* SATA Controller IDE (Panther Point) */ | 320 | /* SATA Controller IDE (Panther Point) */ |
| 317 | { 0x8086, 0x1e08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, | 321 | { 0x8086, 0x1e08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, |
| 318 | /* SATA Controller IDE (Panther Point) */ | 322 | /* SATA Controller IDE (Panther Point) */ |
| @@ -338,6 +342,7 @@ static struct scsi_host_template piix_sht = { | |||
| 338 | static struct ata_port_operations piix_sata_ops = { | 342 | static struct ata_port_operations piix_sata_ops = { |
| 339 | .inherits = &ata_bmdma32_port_ops, | 343 | .inherits = &ata_bmdma32_port_ops, |
| 340 | .sff_irq_check = piix_irq_check, | 344 | .sff_irq_check = piix_irq_check, |
| 345 | .port_start = piix_port_start, | ||
| 341 | }; | 346 | }; |
| 342 | 347 | ||
| 343 | static struct ata_port_operations piix_pata_ops = { | 348 | static struct ata_port_operations piix_pata_ops = { |
| @@ -478,6 +483,7 @@ static const struct piix_map_db *piix_map_db_table[] = { | |||
| 478 | [ich8_2port_sata] = &ich8_2port_map_db, | 483 | [ich8_2port_sata] = &ich8_2port_map_db, |
| 479 | [ich8m_apple_sata] = &ich8m_apple_map_db, | 484 | [ich8m_apple_sata] = &ich8m_apple_map_db, |
| 480 | [tolapai_sata] = &tolapai_map_db, | 485 | [tolapai_sata] = &tolapai_map_db, |
| 486 | [ich8_sata_snb] = &ich8_map_db, | ||
| 481 | }; | 487 | }; |
| 482 | 488 | ||
| 483 | static struct ata_port_info piix_port_info[] = { | 489 | static struct ata_port_info piix_port_info[] = { |
| @@ -606,6 +612,19 @@ static struct ata_port_info piix_port_info[] = { | |||
| 606 | .port_ops = &piix_vmw_ops, | 612 | .port_ops = &piix_vmw_ops, |
| 607 | }, | 613 | }, |
| 608 | 614 | ||
| 615 | /* | ||
| 616 | * some Sandybridge chipsets have broken 32 mode up to now, | ||
| 617 | * see https://bugzilla.kernel.org/show_bug.cgi?id=40592 | ||
| 618 | */ | ||
| 619 | [ich8_sata_snb] = | ||
| 620 | { | ||
| 621 | .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SIDPR | PIIX_FLAG_PIO16, | ||
| 622 | .pio_mask = ATA_PIO4, | ||
| 623 | .mwdma_mask = ATA_MWDMA2, | ||
| 624 | .udma_mask = ATA_UDMA6, | ||
| 625 | .port_ops = &piix_sata_ops, | ||
| 626 | }, | ||
| 627 | |||
| 609 | }; | 628 | }; |
| 610 | 629 | ||
| 611 | static struct pci_bits piix_enable_bits[] = { | 630 | static struct pci_bits piix_enable_bits[] = { |
| @@ -649,6 +668,14 @@ static const struct ich_laptop ich_laptop[] = { | |||
| 649 | { 0, } | 668 | { 0, } |
| 650 | }; | 669 | }; |
| 651 | 670 | ||
| 671 | static int piix_port_start(struct ata_port *ap) | ||
| 672 | { | ||
| 673 | if (!(ap->flags & PIIX_FLAG_PIO16)) | ||
| 674 | ap->pflags |= ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE; | ||
| 675 | |||
| 676 | return ata_bmdma_port_start(ap); | ||
| 677 | } | ||
| 678 | |||
| 652 | /** | 679 | /** |
| 653 | * ich_pata_cable_detect - Probe host controller cable detect info | 680 | * ich_pata_cable_detect - Probe host controller cable detect info |
| 654 | * @ap: Port for which cable detect info is desired | 681 | * @ap: Port for which cable detect info is desired |
| @@ -704,22 +731,11 @@ static int piix_pata_prereset(struct ata_link *link, unsigned long deadline) | |||
| 704 | 731 | ||
| 705 | static DEFINE_SPINLOCK(piix_lock); | 732 | static DEFINE_SPINLOCK(piix_lock); |
| 706 | 733 | ||
| 707 | /** | 734 | static void piix_set_timings(struct ata_port *ap, struct ata_device *adev, |
| 708 | * piix_set_piomode - Initialize host controller PATA PIO timings | 735 | u8 pio) |
| 709 | * @ap: Port whose timings we are configuring | ||
| 710 | * @adev: um | ||
| 711 | * | ||
| 712 | * Set PIO mode for device, in host controller PCI config space. | ||
| 713 | * | ||
| 714 | * LOCKING: | ||
| 715 | * None (inherited from caller). | ||
| 716 | */ | ||
| 717 | |||
| 718 | static void piix_set_piomode(struct ata_port *ap, struct ata_device *adev) | ||
| 719 | { | 736 | { |
| 720 | struct pci_dev *dev = to_pci_dev(ap->host->dev); | 737 | struct pci_dev *dev = to_pci_dev(ap->host->dev); |
| 721 | unsigned long flags; | 738 | unsigned long flags; |
| 722 | unsigned int pio = adev->pio_mode - XFER_PIO_0; | ||
| 723 | unsigned int is_slave = (adev->devno != 0); | 739 | unsigned int is_slave = (adev->devno != 0); |
| 724 | unsigned int master_port= ap->port_no ? 0x42 : 0x40; | 740 | unsigned int master_port= ap->port_no ? 0x42 : 0x40; |
| 725 | unsigned int slave_port = 0x44; | 741 | unsigned int slave_port = 0x44; |
| @@ -744,10 +760,16 @@ static void piix_set_piomode(struct ata_port *ap, struct ata_device *adev) | |||
| 744 | control |= 1; /* TIME1 enable */ | 760 | control |= 1; /* TIME1 enable */ |
| 745 | if (ata_pio_need_iordy(adev)) | 761 | if (ata_pio_need_iordy(adev)) |
| 746 | control |= 2; /* IE enable */ | 762 | control |= 2; /* IE enable */ |
| 747 | |||
| 748 | /* Intel specifies that the PPE functionality is for disk only */ | 763 | /* Intel specifies that the PPE functionality is for disk only */ |
| 749 | if (adev->class == ATA_DEV_ATA) | 764 | if (adev->class == ATA_DEV_ATA) |
| 750 | control |= 4; /* PPE enable */ | 765 | control |= 4; /* PPE enable */ |
| 766 | /* | ||
| 767 | * If the drive MWDMA is faster than it can do PIO then | ||
| 768 | * we must force PIO into PIO0 | ||
| 769 | */ | ||
| 770 | if (adev->pio_mode < XFER_PIO_0 + pio) | ||
| 771 | /* Enable DMA timing only */ | ||
| 772 | control |= 8; /* PIO cycles in PIO0 */ | ||
| 751 | 773 | ||
| 752 | spin_lock_irqsave(&piix_lock, flags); | 774 | spin_lock_irqsave(&piix_lock, flags); |
| 753 | 775 | ||
| @@ -759,8 +781,6 @@ static void piix_set_piomode(struct ata_port *ap, struct ata_device *adev) | |||
| 759 | if (is_slave) { | 781 | if (is_slave) { |
| 760 | /* clear TIME1|IE1|PPE1|DTE1 */ | 782 | /* clear TIME1|IE1|PPE1|DTE1 */ |
| 761 | master_data &= 0xff0f; | 783 | master_data &= 0xff0f; |
| 762 | /* Enable SITRE (separate slave timing register) */ | ||
| 763 | master_data |= 0x4000; | ||
| 764 | /* enable PPE1, IE1 and TIME1 as needed */ | 784 | /* enable PPE1, IE1 and TIME1 as needed */ |
| 765 | master_data |= (control << 4); | 785 | master_data |= (control << 4); |
| 766 | pci_read_config_byte(dev, slave_port, &slave_data); | 786 | pci_read_config_byte(dev, slave_port, &slave_data); |
| @@ -778,6 +798,9 @@ static void piix_set_piomode(struct ata_port *ap, struct ata_device *adev) | |||
| 778 | (timings[pio][0] << 12) | | 798 | (timings[pio][0] << 12) | |
| 779 | (timings[pio][1] << 8); | 799 | (timings[pio][1] << 8); |
| 780 | } | 800 | } |
| 801 | |||
| 802 | /* Enable SITRE (separate slave timing register) */ | ||
| 803 | master_data |= 0x4000; | ||
| 781 | pci_write_config_word(dev, master_port, master_data); | 804 | pci_write_config_word(dev, master_port, master_data); |
| 782 | if (is_slave) | 805 | if (is_slave) |
| 783 | pci_write_config_byte(dev, slave_port, slave_data); | 806 | pci_write_config_byte(dev, slave_port, slave_data); |
| @@ -795,6 +818,22 @@ static void piix_set_piomode(struct ata_port *ap, struct ata_device *adev) | |||
| 795 | } | 818 | } |
| 796 | 819 | ||
| 797 | /** | 820 | /** |
| 821 | * piix_set_piomode - Initialize host controller PATA PIO timings | ||
| 822 | * @ap: Port whose timings we are configuring | ||
| 823 | * @adev: Drive in question | ||
| 824 | * | ||
| 825 | * Set PIO mode for device, in host controller PCI config space. | ||
| 826 | * | ||
| 827 | * LOCKING: | ||
| 828 | * None (inherited from caller). | ||
| 829 | */ | ||
| 830 | |||
| 831 | static void piix_set_piomode(struct ata_port *ap, struct ata_device *adev) | ||
| 832 | { | ||
| 833 | piix_set_timings(ap, adev, adev->pio_mode - XFER_PIO_0); | ||
| 834 | } | ||
| 835 | |||
| 836 | /** | ||
| 798 | * do_pata_set_dmamode - Initialize host controller PATA PIO timings | 837 | * do_pata_set_dmamode - Initialize host controller PATA PIO timings |
| 799 | * @ap: Port whose timings we are configuring | 838 | * @ap: Port whose timings we are configuring |
| 800 | * @adev: Drive in question | 839 | * @adev: Drive in question |
| @@ -810,31 +849,20 @@ static void do_pata_set_dmamode(struct ata_port *ap, struct ata_device *adev, in | |||
| 810 | { | 849 | { |
| 811 | struct pci_dev *dev = to_pci_dev(ap->host->dev); | 850 | struct pci_dev *dev = to_pci_dev(ap->host->dev); |
| 812 | unsigned long flags; | 851 | unsigned long flags; |
| 813 | u8 master_port = ap->port_no ? 0x42 : 0x40; | ||
| 814 | u16 master_data; | ||
| 815 | u8 speed = adev->dma_mode; | 852 | u8 speed = adev->dma_mode; |
| 816 | int devid = adev->devno + 2 * ap->port_no; | 853 | int devid = adev->devno + 2 * ap->port_no; |
| 817 | u8 udma_enable = 0; | 854 | u8 udma_enable = 0; |
| 818 | 855 | ||
| 819 | static const /* ISP RTC */ | ||
| 820 | u8 timings[][2] = { { 0, 0 }, | ||
| 821 | { 0, 0 }, | ||
| 822 | { 1, 0 }, | ||
| 823 | { 2, 1 }, | ||
| 824 | { 2, 3 }, }; | ||
| 825 | |||
| 826 | spin_lock_irqsave(&piix_lock, flags); | ||
| 827 | |||
| 828 | pci_read_config_word(dev, master_port, &master_data); | ||
| 829 | if (ap->udma_mask) | ||
| 830 | pci_read_config_byte(dev, 0x48, &udma_enable); | ||
| 831 | |||
| 832 | if (speed >= XFER_UDMA_0) { | 856 | if (speed >= XFER_UDMA_0) { |
| 833 | unsigned int udma = adev->dma_mode - XFER_UDMA_0; | 857 | unsigned int udma = speed - XFER_UDMA_0; |
| 834 | u16 udma_timing; | 858 | u16 udma_timing; |
| 835 | u16 ideconf; | 859 | u16 ideconf; |
| 836 | int u_clock, u_speed; | 860 | int u_clock, u_speed; |
| 837 | 861 | ||
| 862 | spin_lock_irqsave(&piix_lock, flags); | ||
| 863 | |||
| 864 | pci_read_config_byte(dev, 0x48, &udma_enable); | ||
| 865 | |||
| 838 | /* | 866 | /* |
| 839 | * UDMA is handled by a combination of clock switching and | 867 | * UDMA is handled by a combination of clock switching and |
| 840 | * selection of dividers | 868 | * selection of dividers |
| @@ -867,56 +895,21 @@ static void do_pata_set_dmamode(struct ata_port *ap, struct ata_device *adev, in | |||
| 867 | performance (WR_PingPong_En) */ | 895 | performance (WR_PingPong_En) */ |
| 868 | pci_write_config_word(dev, 0x54, ideconf); | 896 | pci_write_config_word(dev, 0x54, ideconf); |
| 869 | } | 897 | } |
| 898 | |||
| 899 | pci_write_config_byte(dev, 0x48, udma_enable); | ||
| 900 | |||
| 901 | spin_unlock_irqrestore(&piix_lock, flags); | ||
| 870 | } else { | 902 | } else { |
| 871 | /* | 903 | /* MWDMA is driven by the PIO timings. */ |
| 872 | * MWDMA is driven by the PIO timings. We must also enable | 904 | unsigned int mwdma = speed - XFER_MW_DMA_0; |
| 873 | * IORDY unconditionally along with TIME1. PPE has already | ||
| 874 | * been set when the PIO timing was set. | ||
| 875 | */ | ||
| 876 | unsigned int mwdma = adev->dma_mode - XFER_MW_DMA_0; | ||
| 877 | unsigned int control; | ||
| 878 | u8 slave_data; | ||
| 879 | const unsigned int needed_pio[3] = { | 905 | const unsigned int needed_pio[3] = { |
| 880 | XFER_PIO_0, XFER_PIO_3, XFER_PIO_4 | 906 | XFER_PIO_0, XFER_PIO_3, XFER_PIO_4 |
| 881 | }; | 907 | }; |
| 882 | int pio = needed_pio[mwdma] - XFER_PIO_0; | 908 | int pio = needed_pio[mwdma] - XFER_PIO_0; |
| 883 | 909 | ||
| 884 | control = 3; /* IORDY|TIME1 */ | 910 | /* XFER_PIO_0 is never used currently */ |
| 885 | 911 | piix_set_timings(ap, adev, pio); | |
| 886 | /* If the drive MWDMA is faster than it can do PIO then | ||
| 887 | we must force PIO into PIO0 */ | ||
| 888 | |||
| 889 | if (adev->pio_mode < needed_pio[mwdma]) | ||
| 890 | /* Enable DMA timing only */ | ||
| 891 | control |= 8; /* PIO cycles in PIO0 */ | ||
| 892 | |||
| 893 | if (adev->devno) { /* Slave */ | ||
| 894 | master_data &= 0xFF4F; /* Mask out IORDY|TIME1|DMAONLY */ | ||
| 895 | master_data |= control << 4; | ||
| 896 | pci_read_config_byte(dev, 0x44, &slave_data); | ||
| 897 | slave_data &= (ap->port_no ? 0x0f : 0xf0); | ||
| 898 | /* Load the matching timing */ | ||
| 899 | slave_data |= ((timings[pio][0] << 2) | timings[pio][1]) << (ap->port_no ? 4 : 0); | ||
| 900 | pci_write_config_byte(dev, 0x44, slave_data); | ||
| 901 | } else { /* Master */ | ||
| 902 | master_data &= 0xCCF4; /* Mask out IORDY|TIME1|DMAONLY | ||
| 903 | and master timing bits */ | ||
| 904 | master_data |= control; | ||
| 905 | master_data |= | ||
| 906 | (timings[pio][0] << 12) | | ||
| 907 | (timings[pio][1] << 8); | ||
| 908 | } | ||
| 909 | |||
| 910 | if (ap->udma_mask) | ||
| 911 | udma_enable &= ~(1 << devid); | ||
| 912 | |||
| 913 | pci_write_config_word(dev, master_port, master_data); | ||
| 914 | } | 912 | } |
| 915 | /* Don't scribble on 0x48 if the controller does not support UDMA */ | ||
| 916 | if (ap->udma_mask) | ||
| 917 | pci_write_config_byte(dev, 0x48, udma_enable); | ||
| 918 | |||
| 919 | spin_unlock_irqrestore(&piix_lock, flags); | ||
| 920 | } | 913 | } |
| 921 | 914 | ||
| 922 | /** | 915 | /** |
