aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci/alim15x3.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-05-09 18:01:08 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-05-09 18:01:08 -0400
commit2d5eaa6dd744a641e75503232a01f52d0768884c (patch)
tree0736bd00ea3bd032d601d0a676c998cb043b877a /drivers/ide/pci/alim15x3.c
parent18137207236285989dfc0ee7f929b954199228f3 (diff)
ide: rework the code for selecting the best DMA transfer mode (v3)
Depends on the "ide: fix UDMA/MWDMA/SWDMA masks" patch. * add ide_hwif_t.udma_filter hook for filtering UDMA mask (use it in alim15x3, hpt366, siimage and serverworks drivers) * add ide_max_dma_mode() for finding best DMA mode for the device (loosely based on some older libata-core.c code) * convert ide_dma_speed() users to use ide_max_dma_mode() * make ide_rate_filter() take "ide_drive_t *drive" as an argument instead of "u8 mode" and teach it to how to use UDMA mask to do filtering * use ide_rate_filter() in hpt366 driver * remove no longer needed ide_dma_speed() and *_ratemask() * unexport eighty_ninty_three() v2: * rename ->filter_udma_mask to ->udma_filter [ Suggested by Sergei Shtylyov <sshtylyov@ru.mvista.com>. ] v3: * updated for scc_pata driver (fixes XFER_UDMA_6 filtering for user-space originated transfer mode change requests when 100MHz clock is used) Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/pci/alim15x3.c')
-rw-r--r--drivers/ide/pci/alim15x3.c76
1 files changed, 17 insertions, 59 deletions
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
index 26c27d946c67..76643b626bdd 100644
--- a/drivers/ide/pci/alim15x3.c
+++ b/drivers/ide/pci/alim15x3.c
@@ -378,74 +378,31 @@ static void ali15x3_tune_drive (ide_drive_t *drive, u8 pio)
378} 378}
379 379
380/** 380/**
381 * ali15x3_can_ultra - check for ultra DMA support 381 * ali_udma_filter - compute UDMA mask
382 * @drive: drive to do the check 382 * @drive: IDE device
383 * 383 *
384 * Check the drive and controller revisions. Return 0 if UDMA is 384 * Return available UDMA modes.
385 * not available, or 1 if UDMA can be used. The actual rules for 385 *
386 * the ALi are 386 * The actual rules for the ALi are:
387 * No UDMA on revisions <= 0x20 387 * No UDMA on revisions <= 0x20
388 * Disk only for revisions < 0xC2 388 * Disk only for revisions < 0xC2
389 * Not WDC drives for revisions < 0xC2 389 * Not WDC drives for revisions < 0xC2
390 * 390 *
391 * FIXME: WDC ifdef needs to die 391 * FIXME: WDC ifdef needs to die
392 */ 392 */
393
394static u8 ali15x3_can_ultra (ide_drive_t *drive)
395{
396#ifndef CONFIG_WDC_ALI15X3
397 struct hd_driveid *id = drive->id;
398#endif /* CONFIG_WDC_ALI15X3 */
399
400 if (m5229_revision <= 0x20) {
401 return 0;
402 } else if ((m5229_revision < 0xC2) &&
403#ifndef CONFIG_WDC_ALI15X3
404 ((chip_is_1543c_e && strstr(id->model, "WDC ")) ||
405 (drive->media!=ide_disk))) {
406#else /* CONFIG_WDC_ALI15X3 */
407 (drive->media!=ide_disk)) {
408#endif /* CONFIG_WDC_ALI15X3 */
409 return 0;
410 } else {
411 return 1;
412 }
413}
414 393
415/** 394static u8 ali_udma_filter(ide_drive_t *drive)
416 * ali15x3_ratemask - generate DMA mode list
417 * @drive: drive to compute against
418 *
419 * Generate a list of the available DMA modes for the drive.
420 * FIXME: this function contains lots of bogus masking we can dump
421 *
422 * Return the highest available mode (UDMA33, UDMA66, UDMA100,..)
423 */
424
425static u8 ali15x3_ratemask (ide_drive_t *drive)
426{ 395{
427 u8 mode = 0, can_ultra = ali15x3_can_ultra(drive); 396 if (m5229_revision > 0x20 && m5229_revision < 0xC2) {
428 397 if (drive->media != ide_disk)
429 if (m5229_revision > 0xC4 && can_ultra) { 398 return 0;
430 mode = 4; 399#ifndef CONFIG_WDC_ALI15X3
431 } else if (m5229_revision == 0xC4 && can_ultra) { 400 if (chip_is_1543c_e && strstr(drive->id->model, "WDC "))
432 mode = 3; 401 return 0;
433 } else if (m5229_revision >= 0xC2 && can_ultra) { 402#endif
434 mode = 2;
435 } else if (can_ultra) {
436 return 1;
437 } else {
438 return 0;
439 } 403 }
440 404
441 /* 405 return drive->hwif->ultra_mask;
442 * If the drive sees no suitable cable then UDMA 33
443 * is the highest permitted mode
444 */
445
446 if (!eighty_ninty_three(drive))
447 mode = min(mode, (u8)1);
448 return mode;
449} 406}
450 407
451/** 408/**
@@ -461,7 +418,7 @@ static int ali15x3_tune_chipset (ide_drive_t *drive, u8 xferspeed)
461{ 418{
462 ide_hwif_t *hwif = HWIF(drive); 419 ide_hwif_t *hwif = HWIF(drive);
463 struct pci_dev *dev = hwif->pci_dev; 420 struct pci_dev *dev = hwif->pci_dev;
464 u8 speed = ide_rate_filter(ali15x3_ratemask(drive), xferspeed); 421 u8 speed = ide_rate_filter(drive, xferspeed);
465 u8 speed1 = speed; 422 u8 speed1 = speed;
466 u8 unit = (drive->select.b.unit & 0x01); 423 u8 unit = (drive->select.b.unit & 0x01);
467 u8 tmpbyte = 0x00; 424 u8 tmpbyte = 0x00;
@@ -511,7 +468,7 @@ static int ali15x3_tune_chipset (ide_drive_t *drive, u8 xferspeed)
511 468
512static int config_chipset_for_dma (ide_drive_t *drive) 469static int config_chipset_for_dma (ide_drive_t *drive)
513{ 470{
514 u8 speed = ide_dma_speed(drive, ali15x3_ratemask(drive)); 471 u8 speed = ide_max_dma_mode(drive);
515 472
516 if (!(speed)) 473 if (!(speed))
517 return 0; 474 return 0;
@@ -771,6 +728,7 @@ static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif)
771 hwif->autodma = 0; 728 hwif->autodma = 0;
772 hwif->tuneproc = &ali15x3_tune_drive; 729 hwif->tuneproc = &ali15x3_tune_drive;
773 hwif->speedproc = &ali15x3_tune_chipset; 730 hwif->speedproc = &ali15x3_tune_chipset;
731 hwif->udma_filter = &ali_udma_filter;
774 732
775 /* don't use LBA48 DMA on ALi devices before rev 0xC5 */ 733 /* don't use LBA48 DMA on ALi devices before rev 0xC5 */
776 hwif->no_lba48_dma = (m5229_revision <= 0xC4) ? 1 : 0; 734 hwif->no_lba48_dma = (m5229_revision <= 0xC4) ? 1 : 0;