]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ata/ata_piix.c
[SPARC64]: Fix virq decomposition.
[linux-2.6-omap-h63xx.git] / drivers / ata / ata_piix.c
index 4a795fdb6a02fa0bf37b150dca27d2d9cd460e88..d9fa329fd157741f12b83be996e8b7d419052044 100644 (file)
@@ -155,7 +155,6 @@ struct piix_host_priv {
 static int piix_init_one (struct pci_dev *pdev,
                                    const struct pci_device_id *ent);
 static void piix_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);
@@ -201,6 +200,8 @@ 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 },
+       /* ICH8 Mobile PATA Controller */
+       { 0x8086, 0x2850, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
 
        /* NOTE: The following PCI ids must be kept in sync with the
         * list in drivers/pci/quirks.c.
@@ -275,10 +276,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,
-#ifdef CONFIG_PM
-       .resume                 = ata_scsi_device_resume,
-       .suspend                = ata_scsi_device_suspend,
-#endif
 };
 
 static const struct ata_port_operations piix_pata_ops = {
@@ -368,7 +365,7 @@ static const struct ata_port_operations piix_sata_ops = {
 
        .freeze                 = ata_bmdma_freeze,
        .thaw                   = ata_bmdma_thaw,
-       .error_handler          = piix_sata_error_handler,
+       .error_handler          = ata_bmdma_error_handler,
        .post_internal_cmd      = ata_bmdma_post_internal_cmd,
 
        .irq_handler            = ata_interrupt,
@@ -417,7 +414,7 @@ static const struct piix_map_db ich6m_map_db = {
         */
        .map = {
                /* PM   PS   SM   SS       MAP */
-               {  P0,  P2,  RV,  RV }, /* 00b */
+               {  P0,  P2,  NA,  NA }, /* 00b */
                { IDE, IDE,  P1,  P3 }, /* 01b */
                {  P0,  P2, IDE, IDE }, /* 10b */
                {  RV,  RV,  RV,  RV },
@@ -500,7 +497,7 @@ static struct ata_port_info piix_port_info[] = {
                .flags          = PIIX_SATA_FLAGS,
                .pio_mask       = 0x1f, /* pio0-4 */
                .mwdma_mask     = 0x07, /* mwdma0-2 */
-               .udma_mask      = 0x7f, /* udma0-6 */
+               .udma_mask      = ATA_UDMA6,
                .port_ops       = &piix_sata_ops,
        },
 
@@ -510,7 +507,7 @@ static struct ata_port_info piix_port_info[] = {
                .flags          = PIIX_SATA_FLAGS | PIIX_FLAG_SCR,
                .pio_mask       = 0x1f, /* pio0-4 */
                .mwdma_mask     = 0x07, /* mwdma0-2 */
-               .udma_mask      = 0x7f, /* udma0-6 */
+               .udma_mask      = ATA_UDMA6,
                .port_ops       = &piix_sata_ops,
        },
 
@@ -521,7 +518,7 @@ static struct ata_port_info piix_port_info[] = {
                                  PIIX_FLAG_AHCI,
                .pio_mask       = 0x1f, /* pio0-4 */
                .mwdma_mask     = 0x07, /* mwdma0-2 */
-               .udma_mask      = 0x7f, /* udma0-6 */
+               .udma_mask      = ATA_UDMA6,
                .port_ops       = &piix_sata_ops,
        },
 
@@ -532,7 +529,7 @@ static struct ata_port_info piix_port_info[] = {
                                  PIIX_FLAG_AHCI,
                .pio_mask       = 0x1f, /* pio0-4 */
                .mwdma_mask     = 0x07, /* mwdma0-2 */
-               .udma_mask      = 0x7f, /* udma0-6 */
+               .udma_mask      = ATA_UDMA6,
                .port_ops       = &piix_sata_ops,
        },
 
@@ -543,7 +540,7 @@ static struct ata_port_info piix_port_info[] = {
                                  PIIX_FLAG_AHCI,
                .pio_mask       = 0x1f, /* pio0-4 */
                .mwdma_mask     = 0x07, /* mwdma0-2 */
-               .udma_mask      = 0x7f, /* udma0-6 */
+               .udma_mask      = ATA_UDMA6,
                .port_ops       = &piix_sata_ops,
        },
 
@@ -583,6 +580,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 */
+       { 0x24CA, 0x1025, 0x0061 },     /* ICH4 on ACER Aspire 2023WLMi */
        /* end marker */
        { 0, }
 };
@@ -645,12 +643,6 @@ static void piix_pata_error_handler(struct ata_port *ap)
                           ata_std_postreset);
 }
 
-static void piix_sata_error_handler(struct ata_port *ap)
-{
-       ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, NULL,
-                          ata_std_postreset);
-}
-
 /**
  *     piix_set_piomode - Initialize host controller PATA PIO timings
  *     @ap: Port whose timings we are configuring
@@ -695,8 +687,14 @@ static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev)
        if (adev->class == ATA_DEV_ATA)
                control |= 4;   /* PPE enable */
 
+       /* PIO configuration clears DTE unconditionally.  It will be
+        * programmed in set_dmamode which is guaranteed to be called
+        * after set_piomode if any DMA mode is available.
+        */
        pci_read_config_word(dev, master_port, &master_data);
        if (is_slave) {
+               /* clear TIME1|IE1|PPE1|DTE1 */
+               master_data &= 0xff0f;
                /* Enable SITRE (seperate slave timing register) */
                master_data |= 0x4000;
                /* enable PPE1, IE1 and TIME1 as needed */
@@ -704,12 +702,14 @@ static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev)
                pci_read_config_byte(dev, slave_port, &slave_data);
                slave_data &= (ap->port_no ? 0x0f : 0xf0);
                /* Load the timing nibble for this slave */
-               slave_data |= ((timings[pio][0] << 2) | timings[pio][1]) << (ap->port_no ? 4 : 0);
+               slave_data |= ((timings[pio][0] << 2) | timings[pio][1])
+                                               << (ap->port_no ? 4 : 0);
        } else {
-               /* Master keeps the bits in a different format */
-               master_data &= 0xccf8;
+               /* clear ISP|RCT|TIME0|IE0|PPE0|DTE0 */
+               master_data &= 0xccf0;
                /* Enable PPE, IE and TIME as appropriate */
                master_data |= control;
+               /* load ISP and RCT */
                master_data |=
                        (timings[pio][0] << 12) |
                        (timings[pio][1] << 8);
@@ -826,7 +826,7 @@ static void do_pata_set_dmamode (struct ata_port *ap, struct ata_device *adev, i
                        master_data &= 0xFF4F;  /* Mask out IORDY|TIME1|DMAONLY */
                        master_data |= control << 4;
                        pci_read_config_byte(dev, 0x44, &slave_data);
-                       slave_data &= (0x0F + 0xE1 * ap->port_no);
+                       slave_data &= (ap->port_no ? 0x0f : 0xf0);
                        /* Load the matching timing */
                        slave_data |= ((timings[pio][0] << 2) | timings[pio][1]) << (ap->port_no ? 4 : 0);
                        pci_write_config_byte(dev, 0x44, slave_data);
@@ -838,8 +838,11 @@ static void do_pata_set_dmamode (struct ata_port *ap, struct ata_device *adev, i
                                (timings[pio][0] << 12) |
                                (timings[pio][1] << 8);
                }
-               udma_enable &= ~(1 << devid);
-               pci_write_config_word(dev, master_port, master_data);
+
+               if (ap->udma_mask) {
+                       udma_enable &= ~(1 << devid);
+                       pci_write_config_word(dev, master_port, master_data);
+               }
        }
        /* Don't scribble on 0x48 if the controller does not support UDMA */
        if (ap->udma_mask)
@@ -925,20 +928,18 @@ static int __devinit piix_check_450nx_errata(struct pci_dev *ata_dev)
 {
        struct pci_dev *pdev = NULL;
        u16 cfg;
-       u8 rev;
        int no_piix_dma = 0;
 
        while((pdev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, pdev)) != NULL)
        {
                /* Look for 450NX PXB. Check for problem configurations
                   A PCI quirk checks bit 6 already */
-               pci_read_config_byte(pdev, PCI_REVISION_ID, &rev);
                pci_read_config_word(pdev, 0x41, &cfg);
                /* Only on the original revision: IDE DMA can hang */
-               if (rev == 0x00)
+               if (pdev->revision == 0x00)
                        no_piix_dma = 1;
                /* On all revisions below 5 PXB bus lock must be disabled for IDE */
-               else if (cfg & (1<<14) && rev < 5)
+               else if (cfg & (1<<14) && pdev->revision < 5)
                        no_piix_dma = 2;
        }
        if (no_piix_dma)
@@ -1034,7 +1035,7 @@ 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;
 
@@ -1093,7 +1094,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);
+       return ata_pci_init_one(pdev, ppi);
 }
 
 static int __init piix_init(void)