mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-01 06:33:07 +00:00
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>
This commit is contained in:
parent
824cf333db
commit
dd668d150c
1 changed files with 23 additions and 23 deletions
|
@ -73,14 +73,14 @@ static int sis_short_ata40(struct pci_dev *dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sis_port_base - return PCI configuration base for dev
|
* sis_old_port_base - return PCI configuration base for dev
|
||||||
* @adev: device
|
* @adev: device
|
||||||
*
|
*
|
||||||
* Returns the base of the PCI configuration registers for this port
|
* Returns the base of the PCI configuration registers for this port
|
||||||
* number.
|
* number.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int sis_port_base(struct ata_device *adev)
|
static int sis_old_port_base(struct ata_device *adev)
|
||||||
{
|
{
|
||||||
return 0x40 + (4 * adev->ap->port_no) + (2 * adev->devno);
|
return 0x40 + (4 * adev->ap->port_no) + (2 * adev->devno);
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ static void sis_set_fifo(struct ata_port *ap, struct ata_device *adev)
|
||||||
static void sis_old_set_piomode (struct ata_port *ap, struct ata_device *adev)
|
static void sis_old_set_piomode (struct ata_port *ap, struct ata_device *adev)
|
||||||
{
|
{
|
||||||
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
||||||
int port = sis_port_base(adev);
|
int port = sis_old_port_base(adev);
|
||||||
u8 t1, t2;
|
u8 t1, t2;
|
||||||
int speed = adev->pio_mode - XFER_PIO_0;
|
int speed = adev->pio_mode - XFER_PIO_0;
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ static void sis_old_set_piomode (struct ata_port *ap, struct ata_device *adev)
|
||||||
static void sis_100_set_piomode (struct ata_port *ap, struct ata_device *adev)
|
static void sis_100_set_piomode (struct ata_port *ap, struct ata_device *adev)
|
||||||
{
|
{
|
||||||
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
||||||
int port = sis_port_base(adev);
|
int port = sis_old_port_base(adev);
|
||||||
int speed = adev->pio_mode - XFER_PIO_0;
|
int speed = adev->pio_mode - XFER_PIO_0;
|
||||||
|
|
||||||
const u8 actrec[] = { 0x00, 0x67, 0x44, 0x33, 0x31 };
|
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)
|
||||||
{
|
{
|
||||||
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
||||||
int speed = adev->dma_mode - XFER_MW_DMA_0;
|
int speed = adev->dma_mode - XFER_MW_DMA_0;
|
||||||
int drive_pci = sis_port_base(adev);
|
int drive_pci = sis_old_port_base(adev);
|
||||||
u16 timing;
|
u16 timing;
|
||||||
|
|
||||||
const u16 mwdma_bits[] = { 0x707, 0x202, 0x202 };
|
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)
|
||||||
{
|
{
|
||||||
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
||||||
int speed = adev->dma_mode - XFER_MW_DMA_0;
|
int speed = adev->dma_mode - XFER_MW_DMA_0;
|
||||||
int drive_pci = sis_port_base(adev);
|
int drive_pci = sis_old_port_base(adev);
|
||||||
u16 timing;
|
u16 timing;
|
||||||
|
|
||||||
const u16 mwdma_bits[] = { 0x707, 0x202, 0x202 };
|
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)
|
||||||
if (adev->dma_mode < XFER_UDMA_0) {
|
if (adev->dma_mode < XFER_UDMA_0) {
|
||||||
/* bits 3-0 hold recovery timing bits 8-10 active timing and
|
/* bits 3-0 hold recovery timing bits 8-10 active timing and
|
||||||
the higer bits are dependant on the device, bit 15 udma */
|
the higer bits are dependant on the device, bit 15 udma */
|
||||||
timing &= ~ 0x870F;
|
timing &= ~0x870F;
|
||||||
timing |= mwdma_bits[speed];
|
timing |= mwdma_bits[speed];
|
||||||
} else {
|
} else {
|
||||||
/* Bit 15 is UDMA on/off, bit 12-14 are cycle time */
|
/* Bit 15 is UDMA on/off, bit 12-14 are cycle time */
|
||||||
speed = adev->dma_mode - XFER_UDMA_0;
|
speed = adev->dma_mode - XFER_UDMA_0;
|
||||||
timing &= ~0x6000;
|
timing &= ~0xF000;
|
||||||
timing |= udma_bits[speed];
|
timing |= udma_bits[speed];
|
||||||
}
|
}
|
||||||
pci_write_config_word(pdev, drive_pci, timing);
|
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)
|
||||||
{
|
{
|
||||||
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
||||||
int speed = adev->dma_mode - XFER_MW_DMA_0;
|
int speed = adev->dma_mode - XFER_MW_DMA_0;
|
||||||
int drive_pci = sis_port_base(adev);
|
int drive_pci = sis_old_port_base(adev);
|
||||||
u16 timing;
|
u8 timing;
|
||||||
|
|
||||||
const u16 udma_bits[] = { 0x8B00, 0x8700, 0x8500, 0x8300, 0x8200, 0x8100};
|
const u8 udma_bits[] = { 0x8B, 0x87, 0x85, 0x83, 0x82, 0x81};
|
||||||
|
|
||||||
pci_read_config_word(pdev, drive_pci, &timing);
|
pci_read_config_byte(pdev, drive_pci + 1, &timing);
|
||||||
|
|
||||||
if (adev->dma_mode < XFER_UDMA_0) {
|
if (adev->dma_mode < XFER_UDMA_0) {
|
||||||
/* NOT SUPPORTED YET: NEED DATA SHEET. DITTO IN OLD DRIVER */
|
/* NOT SUPPORTED YET: NEED DATA SHEET. DITTO IN OLD DRIVER */
|
||||||
} else {
|
} else {
|
||||||
/* Bit 15 is UDMA on/off, bit 12-14 are cycle time */
|
/* Bit 7 is UDMA on/off, bit 0-3 are cycle time */
|
||||||
speed = adev->dma_mode - XFER_UDMA_0;
|
speed = adev->dma_mode - XFER_UDMA_0;
|
||||||
timing &= ~0x0F00;
|
timing &= ~0x8F;
|
||||||
timing |= udma_bits[speed];
|
timing |= udma_bits[speed];
|
||||||
}
|
}
|
||||||
pci_write_config_word(pdev, drive_pci, timing);
|
pci_write_config_byte(pdev, drive_pci + 1, timing);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -440,22 +440,22 @@ static void sis_133_early_set_dmamode (struct ata_port *ap, struct ata_device *a
|
||||||
{
|
{
|
||||||
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
||||||
int speed = adev->dma_mode - XFER_MW_DMA_0;
|
int speed = adev->dma_mode - XFER_MW_DMA_0;
|
||||||
int drive_pci = sis_port_base(adev);
|
int drive_pci = sis_old_port_base(adev);
|
||||||
u16 timing;
|
u8 timing;
|
||||||
|
/* Low 4 bits are timing */
|
||||||
|
static const u8 udma_bits[] = { 0x8F, 0x8A, 0x87, 0x85, 0x83, 0x82, 0x81};
|
||||||
|
|
||||||
static const u16 udma_bits[] = { 0x8F00, 0x8A00, 0x8700, 0x8500, 0x8300, 0x8200, 0x8100};
|
pci_read_config_byte(pdev, drive_pci + 1, &timing);
|
||||||
|
|
||||||
pci_read_config_word(pdev, drive_pci, &timing);
|
|
||||||
|
|
||||||
if (adev->dma_mode < XFER_UDMA_0) {
|
if (adev->dma_mode < XFER_UDMA_0) {
|
||||||
/* NOT SUPPORTED YET: NEED DATA SHEET. DITTO IN OLD DRIVER */
|
/* NOT SUPPORTED YET: NEED DATA SHEET. DITTO IN OLD DRIVER */
|
||||||
} else {
|
} else {
|
||||||
/* Bit 15 is UDMA on/off, bit 12-14 are cycle time */
|
/* Bit 7 is UDMA on/off, bit 0-3 are cycle time */
|
||||||
speed = adev->dma_mode - XFER_UDMA_0;
|
speed = adev->dma_mode - XFER_UDMA_0;
|
||||||
timing &= ~0x0F00;
|
timing &= ~0x8F;
|
||||||
timing |= udma_bits[speed];
|
timing |= udma_bits[speed];
|
||||||
}
|
}
|
||||||
pci_write_config_word(pdev, drive_pci, timing);
|
pci_write_config_byte(pdev, drive_pci + 1, timing);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue