]> err.no Git - linux-2.6/blobdiff - drivers/scsi/ata_piix.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
[linux-2.6] / drivers / scsi / ata_piix.c
index 4080b8be847bc966c9f87ba66a595d4a9fbf8637..6dc88149f9f1537e0e20b708696a2949f053bac2 100644 (file)
@@ -101,7 +101,7 @@ enum {
        ICH5_PCS                = 0x92, /* port control and status */
        PIIX_SCC                = 0x0A, /* sub-class code register */
 
-       PIIX_FLAG_IGN_PRESENT   = (1 << 25), /* ignore PCS present bits */
+       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 */
@@ -209,8 +209,6 @@ static struct scsi_host_template piix_sht = {
        .name                   = DRV_NAME,
        .ioctl                  = ata_scsi_ioctl,
        .queuecommand           = ata_scsi_queuecmd,
-       .eh_timed_out           = ata_scsi_timed_out,
-       .eh_strategy_handler    = ata_scsi_error,
        .can_queue              = ATA_DEF_QUEUE,
        .this_id                = ATA_SHT_THIS_ID,
        .sg_tablesize           = LIBATA_MAX_PRD,
@@ -302,7 +300,7 @@ static struct piix_map_db ich6_map_db = {
        .mask = 0x3,
        .map = {
                /* PM   PS   SM   SS       MAP */
-               {  P0,  P1,  P2,  P3 }, /* 00b */
+               {  P0,  P2,  P1,  P3 }, /* 00b */
                { IDE, IDE,  P1,  P3 }, /* 01b */
                {  P0,  P2, IDE, IDE }, /* 10b */
                {  RV,  RV,  RV,  RV },
@@ -313,7 +311,7 @@ static struct piix_map_db ich6m_map_db = {
        .mask = 0x3,
        .map = {
                /* PM   PS   SM   SS       MAP */
-               {  P0,  P1,  P2,  P3 }, /* 00b */
+               {  P0,  P2,  RV,  RV }, /* 00b */
                {  RV,  RV,  RV,  RV },
                {  P0,  P2, IDE, IDE }, /* 10b */
                {  RV,  RV,  RV,  RV },
@@ -365,7 +363,7 @@ static struct ata_port_info piix_port_info[] = {
        {
                .sht            = &piix_sht,
                .host_flags     = ATA_FLAG_SATA | PIIX_FLAG_COMBINED |
-                                 PIIX_FLAG_CHECKINTR | PIIX_FLAG_IGN_PRESENT,
+                                 PIIX_FLAG_CHECKINTR | PIIX_FLAG_IGNORE_PCS,
                .pio_mask       = 0x1f, /* pio0-4 */
                .mwdma_mask     = 0x07, /* mwdma0-2 */
                .udma_mask      = 0x7f, /* udma0-6 */
@@ -499,44 +497,59 @@ static int piix_pata_probe_reset(struct ata_port *ap, unsigned int *classes)
  *     piix_sata_probe - Probe PCI device for present SATA devices
  *     @ap: Port associated with the PCI device we wish to probe
  *
- *     Reads SATA PCI device's PCI config register Port Configuration
- *     and Status (PCS) to determine port and device availability.
+ *     Reads and configures SATA PCI device's PCI config register
+ *     Port Configuration and Status (PCS) to determine port and
+ *     device availability.
  *
  *     LOCKING:
  *     None (inherited from caller).
  *
  *     RETURNS:
- *     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.
+ *     Mask of avaliable devices on the port.
  */
-static int piix_sata_probe (struct ata_port *ap)
+static unsigned int piix_sata_probe (struct ata_port *ap)
 {
        struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
-       int combined = (ap->flags & ATA_FLAG_SLAVE_POSS);
-       int orig_mask, mask, i;
+       const unsigned int *map = ap->host_set->private_data;
+       int base = 2 * ap->hard_port_no;
+       unsigned int present_mask = 0;
+       int port, i;
        u8 pcs;
 
        pci_read_config_byte(pdev, ICH5_PCS, &pcs);
-       orig_mask = (int) pcs & 0xff;
-
-       /* TODO: this is vaguely wrong for ICH6 combined mode,
-        * where only two of the four SATA ports are mapped
-        * onto a single ATA channel.  It is also vaguely inaccurate
-        * for ICH5, which has only two ports.  However, this is ok,
-        * as further device presence detection code will handle
-        * any false positives produced here.
-        */
+       DPRINTK("ata%u: ENTER, pcs=0x%x base=%d\n", ap->id, pcs, base);
 
-       for (i = 0; i < 4; i++) {
-               mask = (PIIX_PORT_ENABLED << i);
+       /* enable all ports on this ap and wait for them to settle */
+       for (i = 0; i < 2; i++) {
+               port = map[base + i];
+               if (port >= 0)
+                       pcs |= 1 << port;
+       }
+
+       pci_write_config_byte(pdev, ICH5_PCS, pcs);
+       msleep(100);
+
+       /* let's see which devices are present */
+       pci_read_config_byte(pdev, ICH5_PCS, &pcs);
 
-               if ((orig_mask & mask) == mask)
-                       if (combined || (i == ap->hard_port_no))
-                               return 1;
+       for (i = 0; i < 2; i++) {
+               port = map[base + i];
+               if (port < 0)
+                       continue;
+               if (ap->flags & PIIX_FLAG_IGNORE_PCS || pcs & 1 << (4 + port))
+                       present_mask |= 1 << i;
+               else
+                       pcs &= ~(1 << port);
        }
 
-       return 0;
+       /* disable offline ports on non-AHCI controllers */
+       if (!(ap->flags & PIIX_FLAG_AHCI))
+               pci_write_config_byte(pdev, ICH5_PCS, pcs);
+
+       DPRINTK("ata%u: LEAVE, pcs=0x%x present_mask=0x%x\n",
+               ap->id, pcs, present_mask);
+
+       return present_mask;
 }
 
 /**
@@ -728,7 +741,7 @@ static int piix_disable_ahci(struct pci_dev *pdev)
 /**
  *     piix_check_450nx_errata -       Check for problem 450NX setup
  *     @ata_dev: the PCI device to check
- *     
+ *
  *     Check for the present of 450NX errata #19 and errata #25. If
  *     they are found return an error code so we can turn off DMA
  */
@@ -739,7 +752,7 @@ static int __devinit piix_check_450nx_errata(struct pci_dev *ata_dev)
        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
@@ -758,7 +771,7 @@ static int __devinit piix_check_450nx_errata(struct pci_dev *ata_dev)
        if(no_piix_dma == 2)
                dev_printk(KERN_WARNING, &ata_dev->dev, "A BIOS update may resolve this.\n");
        return no_piix_dma;
-}              
+}
 
 static void __devinit piix_init_sata_map(struct pci_dev *pdev,
                                         struct ata_port_info *pinfo)