diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2010-01-18 07:17:37 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-01-19 01:24:56 -0800 |
commit | 3c8cc8df5a67a539cd185026e6b6f49b576869ba (patch) | |
tree | a2c042b8768ee08d5f99cd711698a237c6ccdebb /drivers | |
parent | 2b7d03a5cdace237525643d48918e68fe24681ed (diff) | |
download | blackbird-op-linux-3c8cc8df5a67a539cd185026e6b6f49b576869ba.tar.gz blackbird-op-linux-3c8cc8df5a67a539cd185026e6b6f49b576869ba.zip |
alim15x3: fix PIO timings calculations
Just use the standard ide_timing_compute() helper to calculate
PIO timings. This fixes many issues with the open-coded version
like potential recovery timings underclocking or not accounting
for the enhanced cycle time specified by the device.
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')
-rw-r--r-- | drivers/ide/alim15x3.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/drivers/ide/alim15x3.c b/drivers/ide/alim15x3.c index 0abc43f3101e..99c355e87850 100644 --- a/drivers/ide/alim15x3.c +++ b/drivers/ide/alim15x3.c @@ -8,7 +8,7 @@ * Copyright (C) 2002 Alan Cox * ALi (now ULi M5228) support by Clear Zhang <Clear.Zhang@ali.com.tw> * Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com> - * Copyright (C) 2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> + * Copyright (C) 2007-2010 Bartlomiej Zolnierkiewicz * * (U)DMA capable version of ali 1533/1543(C), 1535(D) * @@ -60,28 +60,22 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio) { ide_hwif_t *hwif = drive->hwif; struct pci_dev *dev = to_pci_dev(hwif->dev); - struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio); - int s_time = t->setup, a_time = t->active, c_time = t->cycle; - u8 s_clc, a_clc, r_clc; unsigned long flags; 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; + struct ide_timing t; - if ((s_clc = (s_time * bus_speed + 999) / 1000) >= 8) - s_clc = 0; - if ((a_clc = (a_time * bus_speed + 999) / 1000) >= 8) - a_clc = 0; + ide_timing_compute(drive, XFER_PIO_0 + pio, &t, T, 1); + + t.setup = clamp_val(t.setup, 1, 8) & 7; + t.active = clamp_val(t.active, 1, 8) & 7; + t.recover = clamp_val(t.recover, 1, 16) & 15; - if (!(r_clc = (c_time * bus_speed + 999) / 1000 - a_clc - s_clc)) { - r_clc = 1; - } else { - if (r_clc >= 16) - r_clc = 0; - } local_irq_save(flags); - + /* * PIO mode => ATA FIFO on, ATAPI FIFO off */ @@ -99,9 +93,11 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio) pci_write_config_byte(dev, portFIFO, cd_dma_fifo & 0xF0); } } - - pci_write_config_byte(dev, port, s_clc); - pci_write_config_byte(dev, port + unit + 2, (a_clc << 4) | r_clc); + + pci_write_config_byte(dev, port, t.setup); + pci_write_config_byte(dev, port + unit + 2, + (t.active << 4) | t.recover); + local_irq_restore(flags); } @@ -584,6 +580,6 @@ static void __exit ali15x3_ide_exit(void) module_init(ali15x3_ide_init); module_exit(ali15x3_ide_exit); -MODULE_AUTHOR("Michael Aubry, Andrzej Krzysztofowicz, CJ, Andre Hedrick, Alan Cox"); +MODULE_AUTHOR("Michael Aubry, Andrzej Krzysztofowicz, CJ, Andre Hedrick, Alan Cox, Bartlomiej Zolnierkiewicz"); MODULE_DESCRIPTION("PCI driver module for ALi 15x3 IDE"); MODULE_LICENSE("GPL"); |