aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci/piix.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/pci/piix.c')
-rw-r--r--drivers/ide/pci/piix.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c
index 5cfa9378bbb8..fd8214a7ab98 100644
--- a/drivers/ide/pci/piix.c
+++ b/drivers/ide/pci/piix.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/piix.c Version 0.51 Jul 6, 2007 2 * linux/drivers/ide/pci/piix.c Version 0.52 Jul 14, 2007
3 * 3 *
4 * Copyright (C) 1998-1999 Andrzej Krzysztofowicz, Author and Maintainer 4 * Copyright (C) 1998-1999 Andrzej Krzysztofowicz, Author and Maintainer
5 * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> 5 * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org>
@@ -17,11 +17,11 @@
17 * 41 17 * 41
18 * 43 18 * 43
19 * 19 *
20 * | PIO 0 | c0 | 80 | 0 | piix_tune_drive(drive, 0); 20 * | PIO 0 | c0 | 80 | 0 |
21 * | PIO 2 | SW2 | d0 | 90 | 4 | piix_tune_drive(drive, 2); 21 * | PIO 2 | SW2 | d0 | 90 | 4 |
22 * | PIO 3 | MW1 | e1 | a1 | 9 | piix_tune_drive(drive, 3); 22 * | PIO 3 | MW1 | e1 | a1 | 9 |
23 * | PIO 4 | MW2 | e3 | a3 | b | piix_tune_drive(drive, 4); 23 * | PIO 4 | MW2 | e3 | a3 | b |
24 * 24 *
25 * sitre = word40 & 0x4000; primary 25 * sitre = word40 & 0x4000; primary
26 * sitre = word42 & 0x4000; secondary 26 * sitre = word42 & 0x4000; secondary
27 * 27 *
@@ -204,16 +204,16 @@ static void piix_tune_pio (ide_drive_t *drive, u8 pio)
204} 204}
205 205
206/** 206/**
207 * piix_tune_drive - tune a drive attached to PIIX 207 * piix_set_pio_mode - set PIO mode
208 * @drive: drive to tune 208 * @drive: drive to tune
209 * @pio: desired PIO mode 209 * @pio: desired PIO mode
210 * 210 *
211 * Set the drive's PIO mode (might be useful if drive is not registered 211 * Set the drive's PIO mode (might be useful if drive is not registered
212 * in CMOS for any reason). 212 * in CMOS for any reason).
213 */ 213 */
214static void piix_tune_drive (ide_drive_t *drive, u8 pio) 214
215static void piix_set_pio_mode(ide_drive_t *drive, const u8 pio)
215{ 216{
216 pio = ide_get_best_pio_mode(drive, pio, 4);
217 piix_tune_pio(drive, pio); 217 piix_tune_pio(drive, pio);
218 (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio); 218 (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio);
219} 219}
@@ -221,19 +221,18 @@ static void piix_tune_drive (ide_drive_t *drive, u8 pio)
221/** 221/**
222 * piix_tune_chipset - tune a PIIX interface 222 * piix_tune_chipset - tune a PIIX interface
223 * @drive: IDE drive to tune 223 * @drive: IDE drive to tune
224 * @xferspeed: speed to configure 224 * @speed: speed to configure
225 * 225 *
226 * Set a PIIX interface channel to the desired speeds. This involves 226 * Set a PIIX interface channel to the desired speeds. This involves
227 * requires the right timing data into the PIIX configuration space 227 * requires the right timing data into the PIIX configuration space
228 * then setting the drive parameters appropriately 228 * then setting the drive parameters appropriately
229 */ 229 */
230 230
231static int piix_tune_chipset (ide_drive_t *drive, u8 xferspeed) 231static int piix_tune_chipset(ide_drive_t *drive, const u8 speed)
232{ 232{
233 ide_hwif_t *hwif = HWIF(drive); 233 ide_hwif_t *hwif = HWIF(drive);
234 struct pci_dev *dev = hwif->pci_dev; 234 struct pci_dev *dev = hwif->pci_dev;
235 u8 maslave = hwif->channel ? 0x42 : 0x40; 235 u8 maslave = hwif->channel ? 0x42 : 0x40;
236 u8 speed = ide_rate_filter(drive, xferspeed);
237 int a_speed = 3 << (drive->dn * 4); 236 int a_speed = 3 << (drive->dn * 4);
238 int u_flag = 1 << drive->dn; 237 int u_flag = 1 << drive->dn;
239 int v_flag = 0x01 << drive->dn; 238 int v_flag = 0x01 << drive->dn;
@@ -260,11 +259,6 @@ static int piix_tune_chipset (ide_drive_t *drive, u8 xferspeed)
260 case XFER_MW_DMA_2: 259 case XFER_MW_DMA_2:
261 case XFER_MW_DMA_1: 260 case XFER_MW_DMA_1:
262 case XFER_SW_DMA_2: break; 261 case XFER_SW_DMA_2: break;
263 case XFER_PIO_4:
264 case XFER_PIO_3:
265 case XFER_PIO_2:
266 case XFER_PIO_1:
267 case XFER_PIO_0: break;
268 default: return -1; 262 default: return -1;
269 } 263 }
270 264
@@ -294,10 +288,7 @@ static int piix_tune_chipset (ide_drive_t *drive, u8 xferspeed)
294 pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag); 288 pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag);
295 } 289 }
296 290
297 if (speed > XFER_PIO_4) 291 piix_tune_pio(drive, piix_dma_2_pio(speed));
298 piix_tune_pio(drive, piix_dma_2_pio(speed));
299 else
300 piix_tune_pio(drive, speed - XFER_PIO_0);
301 292
302 return ide_config_drive_speed(drive, speed); 293 return ide_config_drive_speed(drive, speed);
303} 294}
@@ -318,7 +309,7 @@ static int piix_config_drive_xfer_rate (ide_drive_t *drive)
318 return 0; 309 return 0;
319 310
320 if (ide_use_fast_pio(drive)) 311 if (ide_use_fast_pio(drive))
321 piix_tune_drive(drive, 255); 312 ide_set_max_pio(drive);
322 313
323 return -1; 314 return -1;
324} 315}
@@ -455,7 +446,8 @@ static void __devinit init_hwif_piix(ide_hwif_t *hwif)
455 } 446 }
456 447
457 hwif->autodma = 0; 448 hwif->autodma = 0;
458 hwif->tuneproc = &piix_tune_drive; 449
450 hwif->set_pio_mode = &piix_set_pio_mode;
459 hwif->speedproc = &piix_tune_chipset; 451 hwif->speedproc = &piix_tune_chipset;
460 hwif->drives[0].autotune = 1; 452 hwif->drives[0].autotune = 1;
461 hwif->drives[1].autotune = 1; 453 hwif->drives[1].autotune = 1;