]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/pci/cs5535.c
Start split out of common open firmware code
[linux-2.6-omap-h63xx.git] / drivers / ide / pci / cs5535.c
index 45f43efbf92c856b4aaabf967cbab9ee87d33c9f..ce44e38390aa9e8bec5232ba1f9304f191dc6c07 100644 (file)
@@ -89,7 +89,7 @@ static void cs5535_set_speed(ide_drive_t *drive, u8 speed)
 
                pioa = speed - XFER_PIO_0;
                piob = ide_get_best_pio_mode(&(drive->hwif->drives[!unit]),
-                                               255, 4, NULL);
+                                               255, 4);
                cmd = pioa < piob ? pioa : piob;
 
                /* Write the speed of the current drive */
@@ -127,20 +127,6 @@ static void cs5535_set_speed(ide_drive_t *drive, u8 speed)
        }
 }
 
-static u8 cs5535_ratemask(ide_drive_t *drive)
-{
-       /* eighty93 will return 1 if it's 80core and capable of
-       exceeding udma2, 0 otherwise. we need ratemask to set
-       the max speed and if we can > udma2 then we return 2
-       which selects speed_max as udma4 which is the 5535's max
-       speed, and 1 selects udma2 which is the max for 40c */
-       if (!eighty_ninty_three(drive))
-               return 1;
-
-       return 2;
-}
-
-
 /****
  *     cs5535_set_drive         -     Configure the drive to the new speed
  *     @drive: Drive to set up
@@ -151,7 +137,7 @@ static u8 cs5535_ratemask(ide_drive_t *drive)
  */
 static int cs5535_set_drive(ide_drive_t *drive, u8 speed)
 {
-       speed = ide_rate_filter(cs5535_ratemask(drive), speed);
+       speed = ide_rate_filter(drive, speed);
        ide_config_drive_speed(drive, speed);
        cs5535_set_speed(drive, speed);
 
@@ -173,37 +159,22 @@ static void cs5535_tuneproc(ide_drive_t *drive, u8 xferspeed)
        /* cs5535 max pio is pio 4, best_pio will check the blacklist.
        i think we don't need to rate_filter the incoming xferspeed
        since we know we're only going to choose pio */
-       xferspeed = ide_get_best_pio_mode(drive, xferspeed, 4, NULL);
+       xferspeed = ide_get_best_pio_mode(drive, xferspeed, 4);
        ide_config_drive_speed(drive, modes[xferspeed]);
        cs5535_set_speed(drive, xferspeed);
 }
 
-static int cs5535_config_drive_for_dma(ide_drive_t *drive)
-{
-       u8 speed;
-
-       speed = ide_dma_speed(drive, cs5535_ratemask(drive));
-
-       /* If no DMA speed was available then let dma_check hit pio */
-       if (!speed) {
-               return 0;
-       }
-
-       cs5535_set_drive(drive, speed);
-       return ide_dma_enable(drive);
-}
-
 static int cs5535_dma_check(ide_drive_t *drive)
 {
        u8 speed;
 
        drive->init_speed = 0;
 
-       if (ide_use_dma(drive) && cs5535_config_drive_for_dma(drive))
+       if (ide_tune_dma(drive))
                return 0;
 
        if (ide_use_fast_pio(drive)) {
-               speed = ide_get_best_pio_mode(drive, 255, 4, NULL);
+               speed = ide_get_best_pio_mode(drive, 255, 4);
                cs5535_set_drive(drive, speed);
        }
 
@@ -216,7 +187,8 @@ static u8 __devinit cs5535_cable_detect(struct pci_dev *dev)
 
        /* if a 80 wire cable was detected */
        pci_read_config_byte(dev, CS5535_CABLE_DETECT, &bit);
-       return (bit & 1);
+
+       return (bit & 1) ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
 }
 
 /****
@@ -241,8 +213,7 @@ static void __devinit init_hwif_cs5535(ide_hwif_t *hwif)
        hwif->ultra_mask = 0x1F;
        hwif->mwdma_mask = 0x07;
 
-
-       hwif->udma_four = cs5535_cable_detect(hwif->pci_dev);
+       hwif->cbl = cs5535_cable_detect(hwif->pci_dev);
 
        if (!noautodma)
                hwif->autodma = 1;
@@ -257,9 +228,10 @@ static void __devinit init_hwif_cs5535(ide_hwif_t *hwif)
 static ide_pci_device_t cs5535_chipset __devinitdata = {
        .name           = "CS5535",
        .init_hwif      = init_hwif_cs5535,
-       .channels       = 1,
        .autodma        = AUTODMA,
        .bootable       = ON_BOARD,
+       .host_flags     = IDE_HFLAG_SINGLE,
+       .pio_mask       = ATA_PIO4,
 };
 
 static int __devinit cs5535_init_one(struct pci_dev *dev,