Merge branch 'for-linus' of master.kernel.org:/pub/scm/linux/kernel/git/cooloney...
[pandora-kernel.git] / drivers / ata / pata_sis.c
index cfe4ec6..2bd7645 100644 (file)
@@ -2,6 +2,7 @@
  *    pata_sis.c - SiS ATA driver
  *
  *     (C) 2005 Red Hat <alan@redhat.com>
+ *     (C) 2007 Bartlomiej Zolnierkiewicz
  *
  *    Based upon linux/drivers/ide/pci/sis5513.c
  * Copyright (C) 1999-2000     Andre Hedrick <andre@linux-ide.org>
@@ -35,7 +36,7 @@
 #include "sis.h"
 
 #define DRV_NAME       "pata_sis"
-#define DRV_VERSION    "0.5.1"
+#define DRV_VERSION    "0.5.2"
 
 struct sis_chipset {
        u16 device;                             /* PCI host ID */
@@ -53,6 +54,7 @@ struct sis_laptop {
 static const struct sis_laptop sis_laptop[] = {
        /* devid, subvendor, subdev */
        { 0x5513, 0x1043, 0x1107 },     /* ASUS A6K */
+       { 0x5513, 0x1734, 0x105F },     /* FSC Amilo A1630 */
        /* end marker */
        { 0, }
 };
@@ -149,6 +151,9 @@ static int sis_pre_reset(struct ata_port *ap, unsigned long deadline)
        if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no]))
                return -ENOENT;
 
+       /* Clear the FIFO settings. We can't enable the FIFO until
+          we know we are poking at a disk */
+       pci_write_config_byte(pdev, 0x4B, 0);
        return ata_std_prereset(ap, deadline);
 }
 
@@ -234,7 +239,7 @@ static void sis_old_set_piomode (struct ata_port *ap, struct ata_device *adev)
 }
 
 /**
- *     sis_100_set_pioode - Initialize host controller PATA PIO timings
+ *     sis_100_set_piomode - Initialize host controller PATA PIO timings
  *     @ap: Port whose timings we are configuring
  *     @adev: Device we are configuring for.
  *
@@ -259,7 +264,7 @@ static void sis_100_set_piomode (struct ata_port *ap, struct ata_device *adev)
 }
 
 /**
- *     sis_133_set_pioode - Initialize host controller PATA PIO timings
+ *     sis_133_set_piomode - Initialize host controller PATA PIO timings
  *     @ap: Port whose timings we are configuring
  *     @adev: Device we are configuring for.
  *
@@ -331,7 +336,7 @@ static void sis_old_set_dmamode (struct ata_port *ap, struct ata_device *adev)
        int drive_pci = sis_old_port_base(adev);
        u16 timing;
 
-       const u16 mwdma_bits[] = { 0x707, 0x202, 0x202 };
+       const u16 mwdma_bits[] = { 0x008, 0x302, 0x301 };
        const u16 udma_bits[]  = { 0xE000, 0xC000, 0xA000 };
 
        pci_read_config_word(pdev, drive_pci, &timing);
@@ -339,15 +344,15 @@ static void sis_old_set_dmamode (struct ata_port *ap, struct ata_device *adev)
        if (adev->dma_mode < XFER_UDMA_0) {
                /* bits 3-0 hold recovery timing bits 8-10 active timing and
                   the higer bits are dependant on the device */
-               timing &= ~ 0x870F;
+               timing &= ~0x870F;
                timing |= mwdma_bits[speed];
-               pci_write_config_word(pdev, drive_pci, timing);
        } else {
                /* Bit 15 is UDMA on/off, bit 13-14 are cycle time */
                speed = adev->dma_mode - XFER_UDMA_0;
                timing &= ~0x6000;
                timing |= udma_bits[speed];
        }
+       pci_write_config_word(pdev, drive_pci, timing);
 }
 
 /**
@@ -370,7 +375,7 @@ static void sis_66_set_dmamode (struct ata_port *ap, struct ata_device *adev)
        int drive_pci = sis_old_port_base(adev);
        u16 timing;
 
-       const u16 mwdma_bits[] = { 0x707, 0x202, 0x202 };
+       const u16 mwdma_bits[] = { 0x008, 0x302, 0x301 };
        const u16 udma_bits[]  = { 0xF000, 0xD000, 0xB000, 0xA000, 0x9000};
 
        pci_read_config_word(pdev, drive_pci, &timing);
@@ -429,8 +434,7 @@ static void sis_100_set_dmamode (struct ata_port *ap, struct ata_device *adev)
  *     @adev: Device to program
  *
  *     Set UDMA/MWDMA mode for device, in host controller PCI config space.
- *     Handles early SiS 961 bridges. Supports MWDMA as well unlike
- *     the old ide/pci driver.
+ *     Handles early SiS 961 bridges.
  *
  *     LOCKING:
  *     None (inherited from caller).
@@ -464,8 +468,6 @@ static void sis_133_early_set_dmamode (struct ata_port *ap, struct ata_device *a
  *     @adev: Device to program
  *
  *     Set UDMA/MWDMA mode for device, in host controller PCI config space.
- *     Handles early SiS 961 bridges. Supports MWDMA as well unlike
- *     the old ide/pci driver.
  *
  *     LOCKING:
  *     None (inherited from caller).
@@ -732,7 +734,7 @@ static const struct ata_port_operations sis_old_ops = {
 
 static const struct ata_port_info sis_info = {
        .sht            = &sis_sht,
-       .flags          = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
+       .flags          = ATA_FLAG_SLAVE_POSS,
        .pio_mask       = 0x1f, /* pio0-4 */
        .mwdma_mask     = 0x07,
        .udma_mask      = 0,
@@ -740,7 +742,7 @@ static const struct ata_port_info sis_info = {
 };
 static const struct ata_port_info sis_info33 = {
        .sht            = &sis_sht,
-       .flags          = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
+       .flags          = ATA_FLAG_SLAVE_POSS,
        .pio_mask       = 0x1f, /* pio0-4 */
        .mwdma_mask     = 0x07,
        .udma_mask      = ATA_UDMA2,    /* UDMA 33 */
@@ -748,28 +750,28 @@ static const struct ata_port_info sis_info33 = {
 };
 static const struct ata_port_info sis_info66 = {
        .sht            = &sis_sht,
-       .flags          = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
+       .flags          = ATA_FLAG_SLAVE_POSS,
        .pio_mask       = 0x1f, /* pio0-4 */
        .udma_mask      = ATA_UDMA4,    /* UDMA 66 */
        .port_ops       = &sis_66_ops,
 };
 static const struct ata_port_info sis_info100 = {
        .sht            = &sis_sht,
-       .flags          = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
+       .flags          = ATA_FLAG_SLAVE_POSS,
        .pio_mask       = 0x1f, /* pio0-4 */
        .udma_mask      = ATA_UDMA5,
        .port_ops       = &sis_100_ops,
 };
 static const struct ata_port_info sis_info100_early = {
        .sht            = &sis_sht,
-       .flags          = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
+       .flags          = ATA_FLAG_SLAVE_POSS,
        .udma_mask      = ATA_UDMA5,
        .pio_mask       = 0x1f, /* pio0-4 */
        .port_ops       = &sis_66_ops,
 };
 static const struct ata_port_info sis_info133 = {
        .sht            = &sis_sht,
-       .flags          = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
+       .flags          = ATA_FLAG_SLAVE_POSS,
        .pio_mask       = 0x1f, /* pio0-4 */
        .udma_mask      = ATA_UDMA6,
        .port_ops       = &sis_133_ops,
@@ -783,7 +785,7 @@ const struct ata_port_info sis_info133_for_sata = {
 };
 static const struct ata_port_info sis_info133_early = {
        .sht            = &sis_sht,
-       .flags          = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
+       .flags          = ATA_FLAG_SLAVE_POSS,
        .pio_mask       = 0x1f, /* pio0-4 */
        .udma_mask      = ATA_UDMA6,
        .port_ops       = &sis_133_early_ops,
@@ -928,9 +930,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
                if (host != NULL) {
                        chipset = sets;                 /* Match found */
                        if (sets->device == 0x630) {    /* SIS630 */
-                               u8 host_rev;
-                               pci_read_config_byte(host, PCI_REVISION_ID, &host_rev);
-                               if (host_rev >= 0x30)   /* 630 ET */
+                               if (host->revision >= 0x30)     /* 630 ET */
                                        chipset = &sis100_early;
                        }
                        break;
@@ -974,7 +974,6 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
                u16 trueid;
                u8 prefctl;
                u8 idecfg;
-               u8 sbrev;
 
                /* Try the second unmasking technique */
                pci_read_config_byte(pdev, 0x4a, &idecfg);
@@ -987,11 +986,10 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
                        lpc_bridge = pci_get_slot(pdev->bus, 0x10); /* Bus 0 Dev 2 Fn 0 */
                        if (lpc_bridge == NULL)
                                break;
-                       pci_read_config_byte(lpc_bridge, PCI_REVISION_ID, &sbrev);
                        pci_read_config_byte(pdev, 0x49, &prefctl);
                        pci_dev_put(lpc_bridge);
 
-                       if (sbrev == 0x10 && (prefctl & 0x80)) {
+                       if (lpc_bridge->revision == 0x10 && (prefctl & 0x80)) {
                                chipset = &sis133_early;
                                break;
                        }