Merge master.kernel.org:/pub/scm/linux/kernel/git/wim/linux-2.6-watchdog
[pandora-kernel.git] / drivers / ata / pata_sis.c
index 91e85f9..560103d 100644 (file)
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
 #include <linux/ata.h>
+#include "libata.h"
 
+#undef DRV_NAME                /* already defined in libata.h, for libata-core */
 #define DRV_NAME       "pata_sis"
-#define DRV_VERSION    "0.4.4"
+#define DRV_VERSION    "0.4.5"
 
 struct sis_chipset {
        u16 device;                     /* PCI host ID */
@@ -43,6 +45,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 +109,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;
@@ -127,7 +157,7 @@ static int sis_66_pre_reset(struct ata_port *ap)
        /* 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;
@@ -538,7 +568,6 @@ static struct scsi_host_template sis_sht = {
        .can_queue              = ATA_DEF_QUEUE,
        .this_id                = ATA_SHT_THIS_ID,
        .sg_tablesize           = LIBATA_MAX_PRD,
-       .max_sectors            = ATA_MAX_SECTORS,
        .cmd_per_lun            = ATA_SHT_CMD_PER_LUN,
        .emulated               = ATA_SHT_EMULATED,
        .use_clustering         = ATA_SHT_USE_CLUSTERING,
@@ -547,6 +576,8 @@ 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,
+       .resume                 = ata_scsi_device_resume,
+       .suspend                = ata_scsi_device_suspend,
 };
 
 static const struct ata_port_operations sis_133_ops = {
@@ -572,14 +603,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 = {
@@ -605,14 +636,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 = {
@@ -639,14 +670,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 = {
@@ -672,14 +703,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 = {
@@ -705,14 +736,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 = {
@@ -752,7 +783,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 */
@@ -767,6 +798,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)
 {
@@ -846,7 +879,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        struct sis_chipset *chipset = NULL;
 
        static struct sis_chipset sis_chipsets[] = {
-       
+
                { 0x0968, &sis_info133 },
                { 0x0966, &sis_info133 },
                { 0x0965, &sis_info133 },
@@ -1000,6 +1033,8 @@ static struct pci_driver sis_pci_driver = {
        .id_table               = sis_pci_tbl,
        .probe                  = sis_init_one,
        .remove                 = ata_pci_remove_one,
+       .suspend                = ata_pci_device_suspend,
+       .resume                 = ata_pci_device_resume,
 };
 
 static int __init sis_init(void)