libata: clean up SFF init mess
[cascardo/linux.git] / drivers / ata / ata_piix.c
index 4fad8d2..13b6b1d 100644 (file)
@@ -40,7 +40,7 @@
  * Documentation
  *     Publically available from Intel web site. Errata documentation
  * is also publically available. As an aide to anyone hacking on this
- * driver the list of errata that are relevant is below.going back to
+ * driver the list of errata that are relevant is belowgoing back to
  * PIIX4. Older device documentation is now a bit tricky to find.
  *
  * The chipsets all follow very much the same design. The orginal Triton
@@ -93,7 +93,7 @@
 #include <linux/libata.h>
 
 #define DRV_NAME       "ata_piix"
-#define DRV_VERSION    "2.00ac6"
+#define DRV_VERSION    "2.11"
 
 enum {
        PIIX_IOCFG              = 0x54, /* IDE I/O configuration register */
@@ -101,11 +101,13 @@ enum {
        ICH5_PCS                = 0x92, /* port control and status */
        PIIX_SCC                = 0x0A, /* sub-class code register */
 
-       PIIX_FLAG_IGNORE_PCS    = (1 << 25), /* ignore PCS present bits */
        PIIX_FLAG_SCR           = (1 << 26), /* SCR available */
        PIIX_FLAG_AHCI          = (1 << 27), /* AHCI possible */
        PIIX_FLAG_CHECKINTR     = (1 << 28), /* make sure PCI INTx enabled */
 
+       PIIX_PATA_FLAGS         = ATA_FLAG_SLAVE_POSS,
+       PIIX_SATA_FLAGS         = ATA_FLAG_SATA | PIIX_FLAG_CHECKINTR,
+
        /* combined mode.  if set, PATA is channel 0.
         * if clear, PATA is channel 1.
         */
@@ -116,18 +118,17 @@ enum {
        PIIX_80C_SEC            = (1 << 7) | (1 << 6),
 
        /* controller IDs */
-       piix_pata_33            = 0,    /* PIIX3 or 4 at 33Mhz */
+       piix_pata_33            = 0,    /* PIIX4 at 33Mhz */
        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,
-       esb_sata                = 6,
-       ich6_sata               = 7,
-       ich6_sata_ahci          = 8,
-       ich6m_sata_ahci         = 9,
-       ich7m_sata_ahci         = 10,
-       ich8_sata_ahci          = 11,
+       ich6_sata               = 6,
+       ich6_sata_ahci          = 7,
+       ich6m_sata_ahci         = 8,
+       ich8_sata_ahci          = 9,
+       piix_pata_mwdma         = 10,   /* PIIX3 MWDMA only */
 
        /* constants for mapping table */
        P0                      = 0,  /* port 0 */
@@ -144,35 +145,30 @@ enum {
 struct piix_map_db {
        const u32 mask;
        const u16 port_enable;
-       const int present_shift;
        const int map[][4];
 };
 
 struct piix_host_priv {
        const int *map;
-       const struct piix_map_db *map_db;
 };
 
 static int piix_init_one (struct pci_dev *pdev,
                                    const struct pci_device_id *ent);
-static void piix_host_stop(struct ata_host *host);
 static void piix_pata_error_handler(struct ata_port *ap);
-static void ich_pata_error_handler(struct ata_port *ap);
 static void piix_sata_error_handler(struct ata_port *ap);
 static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev);
 static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev);
 static void ich_set_dmamode (struct ata_port *ap, struct ata_device *adev);
+static int ich_pata_cable_detect(struct ata_port *ap);
 
 static unsigned int in_module_init = 1;
 
 static const struct pci_device_id piix_pci_tbl[] = {
-#ifdef ATA_ENABLE_PATA
+       /* Intel PIIX3 for the 430HX etc */
+       { 0x8086, 0x7010, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_mwdma },
        /* Intel PIIX4 for the 430TX/440BX/MX chipset: UDMA 33 */
        /* Also PIIX4E (fn3 rev 2) and PIIX4M (fn3 rev 3) */
-       { 0x8086, 0x7110, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_33 },
        { 0x8086, 0x7111, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_33 },
-       { 0x8086, 0x24db, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
-       { 0x8086, 0x25a2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
        /* Intel PIIX4 */
        { 0x8086, 0x7199, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_33 },
        /* Intel PIIX4 */
@@ -205,7 +201,6 @@ static const struct pci_device_id piix_pci_tbl[] = {
        /* ICH7/7-R (i945, i975) UDMA 100*/
        { 0x8086, 0x27DF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_133 },
        { 0x8086, 0x269E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
-#endif
 
        /* NOTE: The following PCI ids must be kept in sync with the
         * list in drivers/pci/quirks.c.
@@ -216,9 +211,9 @@ static const struct pci_device_id piix_pci_tbl[] = {
        /* 82801EB (ICH5) */
        { 0x8086, 0x24df, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata },
        /* 6300ESB (ICH5 variant with broken PCS present bits) */
-       { 0x8086, 0x25a3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, esb_sata },
+       { 0x8086, 0x25a3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata },
        /* 6300ESB pretending RAID */
-       { 0x8086, 0x25b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, esb_sata },
+       { 0x8086, 0x25b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata },
        /* 82801FB/FW (ICH6/ICH6W) */
        { 0x8086, 0x2651, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata },
        /* 82801FR/FRW (ICH6R/ICH6RW) */
@@ -228,15 +223,27 @@ static const struct pci_device_id piix_pci_tbl[] = {
        /* 82801GB/GR/GH (ICH7, identical to ICH6) */
        { 0x8086, 0x27c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci },
        /* 2801GBM/GHM (ICH7M, identical to ICH6M) */
-       { 0x8086, 0x27c4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich7m_sata_ahci },
-       /* Enterprise Southbridge 2 (where's the datasheet?) */
+       { 0x8086, 0x27c4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6m_sata_ahci },
+       /* Enterprise Southbridge 2 (631xESB/632xESB) */
        { 0x8086, 0x2680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci },
-       /* SATA Controller 1 IDE (ICH8, no datasheet yet) */
+       /* SATA Controller 1 IDE (ICH8) */
        { 0x8086, 0x2820, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
-       /* SATA Controller 2 IDE (ICH8, ditto) */
+       /* SATA Controller 2 IDE (ICH8) */
        { 0x8086, 0x2825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
-       /* Mobile SATA Controller IDE (ICH8M, ditto) */
+       /* 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 },
+       /* SATA Controller IDE (ICH9) */
+       { 0x8086, 0x2926, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
+       /* SATA Controller IDE (ICH9M) */
+       { 0x8086, 0x2928, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
+       /* SATA Controller IDE (ICH9M) */
+       { 0x8086, 0x292d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
+       /* SATA Controller IDE (ICH9M) */
+       { 0x8086, 0x292e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci },
 
        { }     /* terminate list */
 };
@@ -246,8 +253,10 @@ static struct pci_driver piix_pci_driver = {
        .id_table               = piix_pci_tbl,
        .probe                  = piix_init_one,
        .remove                 = ata_pci_remove_one,
+#ifdef CONFIG_PM
        .suspend                = ata_pci_device_suspend,
        .resume                 = ata_pci_device_resume,
+#endif
 };
 
 static struct scsi_host_template piix_sht = {
@@ -266,8 +275,6 @@ static struct scsi_host_template piix_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 piix_pata_ops = {
@@ -288,19 +295,20 @@ static const struct ata_port_operations piix_pata_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,
 
        .freeze                 = ata_bmdma_freeze,
        .thaw                   = ata_bmdma_thaw,
        .error_handler          = piix_pata_error_handler,
        .post_internal_cmd      = ata_bmdma_post_internal_cmd,
+       .cable_detect           = ata_cable_40wire,
 
        .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              = piix_host_stop,
 };
 
 static const struct ata_port_operations ich_pata_ops = {
@@ -321,19 +329,20 @@ static const struct ata_port_operations ich_pata_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,
 
        .freeze                 = ata_bmdma_freeze,
        .thaw                   = ata_bmdma_thaw,
-       .error_handler          = ich_pata_error_handler,
+       .error_handler          = piix_pata_error_handler,
        .post_internal_cmd      = ata_bmdma_post_internal_cmd,
+       .cable_detect           = ich_pata_cable_detect,
 
        .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 piix_sata_ops = {
@@ -351,7 +360,7 @@ static const struct ata_port_operations piix_sata_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,
 
        .freeze                 = ata_bmdma_freeze,
        .thaw                   = ata_bmdma_thaw,
@@ -360,16 +369,15 @@ 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,
-       .port_stop              = ata_port_stop,
-       .host_stop              = piix_host_stop,
 };
 
 static const struct piix_map_db ich5_map_db = {
        .mask = 0x7,
        .port_enable = 0x3,
-       .present_shift = 4,
        .map = {
                /* PM   PS   SM   SS       MAP  */
                {  P0,  NA,  P1,  NA }, /* 000b */
@@ -386,7 +394,6 @@ static const struct piix_map_db ich5_map_db = {
 static const struct piix_map_db ich6_map_db = {
        .mask = 0x3,
        .port_enable = 0xf,
-       .present_shift = 4,
        .map = {
                /* PM   PS   SM   SS       MAP */
                {  P0,  P2,  P1,  P3 }, /* 00b */
@@ -399,24 +406,10 @@ static const struct piix_map_db ich6_map_db = {
 static const struct piix_map_db ich6m_map_db = {
        .mask = 0x3,
        .port_enable = 0x5,
-       .present_shift = 4,
-       .map = {
-               /* PM   PS   SM   SS       MAP */
-               {  P0,  P2,  RV,  RV }, /* 00b */
-               {  RV,  RV,  RV,  RV },
-               {  P0,  P2, IDE, IDE }, /* 10b */
-               {  RV,  RV,  RV,  RV },
-       },
-};
-
-static const struct piix_map_db ich7m_map_db = {
-       .mask = 0x3,
-       .port_enable = 0x5,
-       .present_shift = 4,
 
        /* Map 01b isn't specified in the doc but some notebooks use
-        * it anyway.  ATM, the only case spotted carries subsystem ID
-        * 1025:0107.  This is the only difference from ich6m.
+        * it anyway.  MAP 01b have been spotted on both ICH6M and
+        * ICH7M.
         */
        .map = {
                /* PM   PS   SM   SS       MAP */
@@ -430,7 +423,6 @@ static const struct piix_map_db ich7m_map_db = {
 static const struct piix_map_db ich8_map_db = {
        .mask = 0x3,
        .port_enable = 0x3,
-       .present_shift = 8,
        .map = {
                /* PM   PS   SM   SS       MAP */
                {  P0,  P2,  P1,  P3 }, /* 00b (hardwired when in AHCI) */
@@ -442,19 +434,17 @@ static const struct piix_map_db ich8_map_db = {
 
 static const struct piix_map_db *piix_map_db_table[] = {
        [ich5_sata]             = &ich5_map_db,
-       [esb_sata]              = &ich5_map_db,
        [ich6_sata]             = &ich6_map_db,
        [ich6_sata_ahci]        = &ich6_map_db,
        [ich6m_sata_ahci]       = &ich6m_map_db,
-       [ich7m_sata_ahci]       = &ich7m_map_db,
        [ich8_sata_ahci]        = &ich8_map_db,
 };
 
 static struct ata_port_info piix_port_info[] = {
-       /* piix_pata_33: 0:  PIIX3 or 4 at 33MHz */
+       /* piix_pata_33: 0:  PIIX4 at 33MHz */
        {
                .sht            = &piix_sht,
-               .flags          = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
+               .flags          = PIIX_PATA_FLAGS,
                .pio_mask       = 0x1f, /* pio0-4 */
                .mwdma_mask     = 0x06, /* mwdma1-2 ?? CHECK 0 should be ok but slow */
                .udma_mask      = ATA_UDMA_MASK_40C,
@@ -464,7 +454,7 @@ static struct ata_port_info piix_port_info[] = {
        /* ich_pata_33: 1       ICH0 - ICH at 33Mhz*/
        {
                .sht            = &piix_sht,
-               .flags          = ATA_FLAG_SRST | ATA_FLAG_SLAVE_POSS,
+               .flags          = PIIX_PATA_FLAGS,
                .pio_mask       = 0x1f, /* pio 0-4 */
                .mwdma_mask     = 0x06, /* Check: maybe 0x07  */
                .udma_mask      = ATA_UDMA2, /* UDMA33 */
@@ -473,7 +463,7 @@ static struct ata_port_info piix_port_info[] = {
        /* ich_pata_66: 2       ICH controllers up to 66MHz */
        {
                .sht            = &piix_sht,
-               .flags          = ATA_FLAG_SRST | ATA_FLAG_SLAVE_POSS,
+               .flags          = PIIX_PATA_FLAGS,
                .pio_mask       = 0x1f, /* pio 0-4 */
                .mwdma_mask     = 0x06, /* MWDMA0 is broken on chip */
                .udma_mask      = ATA_UDMA4,
@@ -483,7 +473,7 @@ static struct ata_port_info piix_port_info[] = {
        /* ich_pata_100: 3 */
        {
                .sht            = &piix_sht,
-               .flags          = ATA_FLAG_SRST | ATA_FLAG_SLAVE_POSS | PIIX_FLAG_CHECKINTR,
+               .flags          = PIIX_PATA_FLAGS | PIIX_FLAG_CHECKINTR,
                .pio_mask       = 0x1f, /* pio0-4 */
                .mwdma_mask     = 0x06, /* mwdma1-2 */
                .udma_mask      = ATA_UDMA5, /* udma0-5 */
@@ -493,7 +483,7 @@ static struct ata_port_info piix_port_info[] = {
        /* ich_pata_133: 4      ICH with full UDMA6 */
        {
                .sht            = &piix_sht,
-               .flags          = ATA_FLAG_SRST | ATA_FLAG_SLAVE_POSS | PIIX_FLAG_CHECKINTR,
+               .flags          = PIIX_PATA_FLAGS | PIIX_FLAG_CHECKINTR,
                .pio_mask       = 0x1f, /* pio 0-4 */
                .mwdma_mask     = 0x06, /* Check: maybe 0x07  */
                .udma_mask      = ATA_UDMA6, /* UDMA133 */
@@ -503,41 +493,27 @@ static struct ata_port_info piix_port_info[] = {
        /* ich5_sata: 5 */
        {
                .sht            = &piix_sht,
-               .flags          = ATA_FLAG_SATA | PIIX_FLAG_CHECKINTR |
-                                 PIIX_FLAG_IGNORE_PCS,
+               .flags          = PIIX_SATA_FLAGS,
                .pio_mask       = 0x1f, /* pio0-4 */
                .mwdma_mask     = 0x07, /* mwdma0-2 */
                .udma_mask      = 0x7f, /* udma0-6 */
                .port_ops       = &piix_sata_ops,
        },
 
-       /* i6300esb_sata: 6 */
+       /* ich6_sata: 6 */
        {
                .sht            = &piix_sht,
-               .flags          = ATA_FLAG_SATA |
-                                 PIIX_FLAG_CHECKINTR | PIIX_FLAG_IGNORE_PCS,
+               .flags          = PIIX_SATA_FLAGS | PIIX_FLAG_SCR,
                .pio_mask       = 0x1f, /* pio0-4 */
                .mwdma_mask     = 0x07, /* mwdma0-2 */
                .udma_mask      = 0x7f, /* udma0-6 */
                .port_ops       = &piix_sata_ops,
        },
 
-       /* ich6_sata: 7 */
+       /* ich6_sata_ahci: 7 */
        {
                .sht            = &piix_sht,
-               .flags          = ATA_FLAG_SATA |
-                                 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR,
-               .pio_mask       = 0x1f, /* pio0-4 */
-               .mwdma_mask     = 0x07, /* mwdma0-2 */
-               .udma_mask      = 0x7f, /* udma0-6 */
-               .port_ops       = &piix_sata_ops,
-       },
-
-       /* ich6_sata_ahci: 8 */
-       {
-               .sht            = &piix_sht,
-               .flags          = ATA_FLAG_SATA |
-                                 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR |
+               .flags          = PIIX_SATA_FLAGS | PIIX_FLAG_SCR |
                                  PIIX_FLAG_AHCI,
                .pio_mask       = 0x1f, /* pio0-4 */
                .mwdma_mask     = 0x07, /* mwdma0-2 */
@@ -545,11 +521,10 @@ static struct ata_port_info piix_port_info[] = {
                .port_ops       = &piix_sata_ops,
        },
 
-       /* ich6m_sata_ahci: 9 */
+       /* ich6m_sata_ahci: 8 */
        {
                .sht            = &piix_sht,
-               .flags          = ATA_FLAG_SATA |
-                                 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR |
+               .flags          = PIIX_SATA_FLAGS | PIIX_FLAG_SCR |
                                  PIIX_FLAG_AHCI,
                .pio_mask       = 0x1f, /* pio0-4 */
                .mwdma_mask     = 0x07, /* mwdma0-2 */
@@ -557,11 +532,10 @@ static struct ata_port_info piix_port_info[] = {
                .port_ops       = &piix_sata_ops,
        },
 
-       /* ich7m_sata_ahci: 10 */
+       /* ich8_sata_ahci: 9 */
        {
                .sht            = &piix_sht,
-               .flags          = ATA_FLAG_SATA |
-                                 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR |
+               .flags          = PIIX_SATA_FLAGS | PIIX_FLAG_SCR |
                                  PIIX_FLAG_AHCI,
                .pio_mask       = 0x1f, /* pio0-4 */
                .mwdma_mask     = 0x07, /* mwdma0-2 */
@@ -569,18 +543,14 @@ static struct ata_port_info piix_port_info[] = {
                .port_ops       = &piix_sata_ops,
        },
 
-       /* ich8_sata_ahci: 11 */
+       /* piix_pata_mwdma: 10:  PIIX3 MWDMA only */
        {
                .sht            = &piix_sht,
-               .flags          = ATA_FLAG_SATA |
-                                 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR |
-                                 PIIX_FLAG_AHCI,
+               .flags          = PIIX_PATA_FLAGS,
                .pio_mask       = 0x1f, /* pio0-4 */
-               .mwdma_mask     = 0x07, /* mwdma0-2 */
-               .udma_mask      = 0x7f, /* udma0-6 */
-               .port_ops       = &piix_sata_ops,
+               .mwdma_mask     = 0x06, /* mwdma1-2 ?? CHECK 0 should be ok but slow */
+               .port_ops       = &piix_pata_ops,
        },
-
 };
 
 static struct pci_bits piix_enable_bits[] = {
@@ -594,13 +564,27 @@ MODULE_LICENSE("GPL");
 MODULE_DEVICE_TABLE(pci, piix_pci_tbl);
 MODULE_VERSION(DRV_VERSION);
 
-static int force_pcs = 0;
-module_param(force_pcs, int, 0444);
-MODULE_PARM_DESC(force_pcs, "force honoring or ignoring PCS to work around "
-                "device mis-detection (0=default, 1=ignore PCS, 2=honor PCS)");
+struct ich_laptop {
+       u16 device;
+       u16 subvendor;
+       u16 subdevice;
+};
+
+/*
+ *     List of laptops that use short cables rather than 80 wire
+ */
+
+static const struct ich_laptop ich_laptop[] = {
+       /* devid, subvendor, subdev */
+       { 0x27DF, 0x0005, 0x0280 },     /* ICH7 on Acer 5602WLMi */
+       { 0x27DF, 0x1025, 0x0110 },     /* ICH7 on Acer 3682WLMi */
+       { 0x27DF, 0x1043, 0x1267 },     /* ICH7 on Asus W5F */
+       /* end marker */
+       { 0, }
+};
 
 /**
- *     piix_pata_cbl_detect - Probe host controller cable detect info
+ *     ich_pata_cable_detect - Probe host controller cable detect info
  *     @ap: Port for which cable detect info is desired
  *
  *     Read 80c cable indicator from ATA PCI device's PCI config
@@ -610,45 +594,45 @@ MODULE_PARM_DESC(force_pcs, "force honoring or ignoring PCS to work around "
  *     None (inherited from caller).
  */
 
-static void ich_pata_cbl_detect(struct ata_port *ap)
+static int ich_pata_cable_detect(struct ata_port *ap)
 {
        struct pci_dev *pdev = to_pci_dev(ap->host->dev);
+       const struct ich_laptop *lap = &ich_laptop[0];
        u8 tmp, mask;
 
-       /* no 80c support in host controller? */
-       if ((ap->udma_mask & ~ATA_UDMA_MASK_40C) == 0)
-               goto cbl40;
+       /* Check for specials - Acer Aspire 5602WLMi */
+       while (lap->device) {
+               if (lap->device == pdev->device &&
+                   lap->subvendor == pdev->subsystem_vendor &&
+                   lap->subdevice == pdev->subsystem_device) {
+                       return ATA_CBL_PATA40_SHORT;
+               }
+               lap++;
+       }
 
        /* check BIOS cable detect results */
        mask = ap->port_no == 0 ? PIIX_80C_PRI : PIIX_80C_SEC;
        pci_read_config_byte(pdev, PIIX_IOCFG, &tmp);
        if ((tmp & mask) == 0)
-               goto cbl40;
-
-       ap->cbl = ATA_CBL_PATA80;
-       return;
-
-cbl40:
-       ap->cbl = ATA_CBL_PATA40;
+               return ATA_CBL_PATA40;
+       return ATA_CBL_PATA80;
 }
 
 /**
  *     piix_pata_prereset - prereset for PATA host controller
  *     @ap: Target port
- *
+ *     @deadline: deadline jiffies for the operation
  *
  *     LOCKING:
  *     None (inherited from caller).
  */
-static int piix_pata_prereset(struct ata_port *ap)
+static int piix_pata_prereset(struct ata_port *ap, unsigned long deadline)
 {
        struct pci_dev *pdev = to_pci_dev(ap->host->dev);
 
        if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no]))
                return -ENOENT;
-               
-       ap->cbl = ATA_CBL_PATA40;
-       return ata_std_prereset(ap);
+       return ata_std_prereset(ap, deadline);
 }
 
 static void piix_pata_error_handler(struct ata_port *ap)
@@ -657,114 +641,9 @@ static void piix_pata_error_handler(struct ata_port *ap)
                           ata_std_postreset);
 }
 
-
-/**
- *     ich_pata_prereset - prereset for PATA host controller
- *     @ap: Target port
- *
- *
- *     LOCKING:
- *     None (inherited from caller).
- */
-static int ich_pata_prereset(struct ata_port *ap)
-{
-       struct pci_dev *pdev = to_pci_dev(ap->host->dev);
-
-       if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no])) {
-               ata_port_printk(ap, KERN_INFO, "port disabled. ignoring.\n");
-               ap->eh_context.i.action &= ~ATA_EH_RESET_MASK;
-               return 0;
-       }
-
-       ich_pata_cbl_detect(ap);
-
-       return ata_std_prereset(ap);
-}
-
-static void ich_pata_error_handler(struct ata_port *ap)
-{
-       ata_bmdma_drive_eh(ap, ich_pata_prereset, ata_std_softreset, NULL,
-                          ata_std_postreset);
-}
-
-/**
- *     piix_sata_present_mask - determine present mask for SATA host controller
- *     @ap: Target port
- *
- *     Reads SATA PCI device's PCI config register Port Configuration
- *     and Status (PCS) to determine port and device availability.
- *
- *     LOCKING:
- *     None (inherited from caller).
- *
- *     RETURNS:
- *     determined present_mask
- */
-static unsigned int piix_sata_present_mask(struct ata_port *ap)
-{
-       struct pci_dev *pdev = to_pci_dev(ap->host->dev);
-       struct piix_host_priv *hpriv = ap->host->private_data;
-       const unsigned int *map = hpriv->map;
-       int base = 2 * ap->port_no;
-       unsigned int present_mask = 0;
-       int port, i;
-       u16 pcs;
-
-       pci_read_config_word(pdev, ICH5_PCS, &pcs);
-       DPRINTK("ata%u: ENTER, pcs=0x%x base=%d\n", ap->id, pcs, base);
-
-       for (i = 0; i < 2; i++) {
-               port = map[base + i];
-               if (port < 0)
-                       continue;
-               if ((ap->flags & PIIX_FLAG_IGNORE_PCS) ||
-                   (pcs & 1 << (hpriv->map_db->present_shift + port)))
-                       present_mask |= 1 << i;
-       }
-
-       DPRINTK("ata%u: LEAVE, pcs=0x%x present_mask=0x%x\n",
-               ap->id, pcs, present_mask);
-
-       return present_mask;
-}
-
-/**
- *     piix_sata_softreset - reset SATA host port via ATA SRST
- *     @ap: port to reset
- *     @classes: resulting classes of attached devices
- *
- *     Reset SATA host port via ATA SRST.  On controllers with
- *     reliable PCS present bits, the bits are used to determine
- *     device presence.
- *
- *     LOCKING:
- *     Kernel thread context (may sleep)
- *
- *     RETURNS:
- *     0 on success, -errno otherwise.
- */
-static int piix_sata_softreset(struct ata_port *ap, unsigned int *classes)
-{
-       unsigned int present_mask;
-       int i, rc;
-
-       present_mask = piix_sata_present_mask(ap);
-
-       rc = ata_std_softreset(ap, classes);
-       if (rc)
-               return rc;
-
-       for (i = 0; i < ATA_MAX_DEVICES; i++) {
-               if (!(present_mask & (1 << i)))
-                       classes[i] = ATA_DEV_NONE;
-       }
-
-       return 0;
-}
-
 static void piix_sata_error_handler(struct ata_port *ap)
 {
-       ata_bmdma_drive_eh(ap, ata_std_prereset, piix_sata_softreset, NULL,
+       ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, NULL,
                           ata_std_postreset);
 }
 
@@ -865,7 +744,7 @@ static void do_pata_set_dmamode (struct ata_port *ap, struct ata_device *adev, i
        u16 master_data;
        u8 speed                = adev->dma_mode;
        int devid               = adev->devno + 2 * ap->port_no;
-       u8 udma_enable;
+       u8 udma_enable          = 0;
 
        static const     /* ISP  RTC */
        u8 timings[][2] = { { 0, 0 },
@@ -875,7 +754,8 @@ static void do_pata_set_dmamode (struct ata_port *ap, struct ata_device *adev, i
                            { 2, 3 }, };
 
        pci_read_config_word(dev, master_port, &master_data);
-       pci_read_config_byte(dev, 0x48, &udma_enable);
+       if (ap->udma_mask)
+               pci_read_config_byte(dev, 0x48, &udma_enable);
 
        if (speed >= XFER_UDMA_0) {
                unsigned int udma = adev->dma_mode - XFER_UDMA_0;
@@ -1079,18 +959,6 @@ static void __devinit piix_init_pcs(struct pci_dev *pdev,
                pci_write_config_word(pdev, ICH5_PCS, new_pcs);
                msleep(150);
        }
-
-       if (force_pcs == 1) {
-               dev_printk(KERN_INFO, &pdev->dev,
-                          "force ignoring PCS (0x%x)\n", new_pcs);
-               pinfo[0].flags |= PIIX_FLAG_IGNORE_PCS;
-               pinfo[1].flags |= PIIX_FLAG_IGNORE_PCS;
-       } else if (force_pcs == 2) {
-               dev_printk(KERN_INFO, &pdev->dev,
-                          "force honoring PCS (0x%x)\n", new_pcs);
-               pinfo[0].flags &= ~PIIX_FLAG_IGNORE_PCS;
-               pinfo[1].flags &= ~PIIX_FLAG_IGNORE_PCS;
-       }
 }
 
 static void __devinit piix_init_sata_map(struct pci_dev *pdev,
@@ -1140,7 +1008,6 @@ static void __devinit piix_init_sata_map(struct pci_dev *pdev,
                           "invalid MAP value %u\n", map_value);
 
        hpriv->map = map;
-       hpriv->map_db = map_db;
 }
 
 /**
@@ -1161,8 +1028,9 @@ static void __devinit piix_init_sata_map(struct pci_dev *pdev,
 static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        static int printed_version;
+       struct device *dev = &pdev->dev;
        struct ata_port_info port_info[2];
-       struct ata_port_info *ppinfo[2] = { &port_info[0], &port_info[1] };
+       const struct ata_port_info *ppi[] = { &port_info[0], &port_info[1] };
        struct piix_host_priv *hpriv;
        unsigned long port_flags;
 
@@ -1174,7 +1042,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        if (!in_module_init)
                return -ENODEV;
 
-       hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL);
+       hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
        if (!hpriv)
                return -ENOMEM;
 
@@ -1221,16 +1089,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
                port_info[1].mwdma_mask = 0;
                port_info[1].udma_mask = 0;
        }
-       return ata_pci_init_one(pdev, ppinfo, 2);
-}
-
-static void piix_host_stop(struct ata_host *host)
-{
-       struct piix_host_priv *hpriv = host->private_data;
-
-       ata_host_stop(host);
-
-       kfree(hpriv);
+       return ata_pci_init_one(pdev, ppi);
 }
 
 static int __init piix_init(void)