pata_cmd64x: cmd648_bmdma_stop() fix
[safe/jmp/linux-2.6] / drivers / ata / pata_cmd64x.c
index 58c09e2..7bc00d5 100644 (file)
@@ -2,6 +2,7 @@
  * pata_cmd64x.c       - CMD64x PATA for new ATA layer
  *                       (C) 2005 Red Hat Inc
  *                       Alan Cox <alan@lxorguk.ukuu.org.uk>
+ *                       (C) 2009-2010 Bartlomiej Zolnierkiewicz
  *
  * Based upon
  * linux/drivers/ide/pci/cmd64x.c              Version 1.30    Sept 10, 2002
@@ -39,7 +40,7 @@
 
 enum {
        CFR             = 0x50,
-               CFR_INTR_CH0  = 0x02,
+               CFR_INTR_CH0  = 0x04,
        CNTRL           = 0x51,
                CNTRL_DIS_RA0 = 0x40,
                CNTRL_DIS_RA1 = 0x80,
@@ -130,8 +131,14 @@ static void cmd64x_set_timing(struct ata_port *ap, struct ata_device *adev, u8 m
 
                if (pair) {
                        struct ata_timing tp;
+
                        ata_timing_compute(pair, pair->pio_mode, &tp, T, 0);
                        ata_timing_merge(&t, &tp, &t, ATA_TIMING_SETUP);
+                       if (pair->dma_mode) {
+                               ata_timing_compute(pair, pair->dma_mode,
+                                               &tp, T, 0);
+                               ata_timing_merge(&tp, &t, &t, ATA_TIMING_SETUP);
+                       }
                }
        }
 
@@ -147,7 +154,9 @@ static void cmd64x_set_timing(struct ata_port *ap, struct ata_device *adev, u8 m
        /* Now convert the clocks into values we can actually stuff into
           the chip */
 
-       if (t.recover > 1)
+       if (t.recover == 16)
+               t.recover = 0;
+       else if (t.recover > 1)
                t.recover--;
        else
                t.recover = 15;
@@ -219,7 +228,7 @@ static void cmd64x_set_dmamode(struct ata_port *ap, struct ata_device *adev)
                regU |= udma_data[adev->dma_mode - XFER_UDMA_0] << shift;
                /* Merge the control bits */
                regU |= 1 << adev->devno; /* UDMA on */
-               if (adev->dma_mode > 2) /* 15nS timing */
+               if (adev->dma_mode > XFER_UDMA_2) /* 15nS timing */
                        regU |= 4 << adev->devno;
        } else {
                regU &= ~ (1 << adev->devno);   /* UDMA off */