[libata] sata_sis: use correct S/G table size
[cascardo/linux.git] / drivers / ata / ata_piix.c
index 0ff96a0..3c6f43e 100644 (file)
@@ -94,7 +94,7 @@
 #include <linux/dmi.h>
 
 #define DRV_NAME       "ata_piix"
-#define DRV_VERSION    "2.11"
+#define DRV_VERSION    "2.12"
 
 enum {
        PIIX_IOCFG              = 0x54, /* IDE I/O configuration register */
@@ -123,7 +123,6 @@ enum {
        ich_pata_33             = 1,    /* ICH up to UDMA 33 only */
        ich_pata_66             = 2,    /* ICH up to 66 Mhz */
        ich_pata_100            = 3,    /* ICH up to UDMA 100 */
-       ich_pata_133            = 4,    /* ICH up to UDMA 133 */
        ich5_sata               = 5,
        ich6_sata               = 6,
        ich6_sata_ahci          = 7,
@@ -131,6 +130,7 @@ enum {
        ich8_sata_ahci          = 9,
        piix_pata_mwdma         = 10,   /* PIIX3 MWDMA only */
        tolapai_sata_ahci       = 11,
+       ich9_2port_sata         = 12,
 
        /* constants for mapping table */
        P0                      = 0,  /* port 0 */
@@ -199,7 +199,7 @@ static const struct pci_device_id piix_pci_tbl[] = {
        { 0x8086, 0x24CA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
        { 0x8086, 0x24CB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
        /* Intel ICH5 */
-       { 0x8086, 0x24DB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_133 },
+       { 0x8086, 0x24DB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
        /* C-ICH (i810E2) */
        { 0x8086, 0x245B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
        /* ESB (855GME/875P + 6300ESB) UDMA 100  */
@@ -207,7 +207,7 @@ static const struct pci_device_id piix_pci_tbl[] = {
        /* ICH6 (and 6) (i915) UDMA 100 */
        { 0x8086, 0x266F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
        /* ICH7/7-R (i945, i975) UDMA 100*/
-       { 0x8086, 0x27DF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_133 },
+       { 0x8086, 0x27DF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
        { 0x8086, 0x269E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
        /* ICH8 Mobile PATA Controller */
        { 0x8086, 0x2850, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
@@ -239,19 +239,19 @@ static const struct pci_device_id piix_pci_tbl[] = {
        /* SATA Controller 1 IDE (ICH8) */
        { 0x8086, 0x2820, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
        /* SATA Controller 2 IDE (ICH8) */
-       { 0x8086, 0x2825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
+       { 0x8086, 0x2825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich9_2port_sata },
        /* Mobile SATA Controller IDE (ICH8M) */
        { 0x8086, 0x2828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
        /* SATA Controller IDE (ICH9) */
        { 0x8086, 0x2920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
        /* SATA Controller IDE (ICH9) */
-       { 0x8086, 0x2921, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
+       { 0x8086, 0x2921, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich9_2port_sata },
        /* SATA Controller IDE (ICH9) */
-       { 0x8086, 0x2926, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
+       { 0x8086, 0x2926, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich9_2port_sata },
        /* SATA Controller IDE (ICH9M) */
-       { 0x8086, 0x2928, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
+       { 0x8086, 0x2928, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich9_2port_sata },
        /* SATA Controller IDE (ICH9M) */
-       { 0x8086, 0x292d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
+       { 0x8086, 0x292d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich9_2port_sata },
        /* SATA Controller IDE (ICH9M) */
        { 0x8086, 0x292e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
        /* SATA Controller IDE (Tolapai) */
@@ -290,7 +290,6 @@ static struct scsi_host_template piix_sht = {
 };
 
 static const struct ata_port_operations piix_pata_ops = {
-       .port_disable           = ata_port_disable,
        .set_piomode            = piix_set_piomode,
        .set_dmamode            = piix_set_dmamode,
        .mode_filter            = ata_pci_default_filter,
@@ -318,13 +317,11 @@ static const struct ata_port_operations piix_pata_ops = {
        .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 ich_pata_ops = {
-       .port_disable           = ata_port_disable,
        .set_piomode            = piix_set_piomode,
        .set_dmamode            = ich_set_dmamode,
        .mode_filter            = ata_pci_default_filter,
@@ -352,14 +349,11 @@ static const struct ata_port_operations ich_pata_ops = {
        .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 piix_sata_ops = {
-       .port_disable           = ata_port_disable,
-
        .tf_load                = ata_tf_load,
        .tf_read                = ata_tf_read,
        .check_status           = ata_check_status,
@@ -382,7 +376,6 @@ static const struct ata_port_operations piix_sata_ops = {
        .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,
 };
@@ -445,15 +438,27 @@ static const struct piix_map_db ich8_map_db = {
 };
 
 static const struct piix_map_db tolapai_map_db = {
-        .mask = 0x3,
-        .port_enable = 0x3,
-        .map = {
-                /* PM   PS   SM   SS       MAP */
-                {  P0,  NA,  P1,  NA }, /* 00b */
-                {  RV,  RV,  RV,  RV }, /* 01b */
-                {  RV,  RV,  RV,  RV }, /* 10b */
-                {  RV,  RV,  RV,  RV },
-        },
+       .mask = 0x3,
+       .port_enable = 0x3,
+       .map = {
+               /* PM   PS   SM   SS       MAP */
+               {  P0,  NA,  P1,  NA }, /* 00b */
+               {  RV,  RV,  RV,  RV }, /* 01b */
+               {  RV,  RV,  RV,  RV }, /* 10b */
+               {  RV,  RV,  RV,  RV },
+       },
+};
+
+static const struct piix_map_db ich9_2port_map_db = {
+       .mask = 0x3,
+       .port_enable = 0x3,
+       .map = {
+               /* PM   PS   SM   SS       MAP */
+               {  P0,  NA,  P1,  NA }, /* 00b */
+               {  RV,  RV,  RV,  RV }, /* 01b */
+               {  RV,  RV,  RV,  RV }, /* 10b */
+               {  RV,  RV,  RV,  RV },
+       },
 };
 
 static const struct piix_map_db *piix_map_db_table[] = {
@@ -463,10 +468,11 @@ static const struct piix_map_db *piix_map_db_table[] = {
        [ich6m_sata_ahci]       = &ich6m_map_db,
        [ich8_sata_ahci]        = &ich8_map_db,
        [tolapai_sata_ahci]     = &tolapai_map_db,
+       [ich9_2port_sata]       = &ich9_2port_map_db,
 };
 
 static struct ata_port_info piix_port_info[] = {
-       /* piix_pata_33: 0:  PIIX4 at 33MHz */
+       [piix_pata_33] =        /* PIIX4 at 33MHz */
        {
                .sht            = &piix_sht,
                .flags          = PIIX_PATA_FLAGS,
@@ -476,7 +482,7 @@ static struct ata_port_info piix_port_info[] = {
                .port_ops       = &piix_pata_ops,
        },
 
-       /* ich_pata_33: 1       ICH0 - ICH at 33Mhz*/
+       [ich_pata_33] =         /* ICH0 - ICH at 33Mhz*/
        {
                .sht            = &piix_sht,
                .flags          = PIIX_PATA_FLAGS,
@@ -485,7 +491,8 @@ static struct ata_port_info piix_port_info[] = {
                .udma_mask      = ATA_UDMA2, /* UDMA33 */
                .port_ops       = &ich_pata_ops,
        },
-       /* ich_pata_66: 2       ICH controllers up to 66MHz */
+
+       [ich_pata_66] =         /* ICH controllers up to 66MHz */
        {
                .sht            = &piix_sht,
                .flags          = PIIX_PATA_FLAGS,
@@ -495,7 +502,7 @@ static struct ata_port_info piix_port_info[] = {
                .port_ops       = &ich_pata_ops,
        },
 
-       /* ich_pata_100: 3 */
+       [ich_pata_100] =
        {
                .sht            = &piix_sht,
                .flags          = PIIX_PATA_FLAGS | PIIX_FLAG_CHECKINTR,
@@ -505,17 +512,7 @@ static struct ata_port_info piix_port_info[] = {
                .port_ops       = &ich_pata_ops,
        },
 
-       /* ich_pata_133: 4      ICH with full UDMA6 */
-       {
-               .sht            = &piix_sht,
-               .flags          = PIIX_PATA_FLAGS | PIIX_FLAG_CHECKINTR,
-               .pio_mask       = 0x1f, /* pio 0-4 */
-               .mwdma_mask     = 0x06, /* Check: maybe 0x07  */
-               .udma_mask      = ATA_UDMA6, /* UDMA133 */
-               .port_ops       = &ich_pata_ops,
-       },
-
-       /* ich5_sata: 5 */
+       [ich5_sata] =
        {
                .sht            = &piix_sht,
                .flags          = PIIX_SATA_FLAGS,
@@ -525,7 +522,7 @@ static struct ata_port_info piix_port_info[] = {
                .port_ops       = &piix_sata_ops,
        },
 
-       /* ich6_sata: 6 */
+       [ich6_sata] =
        {
                .sht            = &piix_sht,
                .flags          = PIIX_SATA_FLAGS | PIIX_FLAG_SCR,
@@ -535,7 +532,7 @@ static struct ata_port_info piix_port_info[] = {
                .port_ops       = &piix_sata_ops,
        },
 
-       /* ich6_sata_ahci: 7 */
+       [ich6_sata_ahci] =
        {
                .sht            = &piix_sht,
                .flags          = PIIX_SATA_FLAGS | PIIX_FLAG_SCR |
@@ -546,7 +543,7 @@ static struct ata_port_info piix_port_info[] = {
                .port_ops       = &piix_sata_ops,
        },
 
-       /* ich6m_sata_ahci: 8 */
+       [ich6m_sata_ahci] =
        {
                .sht            = &piix_sht,
                .flags          = PIIX_SATA_FLAGS | PIIX_FLAG_SCR |
@@ -557,7 +554,7 @@ static struct ata_port_info piix_port_info[] = {
                .port_ops       = &piix_sata_ops,
        },
 
-       /* ich8_sata_ahci: 9 */
+       [ich8_sata_ahci] =
        {
                .sht            = &piix_sht,
                .flags          = PIIX_SATA_FLAGS | PIIX_FLAG_SCR |
@@ -568,7 +565,7 @@ static struct ata_port_info piix_port_info[] = {
                .port_ops       = &piix_sata_ops,
        },
 
-       /* piix_pata_mwdma: 10:  PIIX3 MWDMA only */
+       [piix_pata_mwdma] =     /* PIIX3 MWDMA only */
        {
                .sht            = &piix_sht,
                .flags          = PIIX_PATA_FLAGS,
@@ -577,7 +574,18 @@ static struct ata_port_info piix_port_info[] = {
                .port_ops       = &piix_pata_ops,
        },
 
-       /* tolapai_sata_ahci: 11: */
+       [tolapai_sata_ahci] =
+       {
+               .sht            = &piix_sht,
+               .flags          = PIIX_SATA_FLAGS | PIIX_FLAG_SCR |
+                                 PIIX_FLAG_AHCI,
+               .pio_mask       = 0x1f, /* pio0-4 */
+               .mwdma_mask     = 0x07, /* mwdma0-2 */
+               .udma_mask      = ATA_UDMA6,
+               .port_ops       = &piix_sata_ops,
+       },
+
+       [ich9_2port_sata] =
        {
                .sht            = &piix_sht,
                .flags          = PIIX_SATA_FLAGS | PIIX_FLAG_SCR |
@@ -615,6 +623,7 @@ static const struct ich_laptop ich_laptop[] = {
        { 0x27DF, 0x0005, 0x0280 },     /* ICH7 on Acer 5602WLMi */
        { 0x27DF, 0x1025, 0x0110 },     /* ICH7 on Acer 3682WLMi */
        { 0x27DF, 0x1043, 0x1267 },     /* ICH7 on Asus W5F */
+       { 0x27DF, 0x103C, 0x30A1 },     /* ICH7 on HP Compaq nc2400 */
        { 0x24CA, 0x1025, 0x0061 },     /* ICH4 on ACER Aspire 2023WLMi */
        /* end marker */
        { 0, }
@@ -657,19 +666,20 @@ static int ich_pata_cable_detect(struct ata_port *ap)
 
 /**
  *     piix_pata_prereset - prereset for PATA host controller
- *     @ap: Target port
+ *     @link: Target link
  *     @deadline: deadline jiffies for the operation
  *
  *     LOCKING:
  *     None (inherited from caller).
  */
-static int piix_pata_prereset(struct ata_port *ap, unsigned long deadline)
+static int piix_pata_prereset(struct ata_link *link, unsigned long deadline)
 {
+       struct ata_port *ap = link->ap;
        struct pci_dev *pdev = to_pci_dev(ap->host->dev);
 
        if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no]))
                return -ENOENT;
-       return ata_std_prereset(ap, deadline);
+       return ata_std_prereset(link, deadline);
 }
 
 static void piix_pata_error_handler(struct ata_port *ap)
@@ -919,7 +929,14 @@ static void ich_set_dmamode (struct ata_port *ap, struct ata_device *adev)
 #ifdef CONFIG_PM
 static int piix_broken_suspend(void)
 {
-       static struct dmi_system_id sysids[] = {
+       static const struct dmi_system_id sysids[] = {
+               {
+                       .ident = "TECRA M3",
+                       .matches = {
+                               DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
+                               DMI_MATCH(DMI_PRODUCT_NAME, "TECRA M3"),
+                       },
+               },
                {
                        .ident = "TECRA M5",
                        .matches = {
@@ -955,7 +972,8 @@ static int piix_broken_suspend(void)
                                DMI_MATCH(DMI_PRODUCT_NAME, "PORTEGE M500"),
                        },
                },
-               { }
+
+               { }     /* terminate list */
        };
        static const char *oemstrs[] = {
                "Tecra M3,",
@@ -1129,7 +1147,7 @@ static void __devinit piix_init_sata_map(struct pci_dev *pdev,
                                         const struct piix_map_db *map_db)
 {
        struct piix_host_priv *hpriv = pinfo[0].private_data;
-       const unsigned int *map;
+       const int *map;
        int i, invalid_map = 0;
        u8 map_value;
 
@@ -1175,7 +1193,7 @@ static void __devinit piix_init_sata_map(struct pci_dev *pdev,
 
 static void piix_iocfg_bit18_quirk(struct pci_dev *pdev)
 {
-       static struct dmi_system_id sysids[] = {
+       static const struct dmi_system_id sysids[] = {
                {
                        /* Clevo M570U sets IOCFG bit 18 if the cdrom
                         * isn't used to boot the system which
@@ -1187,6 +1205,8 @@ static void piix_iocfg_bit18_quirk(struct pci_dev *pdev)
                                DMI_MATCH(DMI_PRODUCT_NAME, "M570U"),
                        },
                },
+
+               { }     /* terminate list */
        };
        u32 iocfg;