Pull asus into release branch
[pandora-kernel.git] / drivers / ata / pata_sis.c
index 916cedb..8dc3bc4 100644 (file)
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
 #include <linux/ata.h>
+#include "sis.h"
 
 #define DRV_NAME       "pata_sis"
-#define DRV_VERSION    "0.4.5"
+#define DRV_VERSION    "0.5.0"
 
 struct sis_chipset {
        u16 device;                     /* PCI host ID */
@@ -43,6 +44,34 @@ struct sis_chipset {
           up code later */
 };
 
+struct sis_laptop {
+       u16 device;
+       u16 subvendor;
+       u16 subdevice;
+};
+
+static const struct sis_laptop sis_laptop[] = {
+       /* devid, subvendor, subdev */
+       { 0x5513, 0x1043, 0x1107 },     /* ASUS A6K */
+       /* end marker */
+       { 0, }
+};
+
+static int sis_short_ata40(struct pci_dev *dev)
+{
+       const struct sis_laptop *lap = &sis_laptop[0];
+
+       while (lap->device) {
+               if (lap->device == dev->device &&
+                   lap->subvendor == dev->subsystem_vendor &&
+                   lap->subdevice == dev->subsystem_device)
+                       return 1;
+               lap++;
+       }
+
+       return 0;
+}
+
 /**
  *     sis_port_base           -       return PCI configuration base for dev
  *     @adev: device
@@ -79,7 +108,7 @@ static int sis_133_pre_reset(struct ata_port *ap)
 
        /* The top bit of this register is the cable detect bit */
        pci_read_config_word(pdev, 0x50 + 2 * ap->port_no, &tmp);
-       if (tmp & 0x8000)
+       if ((tmp & 0x8000) && !sis_short_ata40(pdev))
                ap->cbl = ATA_CBL_PATA40;
        else
                ap->cbl = ATA_CBL_PATA80;
@@ -121,13 +150,13 @@ static int sis_66_pre_reset(struct ata_port *ap)
 
        if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no])) {
                ata_port_disable(ap);
-               printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
+               ata_port_printk(ap, KERN_INFO, "port disabled. ignoring.\n");
                return 0;
        }
        /* Older chips keep cable detect in bits 4/5 of reg 0x48 */
        pci_read_config_byte(pdev, 0x48, &tmp);
        tmp >>= ap->port_no;
-       if (tmp & 0x10)
+       if ((tmp & 0x10) && !sis_short_ata40(pdev))
                ap->cbl = ATA_CBL_PATA40;
        else
                ap->cbl = ATA_CBL_PATA80;
@@ -167,7 +196,7 @@ static int sis_old_pre_reset(struct ata_port *ap)
 
        if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no])) {
                ata_port_disable(ap);
-               printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
+               ata_port_printk(ap, KERN_INFO, "port disabled. ignoring.\n");
                return 0;
        }
        ap->cbl = ATA_CBL_PATA40;
@@ -546,8 +575,10 @@ static struct scsi_host_template sis_sht = {
        .slave_configure        = ata_scsi_slave_config,
        .slave_destroy          = ata_scsi_slave_destroy,
        .bios_param             = ata_std_bios_param,
+#ifdef CONFIG_PM
        .resume                 = ata_scsi_device_resume,
        .suspend                = ata_scsi_device_suspend,
+#endif
 };
 
 static const struct ata_port_operations sis_133_ops = {
@@ -573,14 +604,14 @@ static const struct ata_port_operations sis_133_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 static const struct ata_port_operations sis_133_early_ops = {
@@ -606,14 +637,14 @@ static const struct ata_port_operations sis_133_early_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 static const struct ata_port_operations sis_100_ops = {
@@ -640,14 +671,14 @@ static const struct ata_port_operations sis_100_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 static const struct ata_port_operations sis_66_ops = {
@@ -673,14 +704,14 @@ static const struct ata_port_operations sis_66_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 static const struct ata_port_operations sis_old_ops = {
@@ -706,14 +737,14 @@ static const struct ata_port_operations sis_old_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 static struct ata_port_info sis_info = {
@@ -753,7 +784,7 @@ static struct ata_port_info sis_info100_early = {
        .pio_mask       = 0x1f, /* pio0-4 */
        .port_ops       = &sis_66_ops,
 };
-static struct ata_port_info sis_info133 = {
+struct ata_port_info sis_info133 = {
        .sht            = &sis_sht,
        .flags          = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
        .pio_mask       = 0x1f, /* pio0-4 */
@@ -768,6 +799,8 @@ static struct ata_port_info sis_info133_early = {
        .port_ops       = &sis_133_early_ops,
 };
 
+/* Privately shared with the SiS180 SATA driver, not for use elsewhere */
+EXPORT_SYMBOL_GPL(sis_info133);
 
 static void sis_fixup(struct pci_dev *pdev, struct sis_chipset *sis)
 {
@@ -845,9 +878,10 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        struct ata_port_info *port;
        struct pci_dev *host = NULL;
        struct sis_chipset *chipset = NULL;
+       struct sis_chipset *sets;
 
        static struct sis_chipset sis_chipsets[] = {
-       
+
                { 0x0968, &sis_info133 },
                { 0x0966, &sis_info133 },
                { 0x0965, &sis_info133 },
@@ -899,10 +933,11 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 
        /* We have to find the bridge first */
 
-       for (chipset = &sis_chipsets[0]; chipset->device; chipset++) {
-               host = pci_get_device(PCI_VENDOR_ID_SI, chipset->device, NULL);
+       for (sets = &sis_chipsets[0]; sets->device; sets++) {
+               host = pci_get_device(PCI_VENDOR_ID_SI, sets->device, NULL);
                if (host != NULL) {
-                       if (chipset->device == 0x630) { /* SIS630 */
+                       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 */
@@ -913,7 +948,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        }
 
        /* Look for concealed bridges */
-       if (host == NULL) {
+       if (chipset == NULL) {
                /* Second check */
                u32 idemisc;
                u16 trueid;
@@ -1001,8 +1036,10 @@ static struct pci_driver sis_pci_driver = {
        .id_table               = sis_pci_tbl,
        .probe                  = sis_init_one,
        .remove                 = ata_pci_remove_one,
+#ifdef CONFIG_PM
        .suspend                = ata_pci_device_suspend,
        .resume                 = ata_pci_device_resume,
+#endif
 };
 
 static int __init sis_init(void)