]> Pileus Git - ~andy/linux/blobdiff - drivers/scsi/ata_piix.c
Merge watchdog driver updates
[~andy/linux] / drivers / scsi / ata_piix.c
index 3be546439252332131fac6aca81cbdea71d9934a..deec0cef88d92bcb007c9b28c514948b3c700758 100644 (file)
@@ -1,24 +1,42 @@
 /*
-
-    ata_piix.c - Intel PATA/SATA controllers
-
-    Maintained by:  Jeff Garzik <jgarzik@pobox.com>
-                   Please ALWAYS copy linux-ide@vger.kernel.org
-                   on emails.
-
-
-       Copyright 2003-2004 Red Hat Inc
-       Copyright 2003-2004 Jeff Garzik
-
-
-       Copyright header from piix.c:
-
-    Copyright (C) 1998-1999 Andrzej Krzysztofowicz, Author and Maintainer
-    Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org>
-    Copyright (C) 2003 Red Hat Inc <alan@redhat.com>
-
-    May be copied or modified under the terms of the GNU General Public License
-
+ *    ata_piix.c - Intel PATA/SATA controllers
+ *
+ *    Maintained by:  Jeff Garzik <jgarzik@pobox.com>
+ *                 Please ALWAYS copy linux-ide@vger.kernel.org
+ *                 on emails.
+ *
+ *
+ *     Copyright 2003-2005 Red Hat Inc
+ *     Copyright 2003-2005 Jeff Garzik
+ *
+ *
+ *     Copyright header from piix.c:
+ *
+ *  Copyright (C) 1998-1999 Andrzej Krzysztofowicz, Author and Maintainer
+ *  Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org>
+ *  Copyright (C) 2003 Red Hat Inc <alan@redhat.com>
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; see the file COPYING.  If not, write to
+ *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *
+ *  libata documentation is available via 'make {ps|pdf}docs',
+ *  as Documentation/DocBook/libata.*
+ *
+ *  Hardware documentation available at http://developer.intel.com/
+ *
  */
 
 #include <linux/kernel.h>
 #include <linux/libata.h>
 
 #define DRV_NAME       "ata_piix"
-#define DRV_VERSION    "1.03"
+#define DRV_VERSION    "1.04"
 
 enum {
        PIIX_IOCFG              = 0x54, /* IDE I/O configuration register */
        ICH5_PMR                = 0x90, /* port mapping register */
        ICH5_PCS                = 0x92, /* port control and status */
+       PIIX_SCC                = 0x0A, /* sub-class code register */
 
        PIIX_FLAG_AHCI          = (1 << 28), /* AHCI possible */
        PIIX_FLAG_CHECKINTR     = (1 << 29), /* make sure PCI INTx enabled */
@@ -62,6 +81,8 @@ enum {
        ich6_sata_rm            = 4,
        ich7_sata               = 5,
        esb2_sata               = 6,
+
+       PIIX_AHCI_DEVICE        = 6,
 };
 
 static int piix_init_one (struct pci_dev *pdev,
@@ -562,8 +583,7 @@ static void pci_enable_intx(struct pci_dev *pdev)
 #define AHCI_ENABLE (1 << 31)
 static int piix_disable_ahci(struct pci_dev *pdev)
 {
-       void *mmio;
-       unsigned long addr;
+       void __iomem *mmio;
        u32 tmp;
        int rc = 0;
 
@@ -571,14 +591,14 @@ static int piix_disable_ahci(struct pci_dev *pdev)
         * works because this device is usually set up by BIOS.
         */
 
-       addr = pci_resource_start(pdev, AHCI_PCI_BAR);
-       if (!addr || !pci_resource_len(pdev, AHCI_PCI_BAR))
+       if (!pci_resource_start(pdev, AHCI_PCI_BAR) ||
+           !pci_resource_len(pdev, AHCI_PCI_BAR))
                return 0;
-       
-       mmio = ioremap(addr, 64);
+
+       mmio = pci_iomap(pdev, AHCI_PCI_BAR, 64);
        if (!mmio)
                return -ENOMEM;
-       
+
        tmp = readl(mmio + AHCI_GLOBAL_CTL);
        if (tmp & AHCI_ENABLE) {
                tmp &= ~AHCI_ENABLE;
@@ -588,8 +608,8 @@ static int piix_disable_ahci(struct pci_dev *pdev)
                if (tmp & AHCI_ENABLE)
                        rc = -EIO;
        }
-       
-       iounmap(mmio);
+
+       pci_iounmap(pdev, mmio);
        return rc;
 }
 
@@ -626,9 +646,13 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        port_info[1] = NULL;
 
        if (port_info[0]->host_flags & PIIX_FLAG_AHCI) {
-               int rc = piix_disable_ahci(pdev);
-               if (rc)
-                       return rc;
+               u8 tmp;
+               pci_read_config_byte(pdev, PIIX_SCC, &tmp);
+               if (tmp == PIIX_AHCI_DEVICE) {
+                       int rc = piix_disable_ahci(pdev);
+                       if (rc)
+                               return rc;
+               }
        }
 
        if (port_info[0]->host_flags & PIIX_FLAG_COMBINED) {