]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/ata_piix.c
[libata ata_piix] fix native mode probe, after recent updates
[linux-2.6-omap-h63xx.git] / drivers / scsi / ata_piix.c
index deec0cef88d92bcb007c9b28c514948b3c700758..7f8aa1b552ce1f6d89d23c38c74356bf54363a96 100644 (file)
@@ -45,6 +45,7 @@
 #include <linux/init.h>
 #include <linux/blkdev.h>
 #include <linux/delay.h>
+#include <linux/device.h>
 #include "scsi.h"
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
@@ -68,8 +69,8 @@ enum {
        PIIX_COMB_PATA_P0       = (1 << 1),
        PIIX_COMB               = (1 << 2), /* combined mode enabled? */
 
-       PIIX_PORT_PRESENT       = (1 << 0),
-       PIIX_PORT_ENABLED       = (1 << 4),
+       PIIX_PORT_ENABLED       = (1 << 0),
+       PIIX_PORT_PRESENT       = (1 << 4),
 
        PIIX_80C_PRI            = (1 << 5) | (1 << 4),
        PIIX_80C_SEC            = (1 << 7) | (1 << 6),
@@ -147,7 +148,7 @@ static Scsi_Host_Template piix_sht = {
        .ordered_flush          = 1,
 };
 
-static struct ata_port_operations piix_pata_ops = {
+static const struct ata_port_operations piix_pata_ops = {
        .port_disable           = ata_port_disable,
        .set_piomode            = piix_set_piomode,
        .set_dmamode            = piix_set_dmamode,
@@ -177,7 +178,7 @@ static struct ata_port_operations piix_pata_ops = {
        .host_stop              = ata_host_stop,
 };
 
-static struct ata_port_operations piix_sata_ops = {
+static const struct ata_port_operations piix_sata_ops = {
        .port_disable           = ata_port_disable,
 
        .tf_load                = ata_tf_load,
@@ -377,7 +378,9 @@ static void piix_pata_phy_reset(struct ata_port *ap)
  *     None (inherited from caller).
  *
  *     RETURNS:
- *     Non-zero if device detected, zero otherwise.
+ *     Non-zero if port is enabled, it may or may not have a device
+ *     attached in that case (PRESENT bit would only be set if BIOS probe
+ *     was done). Zero is returned if port is disabled.
  */
 static int piix_sata_probe (struct ata_port *ap)
 {
@@ -401,7 +404,7 @@ static int piix_sata_probe (struct ata_port *ap)
         */
 
        for (i = 0; i < 4; i++) {
-               mask = (PIIX_PORT_PRESENT << i) | (PIIX_PORT_ENABLED << i);
+               mask = (PIIX_PORT_ENABLED << i);
 
                if ((orig_mask & mask) == mask)
                        if (combined || (i == ap->hard_port_no))
@@ -440,7 +443,6 @@ static void piix_sata_phy_reset(struct ata_port *ap)
  *     piix_set_piomode - Initialize host controller PATA PIO timings
  *     @ap: Port whose timings we are configuring
  *     @adev: um
- *     @pio: PIO mode, 0 - 4
  *
  *     Set PIO mode for device, in host controller PCI config space.
  *
@@ -566,18 +568,6 @@ static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev)
        }
 }
 
-/* move to PCI layer, integrate w/ MSI stuff */
-static void pci_enable_intx(struct pci_dev *pdev)
-{
-       u16 pci_command;
-
-       pci_read_config_word(pdev, PCI_COMMAND, &pci_command);
-       if (pci_command & PCI_COMMAND_INTX_DISABLE) {
-               pci_command &= ~PCI_COMMAND_INTX_DISABLE;
-               pci_write_config_word(pdev, PCI_COMMAND, pci_command);
-       }
-}
-
 #define AHCI_PCI_BAR 5
 #define AHCI_GLOBAL_CTL 0x04
 #define AHCI_ENABLE (1 << 31)
@@ -632,18 +622,19 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        static int printed_version;
        struct ata_port_info *port_info[2];
-       unsigned int combined = 0, n_ports = 1;
+       unsigned int combined = 0;
        unsigned int pata_chan = 0, sata_chan = 0;
 
        if (!printed_version++)
-               printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
+               dev_printk(KERN_DEBUG, &pdev->dev,
+                          "version " DRV_VERSION "\n");
 
        /* no hotplugging support (FIXME) */
        if (!in_module_init)
                return -ENODEV;
 
        port_info[0] = &piix_port_info[ent->driver_data];
-       port_info[1] = NULL;
+       port_info[1] = &piix_port_info[ent->driver_data];
 
        if (port_info[0]->host_flags & PIIX_FLAG_AHCI) {
                u8 tmp;
@@ -675,18 +666,19 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
         * message-signalled interrupts currently).
         */
        if (port_info[0]->host_flags & PIIX_FLAG_CHECKINTR)
-               pci_enable_intx(pdev);
+               pci_intx(pdev, 1);
 
        if (combined) {
                port_info[sata_chan] = &piix_port_info[ent->driver_data];
                port_info[sata_chan]->host_flags |= ATA_FLAG_SLAVE_POSS;
                port_info[pata_chan] = &piix_port_info[ich5_pata];
-               n_ports++;
 
-               printk(KERN_WARNING DRV_NAME ": combined mode detected\n");
+               dev_printk(KERN_WARNING, &pdev->dev,
+                          "combined mode detected (p=%u, s=%u)\n",
+                          pata_chan, sata_chan);
        }
 
-       return ata_pci_init_one(pdev, port_info, n_ports);
+       return ata_pci_init_one(pdev, port_info, 2);
 }
 
 static int __init piix_init(void)