patch-2.3.11 linux/drivers/scsi/aic7xxx.c

Next file: linux/drivers/scsi/eata_dma.c
Previous file: linux/drivers/pci/oldproc.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.10/linux/drivers/scsi/aic7xxx.c linux/drivers/scsi/aic7xxx.c
@@ -242,7 +242,6 @@
 #include <linux/proc_fs.h>
 #include <linux/blk.h>
 #include <linux/tqueue.h>
-#include <linux/tasks.h>
 #include "sd.h"
 #include "scsi.h"
 #include "hosts.h"
@@ -270,7 +269,7 @@
     0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL
 };
 
-#define AIC7XXX_C_VERSION  "5.1.18"
+#define AIC7XXX_C_VERSION  "5.1.19"
 
 #define NUMBER(arr)     (sizeof(arr) / sizeof(arr[0]))
 #define MIN(a,b)        (((a) < (b)) ? (a) : (b))
@@ -7186,7 +7185,7 @@
 static int
 acquire_seeprom(struct aic7xxx_host *p)
 {
-  int count=0;
+  int wait;
 
   /*
    * Request access of the memory port.  When access is
@@ -7196,10 +7195,11 @@
    * should be no contention.
    */
   aic_outb(p, SEEMS, SEECTL);
-  while( ((aic_inb(p, SEECTL) & SEERDY) == 0) && count < 1000) {
-    mb();
-    udelay(1);
-    count++;
+  wait = 1000;  /* 1000 msec = 1 second */
+  while ((wait > 0) && ((aic_inb(p, SEECTL) & SEERDY) == 0))
+  {
+    wait--;
+    mdelay(1);  /* 1 msec */
   }
   if ((aic_inb(p, SEECTL) & SEERDY) == 0)
   {
@@ -7419,21 +7419,27 @@
 static unsigned char
 read_brdctl(struct aic7xxx_host *p)
 {
-  unsigned char brdctl;
+  unsigned char brdctl, value;
 
-  if ((p->chip & AHC_CHIPID_MASK) == AHC_AIC7895)
+  if (p->features & AHC_ULTRA2)
   {
-    brdctl = BRDRW;
-    if (p->flags & AHC_CHNLB)
-      brdctl |= BRDCS;
-  }
-  else if (p->features & AHC_ULTRA2)
     brdctl = BRDRW_ULTRA2;
-  else
-    brdctl = BRDRW | BRDCS;
+    aic_outb(p, brdctl, BRDCTL);
+    udelay(4);
+    return(aic_inb(p, BRDCTL));
+  }
+  brdctl = BRDRW;
+  if ( !((p->chip & AHC_CHIPID_MASK) == AHC_AIC7895) ||
+        (p->flags & AHC_CHNLB) )
+  {
+    brdctl |= BRDCS;
+  }
   aic_outb(p, brdctl, BRDCTL);
-  udelay(10);
-  return (aic_inb(p, BRDCTL));
+  udelay(1);
+  value = aic_inb(p, BRDCTL);
+  aic_outb(p, 0, BRDCTL);
+  udelay(1);
+  return (value);
 }
 
 /*+F*************************************************************************
@@ -7448,41 +7454,40 @@
 {
   unsigned char brdctl;
 
-  if ((p->chip & AHC_CHIPID_MASK) == AHC_AIC7895)
+  if (p->features & AHC_ULTRA2)
   {
-    brdctl = BRDSTB;
-    if (p->flags & AHC_CHNLB)
-      brdctl |= BRDCS;
+    brdctl = value;
     aic_outb(p, brdctl, BRDCTL);
     udelay(4);
-    brdctl |= value;
-  }
-  else if (p->features & AHC_ULTRA2)
-  {
-    brdctl = value;
+    brdctl |= BRDSTB_ULTRA2;
+    aic_outb(p, brdctl, BRDCTL);
+    udelay(4);
+    brdctl &= ~BRDSTB_ULTRA2;
+    aic_outb(p, brdctl, BRDCTL);
+    udelay(4);
+    read_brdctl(p);
   }
   else
   {
+    brdctl = BRDSTB;
+    if ( !((p->chip & AHC_CHIPID_MASK) == AHC_AIC7895) ||
+          (p->flags & AHC_CHNLB) )
+    {
+      brdctl |= BRDCS;
+    }
     brdctl = BRDSTB | BRDCS;
     aic_outb(p, brdctl, BRDCTL);
-    udelay(4);
+    udelay(1);
     brdctl |= value;
-  }
-  aic_outb(p, brdctl, BRDCTL);
-  udelay(4);
-  if (p->features & AHC_ULTRA2)
-    brdctl |= BRDSTB_ULTRA2;
-  else
+    aic_outb(p, brdctl, BRDCTL);
+    udelay(1);
     brdctl &= ~BRDSTB;
-  aic_outb(p, brdctl, BRDCTL);
-  udelay(4);
-  if (p->features & AHC_ULTRA2)
-    brdctl &= ~BRDSTB_ULTRA2;
-  else
+    aic_outb(p, brdctl, BRDCTL);
+    udelay(1);
     brdctl &= ~BRDCS;
-  aic_outb(p, brdctl, BRDCTL);
-  udelay(4);
-  read_brdctl(p);
+    aic_outb(p, brdctl, BRDCTL);
+    udelay(1);
+  }
 }
 
 /*+F*************************************************************************
@@ -7499,10 +7504,11 @@
   unsigned char brdctl;
 
   aic_outb(p, BRDRW | BRDCS, BRDCTL);
-  udelay(4);
+  udelay(1);
   aic_outb(p, 0, BRDCTL);
-  udelay(4);
+  udelay(1);
   brdctl = aic_inb(p, BRDCTL);
+  udelay(1);
   *int_50 = !(brdctl & BRDDAT5);
   *ext_present = !(brdctl & BRDDAT6);
   *eeprom = (aic_inb(p, SPIOCAP) & EEPROM);
@@ -7611,7 +7617,6 @@
     else
       max_target = 8;
     aic_outb(p, SEEMS | SEECS, SEECTL);
-    udelay(4);
     sxfrctl1 &= ~STPWEN;
     if ( (p->adapter_control & CFAUTOTERM) ||
          (p->features & AHC_ULTRA2) )
@@ -7736,14 +7741,6 @@
                  p->host_no);
       }
 
-      if (enableLVD_high != 0)
-      {
-        brddat |= BRDDAT4;
-        if (aic7xxx_verbose & VERBOSE_PROBE2)
-          printk(KERN_INFO "(scsi%d) LVD High byte termination Enabled\n",
-                 p->host_no);
-      }
-          
       if (enableLVD_low != 0)
       {
         sxfrctl1 |= STPWEN;
@@ -7752,17 +7749,17 @@
           printk(KERN_INFO "(scsi%d) LVD Low byte termination Enabled\n",
                  p->host_no);
       }
-    }
-    else
-    {
-      if (p->adapter_control & CFWSTERM)
+          
+      if (enableLVD_high != 0)
       {
-        brddat |= BRDDAT6;
+        brddat |= BRDDAT4;
         if (aic7xxx_verbose & VERBOSE_PROBE2)
-          printk(KERN_INFO "(scsi%d) SE High byte termination Enabled\n",
+          printk(KERN_INFO "(scsi%d) LVD High byte termination Enabled\n",
                  p->host_no);
       }
-
+    }
+    else
+    {
       if (p->adapter_control & CFSTERM)
       {
         if (p->features & AHC_ULTRA2)
@@ -7773,6 +7770,14 @@
           printk(KERN_INFO "(scsi%d) SE Low byte termination Enabled\n",
                  p->host_no);
       }
+
+      if (p->adapter_control & CFWSTERM)
+      {
+        brddat |= BRDDAT6;
+        if (aic7xxx_verbose & VERBOSE_PROBE2)
+          printk(KERN_INFO "(scsi%d) SE High byte termination Enabled\n",
+                 p->host_no);
+      }
     }
     aic_outb(p, sxfrctl1, SXFRCTL1);
     write_brdctl(p, brddat);
@@ -8090,7 +8095,11 @@
     /* Select channel B */
     aic_outb(p, aic_inb(p, SBLKCTL) | SELBUSB, SBLKCTL);
 
-    term = (aic_inb(p, SXFRCTL1) & STPWEN);
+    if ((p->flags & AHC_SEEPROM_FOUND) || (aic7xxx_override_term != -1))
+      term = (aic_inb(p, SXFRCTL1) & STPWEN);
+    else
+      term = ((p->flags & AHC_TERM_ENB_B) ? STPWEN : 0);
+
     aic_outb(p, p->scsi_id_b, SCSIID);
     scsi_conf = aic_inb(p, SCSICONF + 1);
     aic_outb(p, DFON | SPIOEN, SXFRCTL0);
@@ -8112,7 +8121,10 @@
   {
     aic_outb(p, p->scsi_id, SCSIID);
   }
-  term = (aic_inb(p, SXFRCTL1) & STPWEN);
+  if ((p->flags & AHC_SEEPROM_FOUND) || (aic7xxx_override_term != -1))
+    term = (aic_inb(p, SXFRCTL1) & STPWEN);
+  else
+    term = ((p->flags & (AHC_TERM_ENB_A|AHC_TERM_ENB_LVD)) ? STPWEN : 0);
   scsi_conf = aic_inb(p, SCSICONF);
   aic_outb(p, DFON | SPIOEN, SXFRCTL0);
   aic_outb(p, (scsi_conf & ENSPCHK) | STIMESEL | term | 
@@ -9049,11 +9061,44 @@
 
 
 #if defined(__i386__) || defined(__alpha__)
+#ifdef CONFIG_PCI
+  /*
+   * PCI-bus chipset probe.
+   */
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,1,92)
+  if (pci_present())
+  {
+    if (pci_find_device(PCI_VENDOR_ID_INTEL,
+                        PCI_DEVICE_ID_INTEL_82450GX,
+                        NULL))
+      aic7xxx_no_probe = 1;
+    if (pci_find_device(PCI_VENDOR_ID_INTEL,
+                        PCI_DEVICE_ID_INTEL_82451NX,
+                        NULL))
+      aic7xxx_no_probe = 1;
+  }
+#else
+#define PCI_DEVICE_ID_INTEL_82451NX 0x84ca
+  if (pcibios_present())
+  {
+    unsigned char pci_bus, pci_devfn;
+    if (!(pcibios_find_device(PCI_VENDOR_ID_INTEL,
+                              PCI_DEVICE_ID_INTEL_82450GX,
+                              0, &pci_bus, &pci_devfn)) )
+      aic7xxx_no_probe = 1;
+    if (!(pcibios_find_device(PCI_VENDOR_ID_INTEL,
+                              PCI_DEVICE_ID_INTEL_82451NX,
+                              0, &pci_bus, &pci_devfn)) )
+      aic7xxx_no_probe = 1;
+  }
+#endif /* LINUX_VERSION_CODE */
+#endif /* CONFIG_PCI */
   /*
    * EISA/VL-bus card signature probe.
    */
   slot = MINSLOT;
-  while ( (slot <= MAXSLOT) && !(aic7xxx_no_probe) )
+  while ( (slot <= MAXSLOT) && 
+         !(aic7xxx_no_probe) )
   {
     base = SLOTBASE(slot) + MINREG;
 
@@ -9311,6 +9356,10 @@
        AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED,
        AHC_AIC7860_FE,                                       7,
        32, C46 },
+      {PCI_VENDOR_ID_ADAPTEC, PCI_DEVICE_ID_ADAPTEC_38602, AHC_AIC7860,
+       AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED,
+       AHC_AIC7860_FE,                                       7,
+       32, C46 },
       {PCI_VENDOR_ID_ADAPTEC, PCI_DEVICE_ID_ADAPTEC_7860, AHC_AIC7860,
        AHC_PAGESCBS | AHC_NEWEEPROM_FMT | AHC_BIOS_ENABLED,
        AHC_AIC7860_FE,                                       7,
@@ -9489,6 +9538,23 @@
           temp_p->pci_device_fn = pdev->devfn;
           temp_p->base = pdev->base_address[0];
           temp_p->mbase = pdev->base_address[1];
+          temp_p->base &= PCI_BASE_ADDRESS_IO_MASK;
+          temp_p->mbase &= PCI_BASE_ADDRESS_MEM_MASK;
+          current_p = list_p;
+	  while(current_p)
+	  {
+	    if ( ((current_p->pci_bus == temp_p->pci_bus) &&
+	          (current_p->pci_device_fn == temp_p->pci_device_fn)) ||
+                  (current_p->base == temp_p->base) )
+	    {
+              /* duplicate PCI entry, skip it */
+	      kfree(temp_p);
+	      temp_p = NULL;
+	    }
+	    current_p = current_p->next;
+	  }
+	  if ( temp_p == NULL )
+            continue;
           if (aic7xxx_verbose & VERBOSE_PROBE2)
             printk("aic7xxx: <%s> at PCI %d/%d\n", 
               board_names[aic_pdevs[i].board_name_index],
@@ -9522,11 +9588,6 @@
 #else  /* LINUX_VERSION_CODE > KERNEL_VERSION(2,1,92) */
           temp_p->pci_bus = pci_bus;
           temp_p->pci_device_fn = pci_devfn;
-          if (aic7xxx_verbose & VERBOSE_PROBE2)
-            printk("aic7xxx: <%s> at PCI %d/%d\n", 
-              board_names[aic_pdevs[i].board_name_index],
-              PCI_SLOT(temp_p->pci_device_fn),
-              PCI_FUNC(temp_p->pci_device_fn));
           pcibios_read_config_byte(pci_bus, pci_devfn, PCI_INTERRUPT_LINE,
             &pci_irq);
           temp_p->irq = pci_irq;
@@ -9536,6 +9597,28 @@
           pcibios_read_config_dword(pci_bus, pci_devfn, PCI_BASE_ADDRESS_1,
             &mmapbase);
           temp_p->mbase = mmapbase;
+          temp_p->base &= PCI_BASE_ADDRESS_IO_MASK;
+          temp_p->mbase &= PCI_BASE_ADDRESS_MEM_MASK;
+          current_p = list_p;
+	  while(current_p)
+	  {
+	    if ( ((current_p->pci_bus == temp_p->pci_bus) &&
+	          (current_p->pci_device_fn == temp_p->pci_device_fn)) ||
+                  (current_p->base == temp_p->base) )
+	    {
+              /* duplicate PCI entry, skip it */
+	      kfree(temp_p);
+	      temp_p = NULL;
+	    }
+	    current_p = current_p->next;
+	  }
+	  if ( temp_p == NULL )
+            continue;
+          if (aic7xxx_verbose & VERBOSE_PROBE2)
+            printk("aic7xxx: <%s> at PCI %d/%d\n", 
+              board_names[aic_pdevs[i].board_name_index],
+              PCI_SLOT(temp_p->pci_device_fn),
+              PCI_FUNC(temp_p->pci_device_fn));
           pcibios_read_config_word(pci_bus, pci_devfn, PCI_COMMAND, &command);
           if (aic7xxx_verbose & VERBOSE_PROBE2)
           {
@@ -9563,12 +9646,6 @@
 #endif /* AIC7XXX_STRICT_PCI_SETUP */
 #endif /* LINUIX_VERSION_CODE > KERNEL_VERSION(2,1,92) */
 
-          /*
-           * The first bit (LSB) of PCI_BASE_ADDRESS_0 is always set, so
-           * we mask it off.
-           */
-          temp_p->base &= PCI_BASE_ADDRESS_IO_MASK;
-          temp_p->mbase &= PCI_BASE_ADDRESS_MEM_MASK;
           temp_p->unpause = INTEN;
           temp_p->pause = temp_p->unpause | PAUSE;
           if ( ((temp_p->base == 0) &&
@@ -9586,6 +9663,9 @@
           }
 
 #ifdef MMAPIO
+          if ( !(temp_p->flags & AHC_MULTI_CHANNEL) ||
+               ((temp_p->chip != (AHC_AIC7870 | AHC_PCI)) &&
+                (temp_p->chip != (AHC_AIC7880 | AHC_PCI))) )
           {
             unsigned long page_offset, base;
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)