sata_mv: support clkdev framework
[safe/jmp/linux-2.6] / drivers / ata / pata_sis.c
index f223126..5c30d56 100644 (file)
@@ -1,7 +1,8 @@
 /*
  *    pata_sis.c - SiS ATA driver
  *
- *     (C) 2005 Red Hat <alan@redhat.com>
+ *     (C) 2005 Red Hat
+ *     (C) 2007,2009 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,8 @@ struct sis_laptop {
 static const struct sis_laptop sis_laptop[] = {
        /* devid, subvendor, subdev */
        { 0x5513, 0x1043, 0x1107 },     /* ASUS A6K */
+       { 0x5513, 0x1734, 0x105F },     /* FSC Amilo A1630 */
+       { 0x5513, 0x1071, 0x8640 },     /* EasyNote K5305 */
        /* end marker */
        { 0, }
 };
@@ -73,16 +76,16 @@ static int sis_short_ata40(struct pci_dev *dev)
 }
 
 /**
- *     sis_port_base           -       return PCI configuration base for dev
+ *     sis_old_port_base               -       return PCI configuration base for dev
  *     @adev: device
  *
  *     Returns the base of the PCI configuration registers for this port
  *     number.
  */
 
-static int sis_port_base(struct ata_device *adev)
+static int sis_old_port_base(struct ata_device *adev)
 {
-       return  0x40 + (4 * adev->ap->port_no) +  (2 * adev->devno);
+       return  0x40 + (4 * adev->link->ap->port_no) +  (2 * adev->devno);
 }
 
 /**
@@ -109,7 +112,6 @@ static int sis_133_cable_detect(struct ata_port *ap)
 /**
  *     sis_66_cable_detect     -       check for 40/80 pin
  *     @ap: Port
- *     @deadline: deadline jiffies for the operation
  *
  *     Perform cable detection on the UDMA66, UDMA100 and early UDMA133
  *     SiS IDE controllers.
@@ -131,42 +133,33 @@ static int sis_66_cable_detect(struct ata_port *ap)
 
 /**
  *     sis_pre_reset           -       probe begin
- *     @ap: ATA port
+ *     @link: ATA link
  *     @deadline: deadline jiffies for the operation
  *
  *     Set up cable type and use generic probe init
  */
 
-static int sis_pre_reset(struct ata_port *ap, unsigned long deadline)
+static int sis_pre_reset(struct ata_link *link, unsigned long deadline)
 {
        static const struct pci_bits sis_enable_bits[] = {
                { 0x4aU, 1U, 0x02UL, 0x02UL },  /* port 0 */
                { 0x4aU, 1U, 0x04UL, 0x04UL },  /* port 1 */
        };
 
+       struct ata_port *ap = link->ap;
        struct pci_dev *pdev = to_pci_dev(ap->host->dev);
 
        if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no]))
                return -ENOENT;
 
-       return ata_std_prereset(ap, deadline);
+       /* 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_sff_prereset(link, deadline);
 }
 
 
 /**
- *     sis_error_handler - Probe specified port on PATA host controller
- *     @ap: Port to probe
- *
- *     LOCKING:
- *     None (inherited from caller).
- */
-
-static void sis_error_handler(struct ata_port *ap)
-{
-       ata_bmdma_drive_eh(ap, sis_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
-}
-
-/**
  *     sis_set_fifo    -       Set RWP fifo bits for this device
  *     @ap: Port
  *     @adev: Device
@@ -211,7 +204,7 @@ static void sis_set_fifo(struct ata_port *ap, struct ata_device *adev)
 static void sis_old_set_piomode (struct ata_port *ap, struct ata_device *adev)
 {
        struct pci_dev *pdev    = to_pci_dev(ap->host->dev);
-       int port = sis_port_base(adev);
+       int port = sis_old_port_base(adev);
        u8 t1, t2;
        int speed = adev->pio_mode - XFER_PIO_0;
 
@@ -234,7 +227,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.
  *
@@ -248,7 +241,7 @@ static void sis_old_set_piomode (struct ata_port *ap, struct ata_device *adev)
 static void sis_100_set_piomode (struct ata_port *ap, struct ata_device *adev)
 {
        struct pci_dev *pdev    = to_pci_dev(ap->host->dev);
-       int port = sis_port_base(adev);
+       int port = sis_old_port_base(adev);
        int speed = adev->pio_mode - XFER_PIO_0;
 
        const u8 actrec[] = { 0x00, 0x67, 0x44, 0x33, 0x31 };
@@ -259,7 +252,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.
  *
@@ -328,26 +321,26 @@ static void sis_old_set_dmamode (struct ata_port *ap, struct ata_device *adev)
 {
        struct pci_dev *pdev    = to_pci_dev(ap->host->dev);
        int speed = adev->dma_mode - XFER_MW_DMA_0;
-       int drive_pci = sis_port_base(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);
 
        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;
+                  the higher bits are dependant on the device */
+               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);
 }
 
 /**
@@ -367,23 +360,24 @@ static void sis_66_set_dmamode (struct ata_port *ap, struct ata_device *adev)
 {
        struct pci_dev *pdev    = to_pci_dev(ap->host->dev);
        int speed = adev->dma_mode - XFER_MW_DMA_0;
-       int drive_pci = sis_port_base(adev);
+       int drive_pci = sis_old_port_base(adev);
        u16 timing;
 
-       const u16 mwdma_bits[] = { 0x707, 0x202, 0x202 };
-       const u16 udma_bits[]  = { 0xF000, 0xD000, 0xB000, 0xA000, 0x9000};
+       /* MWDMA 0-2 and UDMA 0-5 */
+       const u16 mwdma_bits[] = { 0x008, 0x302, 0x301 };
+       const u16 udma_bits[]  = { 0xF000, 0xD000, 0xB000, 0xA000, 0x9000, 0x8000 };
 
        pci_read_config_word(pdev, drive_pci, &timing);
 
        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, bit 15 udma */
-               timing &= ~ 0x870F;
+                  the higher bits are dependant on the device, bit 15 udma */
+               timing &= ~0x870F;
                timing |= mwdma_bits[speed];
        } else {
                /* Bit 15 is UDMA on/off, bit 12-14 are cycle time */
                speed = adev->dma_mode - XFER_UDMA_0;
-               timing &= ~0x6000;
+               timing &= ~0xF000;
                timing |= udma_bits[speed];
        }
        pci_write_config_word(pdev, drive_pci, timing);
@@ -405,22 +399,22 @@ static void sis_100_set_dmamode (struct ata_port *ap, struct ata_device *adev)
 {
        struct pci_dev *pdev    = to_pci_dev(ap->host->dev);
        int speed = adev->dma_mode - XFER_MW_DMA_0;
-       int drive_pci = sis_port_base(adev);
-       u16 timing;
+       int drive_pci = sis_old_port_base(adev);
+       u8 timing;
 
-       const u16 udma_bits[]  = { 0x8B00, 0x8700, 0x8500, 0x8300, 0x8200, 0x8100};
+       const u8 udma_bits[]  = { 0x8B, 0x87, 0x85, 0x83, 0x82, 0x81};
 
-       pci_read_config_word(pdev, drive_pci, &timing);
+       pci_read_config_byte(pdev, drive_pci + 1, &timing);
 
        if (adev->dma_mode < XFER_UDMA_0) {
                /* NOT SUPPORTED YET: NEED DATA SHEET. DITTO IN OLD DRIVER */
        } else {
-               /* Bit 15 is UDMA on/off, bit 12-14 are cycle time */
+               /* Bit 7 is UDMA on/off, bit 0-3 are cycle time */
                speed = adev->dma_mode - XFER_UDMA_0;
-               timing &= ~0x0F00;
+               timing &= ~0x8F;
                timing |= udma_bits[speed];
        }
-       pci_write_config_word(pdev, drive_pci, timing);
+       pci_write_config_byte(pdev, drive_pci + 1, timing);
 }
 
 /**
@@ -429,8 +423,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).
@@ -440,22 +433,22 @@ static void sis_133_early_set_dmamode (struct ata_port *ap, struct ata_device *a
 {
        struct pci_dev *pdev    = to_pci_dev(ap->host->dev);
        int speed = adev->dma_mode - XFER_MW_DMA_0;
-       int drive_pci = sis_port_base(adev);
-       u16 timing;
+       int drive_pci = sis_old_port_base(adev);
+       u8 timing;
+       /* Low 4 bits are timing */
+       static const u8 udma_bits[]  = { 0x8F, 0x8A, 0x87, 0x85, 0x83, 0x82, 0x81};
 
-       static const u16 udma_bits[]  = { 0x8F00, 0x8A00, 0x8700, 0x8500, 0x8300, 0x8200, 0x8100};
-
-       pci_read_config_word(pdev, drive_pci, &timing);
+       pci_read_config_byte(pdev, drive_pci + 1, &timing);
 
        if (adev->dma_mode < XFER_UDMA_0) {
                /* NOT SUPPORTED YET: NEED DATA SHEET. DITTO IN OLD DRIVER */
        } else {
-               /* Bit 15 is UDMA on/off, bit 12-14 are cycle time */
+               /* Bit 7 is UDMA on/off, bit 0-3 are cycle time */
                speed = adev->dma_mode - XFER_UDMA_0;
-               timing &= ~0x0F00;
+               timing &= ~0x8F;
                timing |= udma_bits[speed];
        }
-       pci_write_config_word(pdev, drive_pci, timing);
+       pci_write_config_byte(pdev, drive_pci + 1, timing);
 }
 
 /**
@@ -464,8 +457,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).
@@ -509,247 +500,115 @@ static void sis_133_set_dmamode (struct ata_port *ap, struct ata_device *adev)
 }
 
 static struct scsi_host_template sis_sht = {
-       .module                 = THIS_MODULE,
-       .name                   = DRV_NAME,
-       .ioctl                  = ata_scsi_ioctl,
-       .queuecommand           = ata_scsi_queuecmd,
-       .can_queue              = ATA_DEF_QUEUE,
-       .this_id                = ATA_SHT_THIS_ID,
-       .sg_tablesize           = LIBATA_MAX_PRD,
-       .cmd_per_lun            = ATA_SHT_CMD_PER_LUN,
-       .emulated               = ATA_SHT_EMULATED,
-       .use_clustering         = ATA_SHT_USE_CLUSTERING,
-       .proc_name              = DRV_NAME,
-       .dma_boundary           = ATA_DMA_BOUNDARY,
-       .slave_configure        = ata_scsi_slave_config,
-       .slave_destroy          = ata_scsi_slave_destroy,
-       .bios_param             = ata_std_bios_param,
+       ATA_BMDMA_SHT(DRV_NAME),
 };
 
-static const struct ata_port_operations sis_133_ops = {
-       .port_disable           = ata_port_disable,
+static struct ata_port_operations sis_133_for_sata_ops = {
+       .inherits               = &ata_bmdma_port_ops,
        .set_piomode            = sis_133_set_piomode,
        .set_dmamode            = sis_133_set_dmamode,
-       .mode_filter            = ata_pci_default_filter,
-
-       .tf_load                = ata_tf_load,
-       .tf_read                = ata_tf_read,
-       .check_status           = ata_check_status,
-       .exec_command           = ata_exec_command,
-       .dev_select             = ata_std_dev_select,
-
-       .freeze                 = ata_bmdma_freeze,
-       .thaw                   = ata_bmdma_thaw,
-       .error_handler          = sis_error_handler,
-       .post_internal_cmd      = ata_bmdma_post_internal_cmd,
        .cable_detect           = sis_133_cable_detect,
+};
 
-       .bmdma_setup            = ata_bmdma_setup,
-       .bmdma_start            = ata_bmdma_start,
-       .bmdma_stop             = ata_bmdma_stop,
-       .bmdma_status           = ata_bmdma_status,
-       .qc_prep                = ata_qc_prep,
-       .qc_issue               = ata_qc_issue_prot,
-       .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,
+static struct ata_port_operations sis_base_ops = {
+       .inherits               = &ata_bmdma_port_ops,
+       .prereset               = sis_pre_reset,
+};
 
-       .port_start             = ata_port_start,
+static struct ata_port_operations sis_133_ops = {
+       .inherits               = &sis_base_ops,
+       .set_piomode            = sis_133_set_piomode,
+       .set_dmamode            = sis_133_set_dmamode,
+       .cable_detect           = sis_133_cable_detect,
 };
 
-static const struct ata_port_operations sis_133_early_ops = {
-       .port_disable           = ata_port_disable,
+static struct ata_port_operations sis_133_early_ops = {
+       .inherits               = &sis_base_ops,
        .set_piomode            = sis_100_set_piomode,
        .set_dmamode            = sis_133_early_set_dmamode,
-       .mode_filter            = ata_pci_default_filter,
-
-       .tf_load                = ata_tf_load,
-       .tf_read                = ata_tf_read,
-       .check_status           = ata_check_status,
-       .exec_command           = ata_exec_command,
-       .dev_select             = ata_std_dev_select,
-
-       .freeze                 = ata_bmdma_freeze,
-       .thaw                   = ata_bmdma_thaw,
-       .error_handler          = sis_error_handler,
-       .post_internal_cmd      = ata_bmdma_post_internal_cmd,
        .cable_detect           = sis_66_cable_detect,
-
-       .bmdma_setup            = ata_bmdma_setup,
-       .bmdma_start            = ata_bmdma_start,
-       .bmdma_stop             = ata_bmdma_stop,
-       .bmdma_status           = ata_bmdma_status,
-       .qc_prep                = ata_qc_prep,
-       .qc_issue               = ata_qc_issue_prot,
-       .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,
 };
 
-static const struct ata_port_operations sis_100_ops = {
-       .port_disable           = ata_port_disable,
+static struct ata_port_operations sis_100_ops = {
+       .inherits               = &sis_base_ops,
        .set_piomode            = sis_100_set_piomode,
        .set_dmamode            = sis_100_set_dmamode,
-       .mode_filter            = ata_pci_default_filter,
-
-       .tf_load                = ata_tf_load,
-       .tf_read                = ata_tf_read,
-       .check_status           = ata_check_status,
-       .exec_command           = ata_exec_command,
-       .dev_select             = ata_std_dev_select,
-
-       .freeze                 = ata_bmdma_freeze,
-       .thaw                   = ata_bmdma_thaw,
-       .error_handler          = sis_error_handler,
-       .post_internal_cmd      = ata_bmdma_post_internal_cmd,
        .cable_detect           = sis_66_cable_detect,
-
-       .bmdma_setup            = ata_bmdma_setup,
-       .bmdma_start            = ata_bmdma_start,
-       .bmdma_stop             = ata_bmdma_stop,
-       .bmdma_status           = ata_bmdma_status,
-       .qc_prep                = ata_qc_prep,
-       .qc_issue               = ata_qc_issue_prot,
-       .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,
 };
 
-static const struct ata_port_operations sis_66_ops = {
-       .port_disable           = ata_port_disable,
+static struct ata_port_operations sis_66_ops = {
+       .inherits               = &sis_base_ops,
        .set_piomode            = sis_old_set_piomode,
        .set_dmamode            = sis_66_set_dmamode,
-       .mode_filter            = ata_pci_default_filter,
-
-       .tf_load                = ata_tf_load,
-       .tf_read                = ata_tf_read,
-       .check_status           = ata_check_status,
-       .exec_command           = ata_exec_command,
-       .dev_select             = ata_std_dev_select,
        .cable_detect           = sis_66_cable_detect,
-
-       .freeze                 = ata_bmdma_freeze,
-       .thaw                   = ata_bmdma_thaw,
-       .error_handler          = sis_error_handler,
-       .post_internal_cmd      = ata_bmdma_post_internal_cmd,
-
-       .bmdma_setup            = ata_bmdma_setup,
-       .bmdma_start            = ata_bmdma_start,
-       .bmdma_stop             = ata_bmdma_stop,
-       .bmdma_status           = ata_bmdma_status,
-       .qc_prep                = ata_qc_prep,
-       .qc_issue               = ata_qc_issue_prot,
-       .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,
 };
 
-static const struct ata_port_operations sis_old_ops = {
-       .port_disable           = ata_port_disable,
+static struct ata_port_operations sis_old_ops = {
+       .inherits               = &sis_base_ops,
        .set_piomode            = sis_old_set_piomode,
        .set_dmamode            = sis_old_set_dmamode,
-       .mode_filter            = ata_pci_default_filter,
-
-       .tf_load                = ata_tf_load,
-       .tf_read                = ata_tf_read,
-       .check_status           = ata_check_status,
-       .exec_command           = ata_exec_command,
-       .dev_select             = ata_std_dev_select,
-
-       .freeze                 = ata_bmdma_freeze,
-       .thaw                   = ata_bmdma_thaw,
-       .error_handler          = sis_error_handler,
-       .post_internal_cmd      = ata_bmdma_post_internal_cmd,
        .cable_detect           = ata_cable_40wire,
-
-       .bmdma_setup            = ata_bmdma_setup,
-       .bmdma_start            = ata_bmdma_start,
-       .bmdma_stop             = ata_bmdma_stop,
-       .bmdma_status           = ata_bmdma_status,
-       .qc_prep                = ata_qc_prep,
-       .qc_issue               = ata_qc_issue_prot,
-       .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,
 };
 
 static const struct ata_port_info sis_info = {
-       .sht            = &sis_sht,
-       .flags          = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
-       .pio_mask       = 0x1f, /* pio0-4 */
-       .mwdma_mask     = 0x07,
-       .udma_mask      = 0,
+       .flags          = ATA_FLAG_SLAVE_POSS,
+       .pio_mask       = ATA_PIO4,
+       .mwdma_mask     = ATA_MWDMA2,
+       /* No UDMA */
        .port_ops       = &sis_old_ops,
 };
 static const struct ata_port_info sis_info33 = {
-       .sht            = &sis_sht,
-       .flags          = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
-       .pio_mask       = 0x1f, /* pio0-4 */
-       .mwdma_mask     = 0x07,
-       .udma_mask      = ATA_UDMA2,    /* UDMA 33 */
+       .flags          = ATA_FLAG_SLAVE_POSS,
+       .pio_mask       = ATA_PIO4,
+       .mwdma_mask     = ATA_MWDMA2,
+       .udma_mask      = ATA_UDMA2,
        .port_ops       = &sis_old_ops,
 };
 static const struct ata_port_info sis_info66 = {
-       .sht            = &sis_sht,
-       .flags          = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
-       .pio_mask       = 0x1f, /* pio0-4 */
-       .udma_mask      = ATA_UDMA4,    /* UDMA 66 */
+       .flags          = ATA_FLAG_SLAVE_POSS,
+       .pio_mask       = ATA_PIO4,
+       /* No MWDMA */
+       .udma_mask      = ATA_UDMA4,
        .port_ops       = &sis_66_ops,
 };
 static const struct ata_port_info sis_info100 = {
-       .sht            = &sis_sht,
-       .flags          = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
-       .pio_mask       = 0x1f, /* pio0-4 */
+       .flags          = ATA_FLAG_SLAVE_POSS,
+       .pio_mask       = ATA_PIO4,
+       /* No MWDMA */
        .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,
+       .pio_mask       = ATA_PIO4,
+       /* No MWDMA */
        .udma_mask      = ATA_UDMA5,
-       .pio_mask       = 0x1f, /* pio0-4 */
        .port_ops       = &sis_66_ops,
 };
-const struct ata_port_info sis_info133 = {
-       .sht            = &sis_sht,
-       .flags          = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
-       .pio_mask       = 0x1f, /* pio0-4 */
+static const struct ata_port_info sis_info133 = {
+       .flags          = ATA_FLAG_SLAVE_POSS,
+       .pio_mask       = ATA_PIO4,
+       /* No MWDMA */
        .udma_mask      = ATA_UDMA6,
        .port_ops       = &sis_133_ops,
 };
-static const struct ata_port_info sis_info133_early = {
-       .sht            = &sis_sht,
+const struct ata_port_info sis_info133_for_sata = {
        .flags          = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
-       .pio_mask       = 0x1f, /* pio0-4 */
+       .pio_mask       = ATA_PIO4,
+       /* No MWDMA */
+       .udma_mask      = ATA_UDMA6,
+       .port_ops       = &sis_133_for_sata_ops,
+};
+static const struct ata_port_info sis_info133_early = {
+       .flags          = ATA_FLAG_SLAVE_POSS,
+       .pio_mask       = ATA_PIO4,
+       /* No MWDMA */
        .udma_mask      = ATA_UDMA6,
        .port_ops       = &sis_133_early_ops,
 };
 
 /* Privately shared with the SiS180 SATA driver, not for use elsewhere */
-EXPORT_SYMBOL_GPL(sis_info133);
+EXPORT_SYMBOL_GPL(sis_info133_for_sata);
 
 static void sis_fixup(struct pci_dev *pdev, struct sis_chipset *sis)
 {
@@ -823,11 +682,11 @@ static void sis_fixup(struct pci_dev *pdev, struct sis_chipset *sis)
 static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        static int printed_version;
-       struct ata_port_info port;
-       const struct ata_port_info *ppi[] = { &port, NULL };
+       const struct ata_port_info *ppi[] = { NULL, NULL };
        struct pci_dev *host = NULL;
        struct sis_chipset *chipset = NULL;
        struct sis_chipset *sets;
+       int rc;
 
        static struct sis_chipset sis_chipsets[] = {
 
@@ -880,16 +739,17 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
                dev_printk(KERN_DEBUG, &pdev->dev,
                           "version " DRV_VERSION "\n");
 
-       /* We have to find the bridge first */
+       rc = pcim_enable_device(pdev);
+       if (rc)
+               return rc;
 
+       /* We have to find the bridge first */
        for (sets = &sis_chipsets[0]; sets->device; sets++) {
                host = pci_get_device(PCI_VENDOR_ID_SI, sets->device, NULL);
                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;
@@ -933,7 +793,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);
@@ -946,11 +805,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;
                        }
@@ -964,17 +822,34 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        if (chipset == NULL)
                return -ENODEV;
 
-       port = *chipset->info;
-       port.private_data = chipset;
+       ppi[0] = chipset->info;
 
        sis_fixup(pdev, chipset);
 
-       return ata_pci_init_one(pdev, ppi);
+       return ata_pci_sff_init_one(pdev, ppi, &sis_sht, chipset);
 }
 
+#ifdef CONFIG_PM
+static int sis_reinit_one(struct pci_dev *pdev)
+{
+       struct ata_host *host = dev_get_drvdata(&pdev->dev);
+       int rc;
+
+       rc = ata_pci_device_do_resume(pdev);
+       if (rc)
+               return rc;
+
+       sis_fixup(pdev, host->private_data);
+
+       ata_host_resume(host);
+       return 0;
+}
+#endif
+
 static const struct pci_device_id sis_pci_tbl[] = {
        { PCI_VDEVICE(SI, 0x5513), },   /* SiS 5513 */
        { PCI_VDEVICE(SI, 0x5518), },   /* SiS 5518 */
+       { PCI_VDEVICE(SI, 0x1180), },   /* SiS 1180 */
 
        { }
 };
@@ -986,7 +861,7 @@ static struct pci_driver sis_pci_driver = {
        .remove                 = ata_pci_remove_one,
 #ifdef CONFIG_PM
        .suspend                = ata_pci_device_suspend,
-       .resume                 = ata_pci_device_resume,
+       .resume                 = sis_reinit_one,
 #endif
 };