Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci PCI frontend for new ahc driver.



details:   https://anonhg.NetBSD.org/src/rev/b3abe6cd8b58
branches:  trunk
changeset: 483658:b3abe6cd8b58
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Wed Mar 15 02:33:52 2000 +0000

description:
PCI frontend for new ahc driver.

diffstat:

 sys/dev/pci/ahc_pci.c |  1377 +++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 1120 insertions(+), 257 deletions(-)

diffs (truncated from 1509 to 300 lines):

diff -r 53cc2e5b0c3f -r b3abe6cd8b58 sys/dev/pci/ahc_pci.c
--- a/sys/dev/pci/ahc_pci.c     Wed Mar 15 02:28:42 2000 +0000
+++ b/sys/dev/pci/ahc_pci.c     Wed Mar 15 02:33:52 2000 +0000
@@ -1,24 +1,25 @@
-/*     $NetBSD: ahc_pci.c,v 1.21 2000/01/26 06:44:18 thorpej Exp $     */
+/*     $NetBSD: ahc_pci.c,v 1.22 2000/03/15 02:33:52 fvdl Exp $        */
 
 /*
  * Product specific probe and attach routines for:
- *      3940, 2940, aic7880, aic7870, aic7860 and aic7850 SCSI controllers
+ *      3940, 2940, aic7895, aic7890, aic7880,
+ *     aic7870, aic7860 and aic7850 SCSI controllers
  *
- * Copyright (c) 1995, 1996 Justin T. Gibbs.
+ * Copyright (c) 1994, 1995, 1996, 1997, 1998, 1999, 2000 Justin T. Gibbs.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
- *    notice immediately at the beginning of the file, without modification,
- *    this list of conditions, and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. The name of the author may not be used to endorse or promote products
  *    derived from this software without specific prior written permission.
  *
+ * Alternatively, this software may be distributed under the terms of the
+ * the GNU Public License ("GPL").
+ *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -31,7 +32,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * from        Id: aic7870.c,v 1.37 1996/06/08 06:55:55 gibbs Exp
+ * $FreeBSD: src/sys/dev/aic7xxx/ahc_pci.c,v 1.28 2000/02/09 21:00:22 gibbs Exp $
  */
 
 #include <sys/param.h>
@@ -44,216 +45,681 @@
 #include <machine/bus.h>
 #include <machine/intr.h>
 
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcivar.h>
+
+/* XXXX some i386 on-board chips act weird when memory-mapped */
+#ifndef __i386__
+#define AHC_ALLOW_MEMIO
+#endif
+
+#define AHC_PCI_IOADDR PCI_MAPREG_START        /* I/O Address */
+#define AHC_PCI_MEMADDR        (PCI_MAPREG_START + 4)  /* Mem I/O Address */
+
 #include <dev/scsipi/scsi_all.h>
 #include <dev/scsipi/scsipi_all.h>
 #include <dev/scsipi/scsiconf.h>
 
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcivar.h>
+#include <dev/ic/aic7xxxvar.h>
+#include <dev/ic/smc93cx6var.h>
 
-#include <dev/ic/aic7xxxreg.h>
-#include <dev/ic/aic7xxxvar.h>
+#include <dev/microcode/aic7xxx/aic7xxx_reg.h>
 
-/*
- * Under normal circumstances, these messages are unnecessary
- * and not terribly cosmetic.
- */
 #ifdef DEBUG
-#define bootverbose    1
+#define bootverbose 1
 #else
-#define bootverbose    0
+#define bootverbose 1
 #endif
 
-#define PCI_BASEADR_IO 0x10
-#define PCI_BASEADR_MEM        0x14
+struct ahc_pci_busdata {
+       pci_chipset_tag_t pc;
+       pcitag_t tag;
+       u_int dev;
+       u_int func;
+};
+
+static __inline u_int64_t
+ahc_compose_id(u_int device, u_int vendor, u_int subdevice, u_int subvendor)
+{
+       u_int64_t id;
+
+       id = subvendor
+          | (subdevice << 16)
+          | ((u_int64_t)vendor << 32)
+          | ((u_int64_t)device << 48);
+
+       return (id);
+}
+
+#define ID_ALL_MASK            0xFFFFFFFFFFFFFFFFull
+#define ID_DEV_VENDOR_MASK     0xFFFFFFFF00000000ull
+#define ID_AIC7850             0x5078900400000000ull
+#define ID_AHA_2910_15_20_30C  0x5078900478509004ull
+#define ID_AIC7855             0x5578900400000000ull
+#define ID_AIC7859             0x3860900400000000ull
+#define ID_AHA_2930CU          0x3860900438699004ull
+#define ID_AIC7860             0x6078900400000000ull
+#define ID_AIC7860C            0x6078900478609004ull
+#define ID_AHA_2940AU_0                0x6178900400000000ull
+#define ID_AHA_2940AU_1                0x6178900478619004ull
+#define ID_AHA_2940AU_CN       0x2178900478219004ull
+#define ID_AHA_2930C_VAR       0x6038900438689004ull
+
+#define ID_AIC7870             0x7078900400000000ull
+#define ID_AHA_2940            0x7178900400000000ull
+#define ID_AHA_3940            0x7278900400000000ull
+#define ID_AHA_398X            0x7378900400000000ull
+#define ID_AHA_2944            0x7478900400000000ull
+#define ID_AHA_3944            0x7578900400000000ull
+
+#define ID_AIC7880             0x8078900400000000ull
+#define ID_AIC7880_B           0x8078900478809004ull
+#define ID_AHA_2940U           0x8178900400000000ull
+#define ID_AHA_3940U           0x8278900400000000ull
+#define ID_AHA_2944U           0x8478900400000000ull
+#define ID_AHA_3944U           0x8578900400000000ull
+#define ID_AHA_398XU           0x8378900400000000ull
+#define ID_AHA_4944U           0x8678900400000000ull
+#define ID_AHA_2940UB          0x8178900478819004ull
+#define ID_AHA_2930U           0x8878900478889004ull
+#define ID_AHA_2940U_PRO       0x8778900478879004ull
+#define ID_AHA_2940U_CN                0x0078900478009004ull
+
+#define ID_AIC7895             0x7895900478959004ull
+#define ID_AIC7895_RAID_PORT   0x7893900478939004ull
+#define ID_AHA_2940U_DUAL      0x7895900478919004ull
+#define ID_AHA_3940AU          0x7895900478929004ull
+#define ID_AHA_3944AU          0x7895900478949004ull
+
+#define ID_AIC7890             0x001F9005000F9005ull
+#define ID_AHA_2930U2          0x0011900501819005ull
+#define ID_AHA_2940U2B         0x00109005A1009005ull
+#define ID_AHA_2940U2_OEM      0x0010900521809005ull
+#define ID_AHA_2940U2          0x00109005A1809005ull
+#define ID_AHA_2950U2B         0x00109005E1009005ull
+
+#define ID_AIC7892             0x008F9005FFFF9005ull
+#define ID_AHA_29160           0x00809005E2A09005ull
+#define ID_AHA_29160_CPQ       0x00809005E2A00E11ull
+#define ID_AHA_29160N          0x0080900562A09005ull
+#define ID_AHA_29160B          0x00809005E2209005ull
+#define ID_AHA_19160B          0x0081900562A19005ull
+
+#define ID_AIC7896             0x005F9005FFFF9005ull
+#define ID_AHA_3950U2B_0       0x00509005FFFF9005ull
+#define ID_AHA_3950U2B_1       0x00509005F5009005ull
+#define ID_AHA_3950U2D_0       0x00519005FFFF9005ull
+#define ID_AHA_3950U2D_1       0x00519005B5009005ull
+
+#define ID_AIC7899             0x00CF9005FFFF9005ull
+#define ID_AHA_3960D           0x00C09005F6209005ull /* AKA AHA-39160 */
+#define ID_AHA_3960D_CPQ       0x00C09005F6200E11ull
+
+#define ID_AIC7810             0x1078900400000000ull
+#define ID_AIC7815             0x1578900400000000ull
+
+typedef int (ahc_device_setup_t)(struct pci_attach_args *, char *,
+                                ahc_chip *, ahc_feature *, ahc_flag *);
+
+static ahc_device_setup_t ahc_aic7850_setup;
+static ahc_device_setup_t ahc_aic7855_setup;
+static ahc_device_setup_t ahc_aic7859_setup;
+static ahc_device_setup_t ahc_aic7860_setup;
+static ahc_device_setup_t ahc_aic7870_setup;
+static ahc_device_setup_t ahc_aha394X_setup;
+static ahc_device_setup_t ahc_aha398X_setup;
+static ahc_device_setup_t ahc_aic7880_setup;
+static ahc_device_setup_t ahc_2940Pro_setup;
+static ahc_device_setup_t ahc_aha394XU_setup;
+static ahc_device_setup_t ahc_aha398XU_setup;
+static ahc_device_setup_t ahc_aic7890_setup;
+static ahc_device_setup_t ahc_aic7892_setup;
+static ahc_device_setup_t ahc_aic7895_setup;
+static ahc_device_setup_t ahc_aic7896_setup;
+static ahc_device_setup_t ahc_aic7899_setup;
+static ahc_device_setup_t ahc_raid_setup;
+static ahc_device_setup_t ahc_aha394XX_setup;
+static ahc_device_setup_t ahc_aha398XX_setup;
+
+struct ahc_pci_identity {
+       u_int64_t                full_id;
+       u_int64_t                id_mask;
+       char                    *name;
+       ahc_device_setup_t      *setup;
+};
 
-#define PCI_DEVICE_ID_ADAPTEC_3940U    0x82789004ul
-#define PCI_DEVICE_ID_ADAPTEC_2944U    0x84789004ul
-#define PCI_DEVICE_ID_ADAPTEC_2940U    0x81789004ul
-#define PCI_DEVICE_ID_ADAPTEC_2940UP   0x87789004ul
-#define PCI_DEVICE_ID_ADAPTEC_2940AU   0x61789004ul
-#define PCI_DEVICE_ID_ADAPTEC_3940     0x72789004ul
-#define PCI_DEVICE_ID_ADAPTEC_2944     0x74789004ul
-#define PCI_DEVICE_ID_ADAPTEC_2940     0x71789004ul
-#define PCI_DEVICE_ID_ADAPTEC_AIC7880  0x80789004ul
-#define PCI_DEVICE_ID_ADAPTEC_AIC7870  0x70789004ul
-#define PCI_DEVICE_ID_ADAPTEC_AIC7860  0x60789004ul
-#define PCI_DEVICE_ID_ADAPTEC_AIC7855  0x55789004ul
-#define PCI_DEVICE_ID_ADAPTEC_AIC7850  0x50789004ul
+struct ahc_pci_identity ahc_pci_ident_table [] =
+{
+       /* aic7850 based controllers */
+       {
+               ID_AHA_2910_15_20_30C,
+               ID_ALL_MASK,
+               "Adaptec 2910/15/20/30C SCSI adapter",
+               ahc_aic7850_setup
+       },
+       /* aic7859 based controllers */
+       {
+               ID_AHA_2930CU,
+               ID_ALL_MASK,
+               "Adaptec 2930CU SCSI adapter",
+               ahc_aic7859_setup
+       },
+       /* aic7860 based controllers */
+       {
+               ID_AHA_2940AU_0 & ID_DEV_VENDOR_MASK,
+               ID_DEV_VENDOR_MASK,
+               "Adaptec 2940A Ultra SCSI adapter",
+               ahc_aic7860_setup
+       },
+       {
+               ID_AHA_2940AU_CN & ID_DEV_VENDOR_MASK,
+               ID_DEV_VENDOR_MASK,
+               "Adaptec 2940A/CN Ultra SCSI adapter",
+               ahc_aic7860_setup
+       },
+       {
+               ID_AHA_2930C_VAR & ID_DEV_VENDOR_MASK,
+               ID_DEV_VENDOR_MASK,
+               "Adaptec 2930C SCSI adapter (VAR)",
+               ahc_aic7860_setup
+       },
+       /* aic7870 based controllers */
+       {
+               ID_AHA_2940,
+               ID_ALL_MASK,
+               "Adaptec 2940 SCSI adapter",
+               ahc_aic7870_setup
+       },
+       {
+               ID_AHA_3940,
+               ID_ALL_MASK,
+               "Adaptec 3940 SCSI adapter",
+               ahc_aha394X_setup
+       },
+       {
+               ID_AHA_398X,
+               ID_ALL_MASK,
+               "Adaptec 398X SCSI RAID adapter",
+               ahc_aha398X_setup
+       },
+       {
+               ID_AHA_2944,
+               ID_ALL_MASK,
+               "Adaptec 2944 SCSI adapter",
+               ahc_aic7870_setup
+       },
+       {
+               ID_AHA_3944,
+               ID_ALL_MASK,
+               "Adaptec 3944 SCSI adapter",
+               ahc_aha394X_setup
+       },
+       /* aic7880 based controllers */
+       {
+               ID_AHA_2940U & ID_DEV_VENDOR_MASK,
+               ID_DEV_VENDOR_MASK,
+               "Adaptec 2940 Ultra SCSI adapter",
+               ahc_aic7880_setup
+       },
+       {
+               ID_AHA_3940U & ID_DEV_VENDOR_MASK,
+               ID_DEV_VENDOR_MASK,
+               "Adaptec 3940 Ultra SCSI adapter",
+               ahc_aha394XU_setup
+       },
+       {
+               ID_AHA_2944U & ID_DEV_VENDOR_MASK,



Home | Main Index | Thread Index | Old Index