aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci/it821x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/pci/it821x.c')
-rw-r--r--drivers/ide/pci/it821x.c90
1 files changed, 29 insertions, 61 deletions
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index 758a98230cc5..1b69d82478c6 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -229,24 +229,24 @@ static void it821x_clock_strategy(ide_drive_t *drive)
229} 229}
230 230
231/** 231/**
232 * it821x_tunepio - tune a drive 232 * it821x_set_pio_mode - set host controller for PIO mode
233 * @drive: drive to tune 233 * @drive: drive
234 * @pio: the desired PIO mode 234 * @pio: PIO mode number
235 * 235 *
236 * Try to tune the drive/host to the desired PIO mode taking into 236 * Tune the host to the desired PIO mode taking into the consideration
237 * the consideration the maximum PIO mode supported by the other 237 * the maximum PIO mode supported by the other device on the cable.
238 * device on the cable.
239 */ 238 */
240 239
241static int it821x_tunepio(ide_drive_t *drive, u8 set_pio) 240static void it821x_set_pio_mode(ide_drive_t *drive, const u8 pio)
242{ 241{
243 ide_hwif_t *hwif = drive->hwif; 242 ide_hwif_t *hwif = drive->hwif;
244 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 243 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
245 int unit = drive->select.b.unit; 244 int unit = drive->select.b.unit;
246 ide_drive_t *pair = &hwif->drives[1 - unit]; 245 ide_drive_t *pair = &hwif->drives[1 - unit];
246 u8 set_pio = pio;
247 247
248 /* Spec says 89 ref driver uses 88 */ 248 /* Spec says 89 ref driver uses 88 */
249 static u16 pio[] = { 0xAA88, 0xA382, 0xA181, 0x3332, 0x3121 }; 249 static u16 pio_timings[]= { 0xAA88, 0xA382, 0xA181, 0x3332, 0x3121 };
250 static u8 pio_want[] = { ATA_66, ATA_66, ATA_66, ATA_66, ATA_ANY }; 250 static u8 pio_want[] = { ATA_66, ATA_66, ATA_66, ATA_66, ATA_ANY };
251 251
252 /* 252 /*
@@ -261,22 +261,12 @@ static int it821x_tunepio(ide_drive_t *drive, u8 set_pio)
261 set_pio = pair_pio; 261 set_pio = pair_pio;
262 } 262 }
263 263
264 if (itdev->smart)
265 return 0;
266
267 /* We prefer 66Mhz clock for PIO 0-3, don't care for PIO4 */ 264 /* We prefer 66Mhz clock for PIO 0-3, don't care for PIO4 */
268 itdev->want[unit][1] = pio_want[set_pio]; 265 itdev->want[unit][1] = pio_want[set_pio];
269 itdev->want[unit][0] = 1; /* PIO is lowest priority */ 266 itdev->want[unit][0] = 1; /* PIO is lowest priority */
270 itdev->pio[unit] = pio[set_pio]; 267 itdev->pio[unit] = pio_timings[set_pio];
271 it821x_clock_strategy(drive); 268 it821x_clock_strategy(drive);
272 it821x_program(drive, itdev->pio[unit]); 269 it821x_program(drive, itdev->pio[unit]);
273
274 return ide_config_drive_speed(drive, XFER_PIO_0 + set_pio);
275}
276
277static void it821x_set_pio_mode(ide_drive_t *drive, const u8 pio)
278{
279 (void)it821x_tunepio(drive, pio);
280} 270}
281 271
282/** 272/**
@@ -405,47 +395,24 @@ static int it821x_dma_end(ide_drive_t *drive)
405} 395}
406 396
407/** 397/**
408 * it821x_tune_chipset - set controller timings 398 * it821x_set_dma_mode - set host controller for DMA mode
409 * @drive: Drive to set up 399 * @drive: drive
410 * @speed: speed we want to achieve 400 * @speed: DMA mode
411 * 401 *
412 * Tune the ITE chipset for the desired mode. 402 * Tune the ITE chipset for the desired DMA mode.
413 */ 403 */
414 404
415static int it821x_tune_chipset(ide_drive_t *drive, const u8 speed) 405static void it821x_set_dma_mode(ide_drive_t *drive, const u8 speed)
416{ 406{
417 407 /*
418 ide_hwif_t *hwif = drive->hwif; 408 * MWDMA tuning is really hard because our MWDMA and PIO
419 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 409 * timings are kept in the same place. We can switch in the
420 410 * host dma on/off callbacks.
421 if (itdev->smart == 0) { 411 */
422 switch (speed) { 412 if (speed >= XFER_UDMA_0 && speed <= XFER_UDMA_6)
423 /* MWDMA tuning is really hard because our MWDMA and PIO 413 it821x_tune_udma(drive, speed - XFER_UDMA_0);
424 timings are kept in the same place. We can switch in the 414 else if (speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2)
425 host dma on/off callbacks */ 415 it821x_tune_mwdma(drive, speed - XFER_MW_DMA_0);
426 case XFER_MW_DMA_2:
427 case XFER_MW_DMA_1:
428 case XFER_MW_DMA_0:
429 it821x_tune_mwdma(drive, (speed - XFER_MW_DMA_0));
430 break;
431 case XFER_UDMA_6:
432 case XFER_UDMA_5:
433 case XFER_UDMA_4:
434 case XFER_UDMA_3:
435 case XFER_UDMA_2:
436 case XFER_UDMA_1:
437 case XFER_UDMA_0:
438 it821x_tune_udma(drive, (speed - XFER_UDMA_0));
439 break;
440 default:
441 return 1;
442 }
443
444 return ide_config_drive_speed(drive, speed);
445 }
446
447 /* don't touch anything in the smart mode */
448 return 0;
449} 416}
450 417
451/** 418/**
@@ -629,14 +596,15 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
629 printk(KERN_WARNING "it821x: Revision 0x10, workarounds activated.\n"); 596 printk(KERN_WARNING "it821x: Revision 0x10, workarounds activated.\n");
630 } 597 }
631 598
632 hwif->speedproc = &it821x_tune_chipset; 599 if (idev->smart == 0) {
633 hwif->set_pio_mode = &it821x_set_pio_mode; 600 hwif->set_pio_mode = &it821x_set_pio_mode;
601 hwif->set_dma_mode = &it821x_set_dma_mode;
634 602
635 /* MWDMA/PIO clock switching for pass through mode */ 603 /* MWDMA/PIO clock switching for pass through mode */
636 if(!idev->smart) {
637 hwif->dma_start = &it821x_dma_start; 604 hwif->dma_start = &it821x_dma_start;
638 hwif->ide_dma_end = &it821x_dma_end; 605 hwif->ide_dma_end = &it821x_dma_end;
639 } 606 } else
607 hwif->host_flags |= IDE_HFLAG_NO_SET_MODE;
640 608
641 hwif->drives[0].autotune = 1; 609 hwif->drives[0].autotune = 1;
642 hwif->drives[1].autotune = 1; 610 hwif->drives[1].autotune = 1;