aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/cs5536.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/cs5536.c')
-rw-r--r--drivers/ide/cs5536.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/drivers/ide/cs5536.c b/drivers/ide/cs5536.c
index 0332a95eefd4..9623b852c616 100644
--- a/drivers/ide/cs5536.c
+++ b/drivers/ide/cs5536.c
@@ -146,14 +146,16 @@ static void cs5536_set_pio_mode(ide_drive_t *drive, const u8 pio)
146 struct pci_dev *pdev = to_pci_dev(drive->hwif->dev); 146 struct pci_dev *pdev = to_pci_dev(drive->hwif->dev);
147 ide_drive_t *pair = ide_get_pair_dev(drive); 147 ide_drive_t *pair = ide_get_pair_dev(drive);
148 int cshift = (drive->dn & 1) ? IDE_CAST_D1_SHIFT : IDE_CAST_D0_SHIFT; 148 int cshift = (drive->dn & 1) ? IDE_CAST_D1_SHIFT : IDE_CAST_D0_SHIFT;
149 unsigned long timings = (unsigned long)ide_get_drivedata(drive);
149 u32 cast; 150 u32 cast;
150 u8 cmd_pio = pio; 151 u8 cmd_pio = pio;
151 152
152 if (pair) 153 if (pair)
153 cmd_pio = min(pio, ide_get_best_pio_mode(pair, 255, 4)); 154 cmd_pio = min(pio, ide_get_best_pio_mode(pair, 255, 4));
154 155
155 drive->drive_data &= (IDE_DRV_MASK << 8); 156 timings &= (IDE_DRV_MASK << 8);
156 drive->drive_data |= drv_timings[pio]; 157 timings |= drv_timings[pio];
158 ide_set_drivedata(drive, (void *)timings);
157 159
158 cs5536_program_dtc(drive, drv_timings[pio]); 160 cs5536_program_dtc(drive, drv_timings[pio]);
159 161
@@ -186,6 +188,7 @@ static void cs5536_set_dma_mode(ide_drive_t *drive, const u8 mode)
186 188
187 struct pci_dev *pdev = to_pci_dev(drive->hwif->dev); 189 struct pci_dev *pdev = to_pci_dev(drive->hwif->dev);
188 int dshift = (drive->dn & 1) ? IDE_D1_SHIFT : IDE_D0_SHIFT; 190 int dshift = (drive->dn & 1) ? IDE_D1_SHIFT : IDE_D0_SHIFT;
191 unsigned long timings = (unsigned long)ide_get_drivedata(drive);
189 u32 etc; 192 u32 etc;
190 193
191 cs5536_read(pdev, ETC, &etc); 194 cs5536_read(pdev, ETC, &etc);
@@ -195,8 +198,9 @@ static void cs5536_set_dma_mode(ide_drive_t *drive, const u8 mode)
195 etc |= udma_timings[mode - XFER_UDMA_0] << dshift; 198 etc |= udma_timings[mode - XFER_UDMA_0] << dshift;
196 } else { /* MWDMA */ 199 } else { /* MWDMA */
197 etc &= ~(IDE_ETC_UDMA_MASK << dshift); 200 etc &= ~(IDE_ETC_UDMA_MASK << dshift);
198 drive->drive_data &= IDE_DRV_MASK; 201 timings &= IDE_DRV_MASK;
199 drive->drive_data |= mwdma_timings[mode - XFER_MW_DMA_0] << 8; 202 timings |= mwdma_timings[mode - XFER_MW_DMA_0] << 8;
203 ide_set_drivedata(drive, (void *)timings);
200 } 204 }
201 205
202 cs5536_write(pdev, ETC, etc); 206 cs5536_write(pdev, ETC, etc);
@@ -204,9 +208,11 @@ static void cs5536_set_dma_mode(ide_drive_t *drive, const u8 mode)
204 208
205static void cs5536_dma_start(ide_drive_t *drive) 209static void cs5536_dma_start(ide_drive_t *drive)
206{ 210{
211 unsigned long timings = (unsigned long)ide_get_drivedata(drive);
212
207 if (drive->current_speed < XFER_UDMA_0 && 213 if (drive->current_speed < XFER_UDMA_0 &&
208 (drive->drive_data >> 8) != (drive->drive_data & IDE_DRV_MASK)) 214 (timings >> 8) != (timings & IDE_DRV_MASK))
209 cs5536_program_dtc(drive, drive->drive_data >> 8); 215 cs5536_program_dtc(drive, timings >> 8);
210 216
211 ide_dma_start(drive); 217 ide_dma_start(drive);
212} 218}
@@ -214,10 +220,11 @@ static void cs5536_dma_start(ide_drive_t *drive)
214static int cs5536_dma_end(ide_drive_t *drive) 220static int cs5536_dma_end(ide_drive_t *drive)
215{ 221{
216 int ret = ide_dma_end(drive); 222 int ret = ide_dma_end(drive);
223 unsigned long timings = (unsigned long)ide_get_drivedata(drive);
217 224
218 if (drive->current_speed < XFER_UDMA_0 && 225 if (drive->current_speed < XFER_UDMA_0 &&
219 (drive->drive_data >> 8) != (drive->drive_data & IDE_DRV_MASK)) 226 (timings >> 8) != (timings & IDE_DRV_MASK))
220 cs5536_program_dtc(drive, drive->drive_data & IDE_DRV_MASK); 227 cs5536_program_dtc(drive, timings & IDE_DRV_MASK);
221 228
222 return ret; 229 return ret;
223} 230}