diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2010-01-18 07:17:50 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-01-19 01:24:56 -0800 |
commit | 293f18ad720f7c10f9f4b8a87827a1f0989e19ee (patch) | |
tree | 6ffc8c3e755ad8c7d965cbd51caca4949974561f /drivers/ide | |
parent | 3c8cc8df5a67a539cd185026e6b6f49b576869ba (diff) | |
download | blackbird-op-linux-293f18ad720f7c10f9f4b8a87827a1f0989e19ee.tar.gz blackbird-op-linux-293f18ad720f7c10f9f4b8a87827a1f0989e19ee.zip |
alim15x3: add ali_fifo_control() helper
Based on libata pata_ali host driver.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/alim15x3.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/drivers/ide/alim15x3.c b/drivers/ide/alim15x3.c index 99c355e87850..4b47896df9f9 100644 --- a/drivers/ide/alim15x3.c +++ b/drivers/ide/alim15x3.c @@ -48,6 +48,19 @@ static u8 m5229_revision; static u8 chip_is_1543c_e; static struct pci_dev *isa_dev; +static void ali_fifo_control(ide_hwif_t *hwif, ide_drive_t *drive, int on) +{ + struct pci_dev *pdev = to_pci_dev(hwif->dev); + int pio_fifo = 0x54 + hwif->channel; + u8 fifo; + int shift = 4 * (drive->dn & 1); + + pci_read_config_byte(pdev, pio_fifo, &fifo); + fifo &= ~(0x0F << shift); + fifo |= (on << shift); + pci_write_config_byte(pdev, pio_fifo, fifo); +} + /** * ali_set_pio_mode - set host controller for PIO mode * @drive: drive @@ -64,8 +77,7 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio) int bus_speed = ide_pci_clk ? ide_pci_clk : 33; unsigned long T = 1000000 / bus_speed; /* PCI clock based */ int port = hwif->channel ? 0x5c : 0x58; - int portFIFO = hwif->channel ? 0x55 : 0x54; - u8 cd_dma_fifo = 0, unit = drive->dn & 1; + u8 unit = drive->dn & 1; struct ide_timing t; ide_timing_compute(drive, XFER_PIO_0 + pio, &t, T, 1); @@ -79,20 +91,7 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio) /* * PIO mode => ATA FIFO on, ATAPI FIFO off */ - pci_read_config_byte(dev, portFIFO, &cd_dma_fifo); - if (drive->media==ide_disk) { - if (unit) { - pci_write_config_byte(dev, portFIFO, (cd_dma_fifo & 0x0F) | 0x50); - } else { - pci_write_config_byte(dev, portFIFO, (cd_dma_fifo & 0xF0) | 0x05); - } - } else { - if (unit) { - pci_write_config_byte(dev, portFIFO, cd_dma_fifo & 0x0F); - } else { - pci_write_config_byte(dev, portFIFO, cd_dma_fifo & 0xF0); - } - } + ali_fifo_control(hwif, drive, (drive->media == ide_disk) ? 0x05 : 0x00); pci_write_config_byte(dev, port, t.setup); pci_write_config_byte(dev, port + unit + 2, |