diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2009-02-11 16:08:41 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2009-02-25 15:30:16 -0500 |
commit | c48052cc36e02fff6a9bb3cf83c4206b9127611f (patch) | |
tree | 7f93272031092a90d2b5decccd381319aae72be4 /drivers/ata | |
parent | 6be96ac15e4d913e1f48299db083ada5321803b2 (diff) |
[libata] pata_amd: program FIFO
With 32bit PIO we can use the posted write buffers, but only for 32bit I/O
cycles. This means we must disable the FIFO for ATAPI where a final 16bit
cycle may occur.
Rework the FIFO logic so that we disable the FIFO then selectively
re-enable it when we set the timings on AMD devices. Also fix a case
where we scribbled on PCI config 0x41 of Nvidia chips when we shouldn't.
Signed-off-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata')
-rw-r--r-- | drivers/ata/pata_amd.c | 76 |
1 files changed, 59 insertions, 17 deletions
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c index 63719ab9ea44..115b1cd6dcf5 100644 --- a/drivers/ata/pata_amd.c +++ b/drivers/ata/pata_amd.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <linux/libata.h> | 24 | #include <linux/libata.h> |
25 | 25 | ||
26 | #define DRV_NAME "pata_amd" | 26 | #define DRV_NAME "pata_amd" |
27 | #define DRV_VERSION "0.3.11" | 27 | #define DRV_VERSION "0.4.1" |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * timing_setup - shared timing computation and load | 30 | * timing_setup - shared timing computation and load |
@@ -145,6 +145,13 @@ static int amd_pre_reset(struct ata_link *link, unsigned long deadline) | |||
145 | return ata_sff_prereset(link, deadline); | 145 | return ata_sff_prereset(link, deadline); |
146 | } | 146 | } |
147 | 147 | ||
148 | /** | ||
149 | * amd_cable_detect - report cable type | ||
150 | * @ap: port | ||
151 | * | ||
152 | * AMD controller/BIOS setups record the cable type in word 0x42 | ||
153 | */ | ||
154 | |||
148 | static int amd_cable_detect(struct ata_port *ap) | 155 | static int amd_cable_detect(struct ata_port *ap) |
149 | { | 156 | { |
150 | static const u32 bitmask[2] = {0x03, 0x0C}; | 157 | static const u32 bitmask[2] = {0x03, 0x0C}; |
@@ -158,6 +165,40 @@ static int amd_cable_detect(struct ata_port *ap) | |||
158 | } | 165 | } |
159 | 166 | ||
160 | /** | 167 | /** |
168 | * amd_fifo_setup - set the PIO FIFO for ATA/ATAPI | ||
169 | * @ap: ATA interface | ||
170 | * @adev: ATA device | ||
171 | * | ||
172 | * Set the PCI fifo for this device according to the devices present | ||
173 | * on the bus at this point in time. We need to turn the post write buffer | ||
174 | * off for ATAPI devices as we may need to issue a word sized write to the | ||
175 | * device as the final I/O | ||
176 | */ | ||
177 | |||
178 | static void amd_fifo_setup(struct ata_port *ap) | ||
179 | { | ||
180 | struct ata_device *adev; | ||
181 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | ||
182 | static const u8 fifobit[2] = { 0xC0, 0x30}; | ||
183 | u8 fifo = fifobit[ap->port_no]; | ||
184 | u8 r; | ||
185 | |||
186 | |||
187 | ata_for_each_dev(adev, &ap->link, ENABLED) { | ||
188 | if (adev->class == ATA_DEV_ATAPI) | ||
189 | fifo = 0; | ||
190 | } | ||
191 | if (pdev->device == PCI_DEVICE_ID_AMD_VIPER_7411) /* FIFO is broken */ | ||
192 | fifo = 0; | ||
193 | |||
194 | /* On the later chips the read prefetch bits become no-op bits */ | ||
195 | pci_read_config_byte(pdev, 0x41, &r); | ||
196 | r &= ~fifobit[ap->port_no]; | ||
197 | r |= fifo; | ||
198 | pci_write_config_byte(pdev, 0x41, r); | ||
199 | } | ||
200 | |||
201 | /** | ||
161 | * amd33_set_piomode - set initial PIO mode data | 202 | * amd33_set_piomode - set initial PIO mode data |
162 | * @ap: ATA interface | 203 | * @ap: ATA interface |
163 | * @adev: ATA device | 204 | * @adev: ATA device |
@@ -167,21 +208,25 @@ static int amd_cable_detect(struct ata_port *ap) | |||
167 | 208 | ||
168 | static void amd33_set_piomode(struct ata_port *ap, struct ata_device *adev) | 209 | static void amd33_set_piomode(struct ata_port *ap, struct ata_device *adev) |
169 | { | 210 | { |
211 | amd_fifo_setup(ap); | ||
170 | timing_setup(ap, adev, 0x40, adev->pio_mode, 1); | 212 | timing_setup(ap, adev, 0x40, adev->pio_mode, 1); |
171 | } | 213 | } |
172 | 214 | ||
173 | static void amd66_set_piomode(struct ata_port *ap, struct ata_device *adev) | 215 | static void amd66_set_piomode(struct ata_port *ap, struct ata_device *adev) |
174 | { | 216 | { |
217 | amd_fifo_setup(ap); | ||
175 | timing_setup(ap, adev, 0x40, adev->pio_mode, 2); | 218 | timing_setup(ap, adev, 0x40, adev->pio_mode, 2); |
176 | } | 219 | } |
177 | 220 | ||
178 | static void amd100_set_piomode(struct ata_port *ap, struct ata_device *adev) | 221 | static void amd100_set_piomode(struct ata_port *ap, struct ata_device *adev) |
179 | { | 222 | { |
223 | amd_fifo_setup(ap); | ||
180 | timing_setup(ap, adev, 0x40, adev->pio_mode, 3); | 224 | timing_setup(ap, adev, 0x40, adev->pio_mode, 3); |
181 | } | 225 | } |
182 | 226 | ||
183 | static void amd133_set_piomode(struct ata_port *ap, struct ata_device *adev) | 227 | static void amd133_set_piomode(struct ata_port *ap, struct ata_device *adev) |
184 | { | 228 | { |
229 | amd_fifo_setup(ap); | ||
185 | timing_setup(ap, adev, 0x40, adev->pio_mode, 4); | 230 | timing_setup(ap, adev, 0x40, adev->pio_mode, 4); |
186 | } | 231 | } |
187 | 232 | ||
@@ -397,6 +442,16 @@ static struct ata_port_operations nv133_port_ops = { | |||
397 | .set_dmamode = nv133_set_dmamode, | 442 | .set_dmamode = nv133_set_dmamode, |
398 | }; | 443 | }; |
399 | 444 | ||
445 | static void amd_clear_fifo(struct pci_dev *pdev) | ||
446 | { | ||
447 | u8 fifo; | ||
448 | /* Disable the FIFO, the FIFO logic will re-enable it as | ||
449 | appropriate */ | ||
450 | pci_read_config_byte(pdev, 0x41, &fifo); | ||
451 | fifo &= 0x0F; | ||
452 | pci_write_config_byte(pdev, 0x41, fifo); | ||
453 | } | ||
454 | |||
400 | static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 455 | static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
401 | { | 456 | { |
402 | static const struct ata_port_info info[10] = { | 457 | static const struct ata_port_info info[10] = { |
@@ -503,14 +558,8 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
503 | 558 | ||
504 | if (type < 3) | 559 | if (type < 3) |
505 | ata_pci_bmdma_clear_simplex(pdev); | 560 | ata_pci_bmdma_clear_simplex(pdev); |
506 | 561 | if (pdev->vendor == PCI_VENDOR_ID_AMD) | |
507 | /* Check for AMD7411 */ | 562 | amd_clear_fifo(pdev); |
508 | if (type == 3) | ||
509 | /* FIFO is broken */ | ||
510 | pci_write_config_byte(pdev, 0x41, fifo & 0x0F); | ||
511 | else | ||
512 | pci_write_config_byte(pdev, 0x41, fifo | 0xF0); | ||
513 | |||
514 | /* Cable detection on Nvidia chips doesn't work too well, | 563 | /* Cable detection on Nvidia chips doesn't work too well, |
515 | * cache BIOS programmed UDMA mode. | 564 | * cache BIOS programmed UDMA mode. |
516 | */ | 565 | */ |
@@ -536,18 +585,11 @@ static int amd_reinit_one(struct pci_dev *pdev) | |||
536 | return rc; | 585 | return rc; |
537 | 586 | ||
538 | if (pdev->vendor == PCI_VENDOR_ID_AMD) { | 587 | if (pdev->vendor == PCI_VENDOR_ID_AMD) { |
539 | u8 fifo; | 588 | amd_clear_fifo(pdev); |
540 | pci_read_config_byte(pdev, 0x41, &fifo); | ||
541 | if (pdev->device == PCI_DEVICE_ID_AMD_VIPER_7411) | ||
542 | /* FIFO is broken */ | ||
543 | pci_write_config_byte(pdev, 0x41, fifo & 0x0F); | ||
544 | else | ||
545 | pci_write_config_byte(pdev, 0x41, fifo | 0xF0); | ||
546 | if (pdev->device == PCI_DEVICE_ID_AMD_VIPER_7409 || | 589 | if (pdev->device == PCI_DEVICE_ID_AMD_VIPER_7409 || |
547 | pdev->device == PCI_DEVICE_ID_AMD_COBRA_7401) | 590 | pdev->device == PCI_DEVICE_ID_AMD_COBRA_7401) |
548 | ata_pci_bmdma_clear_simplex(pdev); | 591 | ata_pci_bmdma_clear_simplex(pdev); |
549 | } | 592 | } |
550 | |||
551 | ata_host_resume(host); | 593 | ata_host_resume(host); |
552 | return 0; | 594 | return 0; |
553 | } | 595 | } |