diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2007-05-21 10:00:53 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-05-24 20:34:48 -0400 |
commit | dd668d150cad39d3af676519c81c2757fb7787da (patch) | |
tree | 7b40e9454dee6bd869819a2e044c4a49d01c4321 /drivers/ata/pata_sis.c | |
parent | 824cf333db97954d6144230b5e28f4e65e67d312 (diff) |
pata_sis: Fix and clean up some timing setups
- Rename sis_port_base to sis_old_port_base() so nobody uses it for new
generation controllers in error.
- Use byte size operations where it is cleaner for mode setup
- Fix a couple of masking errors on certai chip revs when setting speeds
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/pata_sis.c')
-rw-r--r-- | drivers/ata/pata_sis.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c index f2231267e011..ec3ae9375015 100644 --- a/drivers/ata/pata_sis.c +++ b/drivers/ata/pata_sis.c | |||
@@ -73,14 +73,14 @@ static int sis_short_ata40(struct pci_dev *dev) | |||
73 | } | 73 | } |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * sis_port_base - return PCI configuration base for dev | 76 | * sis_old_port_base - return PCI configuration base for dev |
77 | * @adev: device | 77 | * @adev: device |
78 | * | 78 | * |
79 | * Returns the base of the PCI configuration registers for this port | 79 | * Returns the base of the PCI configuration registers for this port |
80 | * number. | 80 | * number. |
81 | */ | 81 | */ |
82 | 82 | ||
83 | static int sis_port_base(struct ata_device *adev) | 83 | static int sis_old_port_base(struct ata_device *adev) |
84 | { | 84 | { |
85 | return 0x40 + (4 * adev->ap->port_no) + (2 * adev->devno); | 85 | return 0x40 + (4 * adev->ap->port_no) + (2 * adev->devno); |
86 | } | 86 | } |
@@ -211,7 +211,7 @@ static void sis_set_fifo(struct ata_port *ap, struct ata_device *adev) | |||
211 | static void sis_old_set_piomode (struct ata_port *ap, struct ata_device *adev) | 211 | static void sis_old_set_piomode (struct ata_port *ap, struct ata_device *adev) |
212 | { | 212 | { |
213 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 213 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
214 | int port = sis_port_base(adev); | 214 | int port = sis_old_port_base(adev); |
215 | u8 t1, t2; | 215 | u8 t1, t2; |
216 | int speed = adev->pio_mode - XFER_PIO_0; | 216 | int speed = adev->pio_mode - XFER_PIO_0; |
217 | 217 | ||
@@ -248,7 +248,7 @@ static void sis_old_set_piomode (struct ata_port *ap, struct ata_device *adev) | |||
248 | static void sis_100_set_piomode (struct ata_port *ap, struct ata_device *adev) | 248 | static void sis_100_set_piomode (struct ata_port *ap, struct ata_device *adev) |
249 | { | 249 | { |
250 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 250 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
251 | int port = sis_port_base(adev); | 251 | int port = sis_old_port_base(adev); |
252 | int speed = adev->pio_mode - XFER_PIO_0; | 252 | int speed = adev->pio_mode - XFER_PIO_0; |
253 | 253 | ||
254 | const u8 actrec[] = { 0x00, 0x67, 0x44, 0x33, 0x31 }; | 254 | const u8 actrec[] = { 0x00, 0x67, 0x44, 0x33, 0x31 }; |
@@ -328,7 +328,7 @@ static void sis_old_set_dmamode (struct ata_port *ap, struct ata_device *adev) | |||
328 | { | 328 | { |
329 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 329 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
330 | int speed = adev->dma_mode - XFER_MW_DMA_0; | 330 | int speed = adev->dma_mode - XFER_MW_DMA_0; |
331 | int drive_pci = sis_port_base(adev); | 331 | int drive_pci = sis_old_port_base(adev); |
332 | u16 timing; | 332 | u16 timing; |
333 | 333 | ||
334 | const u16 mwdma_bits[] = { 0x707, 0x202, 0x202 }; | 334 | const u16 mwdma_bits[] = { 0x707, 0x202, 0x202 }; |
@@ -367,7 +367,7 @@ static void sis_66_set_dmamode (struct ata_port *ap, struct ata_device *adev) | |||
367 | { | 367 | { |
368 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 368 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
369 | int speed = adev->dma_mode - XFER_MW_DMA_0; | 369 | int speed = adev->dma_mode - XFER_MW_DMA_0; |
370 | int drive_pci = sis_port_base(adev); | 370 | int drive_pci = sis_old_port_base(adev); |
371 | u16 timing; | 371 | u16 timing; |
372 | 372 | ||
373 | const u16 mwdma_bits[] = { 0x707, 0x202, 0x202 }; | 373 | const u16 mwdma_bits[] = { 0x707, 0x202, 0x202 }; |
@@ -378,12 +378,12 @@ static void sis_66_set_dmamode (struct ata_port *ap, struct ata_device *adev) | |||
378 | if (adev->dma_mode < XFER_UDMA_0) { | 378 | if (adev->dma_mode < XFER_UDMA_0) { |
379 | /* bits 3-0 hold recovery timing bits 8-10 active timing and | 379 | /* bits 3-0 hold recovery timing bits 8-10 active timing and |
380 | the higer bits are dependant on the device, bit 15 udma */ | 380 | the higer bits are dependant on the device, bit 15 udma */ |
381 | timing &= ~ 0x870F; | 381 | timing &= ~0x870F; |
382 | timing |= mwdma_bits[speed]; | 382 | timing |= mwdma_bits[speed]; |
383 | } else { | 383 | } else { |
384 | /* Bit 15 is UDMA on/off, bit 12-14 are cycle time */ | 384 | /* Bit 15 is UDMA on/off, bit 12-14 are cycle time */ |
385 | speed = adev->dma_mode - XFER_UDMA_0; | 385 | speed = adev->dma_mode - XFER_UDMA_0; |
386 | timing &= ~0x6000; | 386 | timing &= ~0xF000; |
387 | timing |= udma_bits[speed]; | 387 | timing |= udma_bits[speed]; |
388 | } | 388 | } |
389 | pci_write_config_word(pdev, drive_pci, timing); | 389 | pci_write_config_word(pdev, drive_pci, timing); |
@@ -405,22 +405,22 @@ static void sis_100_set_dmamode (struct ata_port *ap, struct ata_device *adev) | |||
405 | { | 405 | { |
406 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 406 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
407 | int speed = adev->dma_mode - XFER_MW_DMA_0; | 407 | int speed = adev->dma_mode - XFER_MW_DMA_0; |
408 | int drive_pci = sis_port_base(adev); | 408 | int drive_pci = sis_old_port_base(adev); |
409 | u16 timing; | 409 | u8 timing; |
410 | 410 | ||
411 | const u16 udma_bits[] = { 0x8B00, 0x8700, 0x8500, 0x8300, 0x8200, 0x8100}; | 411 | const u8 udma_bits[] = { 0x8B, 0x87, 0x85, 0x83, 0x82, 0x81}; |
412 | 412 | ||
413 | pci_read_config_word(pdev, drive_pci, &timing); | 413 | pci_read_config_byte(pdev, drive_pci + 1, &timing); |
414 | 414 | ||
415 | if (adev->dma_mode < XFER_UDMA_0) { | 415 | if (adev->dma_mode < XFER_UDMA_0) { |
416 | /* NOT SUPPORTED YET: NEED DATA SHEET. DITTO IN OLD DRIVER */ | 416 | /* NOT SUPPORTED YET: NEED DATA SHEET. DITTO IN OLD DRIVER */ |
417 | } else { | 417 | } else { |
418 | /* Bit 15 is UDMA on/off, bit 12-14 are cycle time */ | 418 | /* Bit 7 is UDMA on/off, bit 0-3 are cycle time */ |
419 | speed = adev->dma_mode - XFER_UDMA_0; | 419 | speed = adev->dma_mode - XFER_UDMA_0; |
420 | timing &= ~0x0F00; | 420 | timing &= ~0x8F; |
421 | timing |= udma_bits[speed]; | 421 | timing |= udma_bits[speed]; |
422 | } | 422 | } |
423 | pci_write_config_word(pdev, drive_pci, timing); | 423 | pci_write_config_byte(pdev, drive_pci + 1, timing); |
424 | } | 424 | } |
425 | 425 | ||
426 | /** | 426 | /** |
@@ -440,22 +440,22 @@ static void sis_133_early_set_dmamode (struct ata_port *ap, struct ata_device *a | |||
440 | { | 440 | { |
441 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 441 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
442 | int speed = adev->dma_mode - XFER_MW_DMA_0; | 442 | int speed = adev->dma_mode - XFER_MW_DMA_0; |
443 | int drive_pci = sis_port_base(adev); | 443 | int drive_pci = sis_old_port_base(adev); |
444 | u16 timing; | 444 | u8 timing; |
445 | 445 | /* Low 4 bits are timing */ | |
446 | static const u16 udma_bits[] = { 0x8F00, 0x8A00, 0x8700, 0x8500, 0x8300, 0x8200, 0x8100}; | 446 | static const u8 udma_bits[] = { 0x8F, 0x8A, 0x87, 0x85, 0x83, 0x82, 0x81}; |
447 | 447 | ||
448 | pci_read_config_word(pdev, drive_pci, &timing); | 448 | pci_read_config_byte(pdev, drive_pci + 1, &timing); |
449 | 449 | ||
450 | if (adev->dma_mode < XFER_UDMA_0) { | 450 | if (adev->dma_mode < XFER_UDMA_0) { |
451 | /* NOT SUPPORTED YET: NEED DATA SHEET. DITTO IN OLD DRIVER */ | 451 | /* NOT SUPPORTED YET: NEED DATA SHEET. DITTO IN OLD DRIVER */ |
452 | } else { | 452 | } else { |
453 | /* Bit 15 is UDMA on/off, bit 12-14 are cycle time */ | 453 | /* Bit 7 is UDMA on/off, bit 0-3 are cycle time */ |
454 | speed = adev->dma_mode - XFER_UDMA_0; | 454 | speed = adev->dma_mode - XFER_UDMA_0; |
455 | timing &= ~0x0F00; | 455 | timing &= ~0x8F; |
456 | timing |= udma_bits[speed]; | 456 | timing |= udma_bits[speed]; |
457 | } | 457 | } |
458 | pci_write_config_word(pdev, drive_pci, timing); | 458 | pci_write_config_byte(pdev, drive_pci + 1, timing); |
459 | } | 459 | } |
460 | 460 | ||
461 | /** | 461 | /** |