Home | History | Annotate | Line # | Download | only in pci
isp_pci.c revision 1.45.2.6
      1  1.45.2.3   bouyer /* $NetBSD: isp_pci.c,v 1.45.2.6 2001/01/05 17:36:09 bouyer Exp $ */
      2  1.45.2.2   bouyer /*
      3  1.45.2.2   bouyer  * This driver, which is contained in NetBSD in the files:
      4  1.45.2.2   bouyer  *
      5  1.45.2.2   bouyer  *	sys/dev/ic/isp.c
      6  1.45.2.6   bouyer  *	sys/dev/ic/isp_inline.h
      7  1.45.2.6   bouyer  *	sys/dev/ic/isp_netbsd.c
      8  1.45.2.6   bouyer  *	sys/dev/ic/isp_netbsd.h
      9  1.45.2.6   bouyer  *	sys/dev/ic/isp_target.c
     10  1.45.2.6   bouyer  *	sys/dev/ic/isp_target.h
     11  1.45.2.6   bouyer  *	sys/dev/ic/isp_tpublic.h
     12  1.45.2.6   bouyer  *	sys/dev/ic/ispmbox.h
     13  1.45.2.6   bouyer  *	sys/dev/ic/ispreg.h
     14  1.45.2.6   bouyer  *	sys/dev/ic/ispvar.h
     15  1.45.2.2   bouyer  *	sys/microcode/isp/asm_sbus.h
     16  1.45.2.2   bouyer  *	sys/microcode/isp/asm_1040.h
     17  1.45.2.2   bouyer  *	sys/microcode/isp/asm_1080.h
     18  1.45.2.2   bouyer  *	sys/microcode/isp/asm_12160.h
     19  1.45.2.2   bouyer  *	sys/microcode/isp/asm_2100.h
     20  1.45.2.2   bouyer  *	sys/microcode/isp/asm_2200.h
     21  1.45.2.2   bouyer  *	sys/pci/isp_pci.c
     22  1.45.2.2   bouyer  *	sys/sbus/isp_sbus.c
     23  1.45.2.2   bouyer  *
     24  1.45.2.2   bouyer  * Is being actively maintained by Matthew Jacob (mjacob (at) netbsd.org).
     25  1.45.2.2   bouyer  * This driver also is shared source with FreeBSD, OpenBSD, Linux, Solaris,
     26  1.45.2.2   bouyer  * Linux versions. This tends to be an interesting maintenance problem.
     27  1.45.2.2   bouyer  *
     28  1.45.2.2   bouyer  * Please coordinate with Matthew Jacob on changes you wish to make here.
     29  1.45.2.2   bouyer  */
     30       1.1      cgd /*
     31       1.1      cgd  * PCI specific probe and attach routines for Qlogic ISP SCSI adapters.
     32      1.41   mjacob  * Matthew Jacob (mjacob (at) nas.nasa.gov)
     33      1.41   mjacob  */
     34      1.41   mjacob /*
     35      1.41   mjacob  * Copyright (C) 1997, 1998, 1999 National Aeronautics & Space Administration
     36       1.1      cgd  * All rights reserved.
     37       1.1      cgd  *
     38       1.1      cgd  * Redistribution and use in source and binary forms, with or without
     39       1.1      cgd  * modification, are permitted provided that the following conditions
     40       1.1      cgd  * are met:
     41       1.1      cgd  * 1. Redistributions of source code must retain the above copyright
     42      1.41   mjacob  *    notice, this list of conditions and the following disclaimer.
     43       1.1      cgd  * 2. Redistributions in binary form must reproduce the above copyright
     44       1.1      cgd  *    notice, this list of conditions and the following disclaimer in the
     45       1.1      cgd  *    documentation and/or other materials provided with the distribution.
     46       1.1      cgd  * 3. The name of the author may not be used to endorse or promote products
     47      1.41   mjacob  *    derived from this software without specific prior written permission
     48      1.21   mjacob  *
     49      1.41   mjacob  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     50      1.41   mjacob  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     51      1.41   mjacob  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     52      1.41   mjacob  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     53      1.41   mjacob  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     54      1.41   mjacob  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     55      1.41   mjacob  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     56      1.41   mjacob  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     57      1.41   mjacob  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     58      1.41   mjacob  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     59       1.1      cgd  */
     60       1.1      cgd 
     61      1.21   mjacob #include <dev/ic/isp_netbsd.h>
     62       1.1      cgd #include <dev/pci/pcireg.h>
     63       1.1      cgd #include <dev/pci/pcivar.h>
     64       1.1      cgd #include <dev/pci/pcidevs.h>
     65  1.45.2.4   bouyer #include <uvm/uvm_extern.h>
     66  1.45.2.6   bouyer #include <sys/reboot.h>
     67       1.3      cgd 
     68       1.1      cgd static u_int16_t isp_pci_rd_reg __P((struct ispsoftc *, int));
     69       1.1      cgd static void isp_pci_wr_reg __P((struct ispsoftc *, int, u_int16_t));
     70  1.45.2.2   bouyer #if !(defined(ISP_DISABLE_1080_SUPPORT) && defined(ISP_DISABLE_12160_SUPPORT))
     71      1.36   mjacob static u_int16_t isp_pci_rd_reg_1080 __P((struct ispsoftc *, int));
     72      1.36   mjacob static void isp_pci_wr_reg_1080 __P((struct ispsoftc *, int, u_int16_t));
     73      1.36   mjacob #endif
     74      1.13  thorpej static int isp_pci_mbxdma __P((struct ispsoftc *));
     75      1.16   bouyer static int isp_pci_dmasetup __P((struct ispsoftc *, struct scsipi_xfer *,
     76  1.45.2.2   bouyer 	ispreq_t *, u_int16_t *, u_int16_t));
     77      1.16   bouyer static void isp_pci_dmateardown __P((struct ispsoftc *, struct scsipi_xfer *,
     78      1.13  thorpej 	u_int32_t));
     79       1.1      cgd static void isp_pci_reset1 __P((struct ispsoftc *));
     80  1.45.2.2   bouyer static void isp_pci_dumpregs __P((struct ispsoftc *, const char *));
     81      1.26   mjacob static int isp_pci_intr __P((void *));
     82       1.1      cgd 
     83  1.45.2.2   bouyer #if	defined(ISP_DISABLE_1020_SUPPORT)
     84  1.45.2.2   bouyer #define	ISP_1040_RISC_CODE	NULL
     85  1.45.2.2   bouyer #else
     86  1.45.2.2   bouyer #define	ISP_1040_RISC_CODE	isp_1040_risc_code
     87  1.45.2.2   bouyer #include <dev/microcode/isp/asm_1040.h>
     88  1.45.2.2   bouyer #endif
     89  1.45.2.2   bouyer 
     90  1.45.2.2   bouyer #if	defined(ISP_DISABLE_1080_SUPPORT)
     91  1.45.2.2   bouyer #define	ISP_1080_RISC_CODE	NULL
     92  1.45.2.2   bouyer #else
     93  1.45.2.2   bouyer #define	ISP_1080_RISC_CODE	isp_1080_risc_code
     94  1.45.2.2   bouyer #include <dev/microcode/isp/asm_1080.h>
     95  1.45.2.2   bouyer #endif
     96  1.45.2.2   bouyer 
     97  1.45.2.2   bouyer #if	defined(ISP_DISABLE_12160_SUPPORT)
     98  1.45.2.2   bouyer #define	ISP_12160_RISC_CODE	NULL
     99  1.45.2.2   bouyer #else
    100  1.45.2.2   bouyer #define	ISP_12160_RISC_CODE	isp_12160_risc_code
    101  1.45.2.2   bouyer #include <dev/microcode/isp/asm_12160.h>
    102  1.45.2.2   bouyer #endif
    103  1.45.2.2   bouyer 
    104  1.45.2.2   bouyer #if	defined(ISP_DISABLE_2100_SUPPORT)
    105  1.45.2.2   bouyer #define	ISP_2100_RISC_CODE	NULL
    106  1.45.2.2   bouyer #else
    107  1.45.2.2   bouyer #define	ISP_2100_RISC_CODE	isp_2100_risc_code
    108  1.45.2.2   bouyer #include <dev/microcode/isp/asm_2100.h>
    109  1.45.2.2   bouyer #endif
    110  1.45.2.2   bouyer 
    111  1.45.2.2   bouyer #if	defined(ISP_DISABLE_2200_SUPPORT)
    112  1.45.2.2   bouyer #define	ISP_2200_RISC_CODE	NULL
    113  1.45.2.2   bouyer #else
    114  1.45.2.2   bouyer #define	ISP_2200_RISC_CODE	isp_2200_risc_code
    115  1.45.2.2   bouyer #include <dev/microcode/isp/asm_2200.h>
    116  1.45.2.2   bouyer #endif
    117  1.45.2.2   bouyer 
    118      1.36   mjacob #ifndef	ISP_DISABLE_1020_SUPPORT
    119       1.1      cgd static struct ispmdvec mdvec = {
    120       1.1      cgd 	isp_pci_rd_reg,
    121       1.1      cgd 	isp_pci_wr_reg,
    122       1.1      cgd 	isp_pci_mbxdma,
    123       1.1      cgd 	isp_pci_dmasetup,
    124      1.13  thorpej 	isp_pci_dmateardown,
    125       1.1      cgd 	NULL,
    126       1.1      cgd 	isp_pci_reset1,
    127      1.15   mjacob 	isp_pci_dumpregs,
    128  1.45.2.2   bouyer 	ISP_1040_RISC_CODE,
    129  1.45.2.2   bouyer 	BIU_BURST_ENABLE|BIU_PCI_CONF1_FIFO_64
    130      1.15   mjacob };
    131      1.36   mjacob #endif
    132      1.36   mjacob 
    133      1.36   mjacob #ifndef	ISP_DISABLE_1080_SUPPORT
    134      1.36   mjacob static struct ispmdvec mdvec_1080 = {
    135      1.36   mjacob 	isp_pci_rd_reg_1080,
    136      1.36   mjacob 	isp_pci_wr_reg_1080,
    137      1.36   mjacob 	isp_pci_mbxdma,
    138      1.36   mjacob 	isp_pci_dmasetup,
    139      1.36   mjacob 	isp_pci_dmateardown,
    140      1.36   mjacob 	NULL,
    141      1.36   mjacob 	isp_pci_reset1,
    142      1.36   mjacob 	isp_pci_dumpregs,
    143  1.45.2.2   bouyer 	ISP_1080_RISC_CODE,
    144  1.45.2.2   bouyer 	BIU_BURST_ENABLE|BIU_PCI_CONF1_FIFO_64
    145  1.45.2.2   bouyer };
    146  1.45.2.2   bouyer #endif
    147  1.45.2.2   bouyer 
    148  1.45.2.2   bouyer #ifndef	ISP_DISABLE_12160_SUPPORT
    149  1.45.2.2   bouyer static struct ispmdvec mdvec_12160 = {
    150  1.45.2.2   bouyer 	isp_pci_rd_reg_1080,
    151  1.45.2.2   bouyer 	isp_pci_wr_reg_1080,
    152  1.45.2.2   bouyer 	isp_pci_mbxdma,
    153  1.45.2.2   bouyer 	isp_pci_dmasetup,
    154  1.45.2.2   bouyer 	isp_pci_dmateardown,
    155  1.45.2.2   bouyer 	NULL,
    156  1.45.2.2   bouyer 	isp_pci_reset1,
    157  1.45.2.2   bouyer 	isp_pci_dumpregs,
    158  1.45.2.2   bouyer 	ISP_12160_RISC_CODE,
    159  1.45.2.2   bouyer 	BIU_BURST_ENABLE|BIU_PCI_CONF1_FIFO_64
    160      1.36   mjacob };
    161      1.36   mjacob #endif
    162      1.15   mjacob 
    163      1.36   mjacob #ifndef	ISP_DISABLE_2100_SUPPORT
    164      1.15   mjacob static struct ispmdvec mdvec_2100 = {
    165      1.15   mjacob 	isp_pci_rd_reg,
    166      1.15   mjacob 	isp_pci_wr_reg,
    167      1.15   mjacob 	isp_pci_mbxdma,
    168      1.15   mjacob 	isp_pci_dmasetup,
    169      1.15   mjacob 	isp_pci_dmateardown,
    170      1.15   mjacob 	NULL,
    171      1.15   mjacob 	isp_pci_reset1,
    172      1.15   mjacob 	isp_pci_dumpregs,
    173  1.45.2.2   bouyer 	ISP_2100_RISC_CODE
    174       1.1      cgd };
    175      1.36   mjacob #endif
    176       1.1      cgd 
    177      1.41   mjacob #ifndef	ISP_DISABLE_2200_SUPPORT
    178      1.41   mjacob static struct ispmdvec mdvec_2200 = {
    179      1.41   mjacob 	isp_pci_rd_reg,
    180      1.41   mjacob 	isp_pci_wr_reg,
    181      1.41   mjacob 	isp_pci_mbxdma,
    182      1.41   mjacob 	isp_pci_dmasetup,
    183      1.41   mjacob 	isp_pci_dmateardown,
    184      1.41   mjacob 	NULL,
    185      1.41   mjacob 	isp_pci_reset1,
    186      1.41   mjacob 	isp_pci_dumpregs,
    187  1.45.2.2   bouyer 	ISP_2200_RISC_CODE
    188      1.41   mjacob };
    189      1.41   mjacob #endif
    190      1.41   mjacob 
    191      1.36   mjacob #ifndef	PCI_VENDOR_QLOGIC
    192      1.36   mjacob #define	PCI_VENDOR_QLOGIC	0x1077
    193      1.36   mjacob #endif
    194      1.36   mjacob 
    195      1.36   mjacob #ifndef	PCI_PRODUCT_QLOGIC_ISP1020
    196      1.36   mjacob #define	PCI_PRODUCT_QLOGIC_ISP1020	0x1020
    197      1.36   mjacob #endif
    198      1.36   mjacob 
    199      1.36   mjacob #ifndef	PCI_PRODUCT_QLOGIC_ISP1080
    200      1.36   mjacob #define	PCI_PRODUCT_QLOGIC_ISP1080	0x1080
    201      1.36   mjacob #endif
    202      1.36   mjacob 
    203      1.36   mjacob #ifndef	PCI_PRODUCT_QLOGIC_ISP1240
    204      1.36   mjacob #define	PCI_PRODUCT_QLOGIC_ISP1240	0x1240
    205      1.36   mjacob #endif
    206       1.1      cgd 
    207  1.45.2.2   bouyer #ifndef	PCI_PRODUCT_QLOGIC_ISP1280
    208  1.45.2.2   bouyer #define	PCI_PRODUCT_QLOGIC_ISP1280	0x1280
    209  1.45.2.2   bouyer #endif
    210  1.45.2.2   bouyer 
    211  1.45.2.2   bouyer #ifndef	PCI_PRODUCT_QLOGIC_ISP12160
    212  1.45.2.2   bouyer #define	PCI_PRODUCT_QLOGIC_ISP12160	0x1216
    213  1.45.2.2   bouyer #endif
    214  1.45.2.2   bouyer 
    215      1.15   mjacob #ifndef	PCI_PRODUCT_QLOGIC_ISP2100
    216      1.15   mjacob #define	PCI_PRODUCT_QLOGIC_ISP2100	0x2100
    217      1.15   mjacob #endif
    218      1.36   mjacob 
    219      1.41   mjacob #ifndef	PCI_PRODUCT_QLOGIC_ISP2200
    220      1.41   mjacob #define	PCI_PRODUCT_QLOGIC_ISP2200	0x2200
    221      1.41   mjacob #endif
    222      1.41   mjacob 
    223      1.36   mjacob #define	PCI_QLOGIC_ISP	((PCI_PRODUCT_QLOGIC_ISP1020 << 16) | PCI_VENDOR_QLOGIC)
    224      1.36   mjacob 
    225      1.36   mjacob #define	PCI_QLOGIC_ISP1080	\
    226      1.36   mjacob 	((PCI_PRODUCT_QLOGIC_ISP1080 << 16) | PCI_VENDOR_QLOGIC)
    227      1.36   mjacob 
    228      1.36   mjacob #define	PCI_QLOGIC_ISP1240	\
    229      1.36   mjacob 	((PCI_PRODUCT_QLOGIC_ISP1240 << 16) | PCI_VENDOR_QLOGIC)
    230      1.36   mjacob 
    231  1.45.2.2   bouyer #define	PCI_QLOGIC_ISP1280	\
    232  1.45.2.2   bouyer 	((PCI_PRODUCT_QLOGIC_ISP1280 << 16) | PCI_VENDOR_QLOGIC)
    233  1.45.2.2   bouyer 
    234  1.45.2.2   bouyer #define	PCI_QLOGIC_ISP12160	\
    235  1.45.2.2   bouyer 	((PCI_PRODUCT_QLOGIC_ISP12160 << 16) | PCI_VENDOR_QLOGIC)
    236  1.45.2.2   bouyer 
    237      1.15   mjacob #define	PCI_QLOGIC_ISP2100	\
    238      1.15   mjacob 	((PCI_PRODUCT_QLOGIC_ISP2100 << 16) | PCI_VENDOR_QLOGIC)
    239      1.15   mjacob 
    240      1.41   mjacob #define	PCI_QLOGIC_ISP2200	\
    241      1.41   mjacob 	((PCI_PRODUCT_QLOGIC_ISP2200 << 16) | PCI_VENDOR_QLOGIC)
    242      1.41   mjacob 
    243      1.44   mjacob #define	IO_MAP_REG	0x10
    244      1.44   mjacob #define	MEM_MAP_REG	0x14
    245      1.39   mjacob #define	PCIR_ROMADDR	0x30
    246      1.39   mjacob 
    247      1.39   mjacob #define	PCI_DFLT_LTNCY	0x40
    248      1.39   mjacob #define	PCI_DFLT_LNSZ	0x10
    249       1.6      cgd 
    250       1.1      cgd 
    251       1.1      cgd static int isp_pci_probe __P((struct device *, struct cfdata *, void *));
    252       1.1      cgd static void isp_pci_attach __P((struct device *, struct device *, void *));
    253       1.1      cgd 
    254       1.1      cgd struct isp_pcisoftc {
    255       1.1      cgd 	struct ispsoftc		pci_isp;
    256      1.15   mjacob 	pci_chipset_tag_t	pci_pc;
    257      1.15   mjacob 	pcitag_t		pci_tag;
    258       1.6      cgd 	bus_space_tag_t		pci_st;
    259       1.6      cgd 	bus_space_handle_t	pci_sh;
    260      1.13  thorpej 	bus_dma_tag_t		pci_dmat;
    261      1.15   mjacob 	bus_dmamap_t		pci_scratch_dmap;	/* for fcp only */
    262      1.13  thorpej 	bus_dmamap_t		pci_rquest_dmap;
    263      1.13  thorpej 	bus_dmamap_t		pci_result_dmap;
    264      1.45   mjacob 	bus_dmamap_t		*pci_xfer_dmap;
    265       1.1      cgd 	void *			pci_ih;
    266      1.36   mjacob 	int16_t			pci_poff[_NREG_BLKS];
    267       1.1      cgd };
    268       1.1      cgd 
    269       1.1      cgd struct cfattach isp_pci_ca = {
    270       1.1      cgd 	sizeof (struct isp_pcisoftc), isp_pci_probe, isp_pci_attach
    271       1.1      cgd };
    272       1.1      cgd 
    273  1.45.2.2   bouyer #ifdef	DEBUG
    274  1.45.2.6   bouyer const char vstring[] =
    275  1.45.2.2   bouyer     "Qlogic ISP Driver, NetBSD (pci) Platform Version %d.%d Core Version %d.%d";
    276  1.45.2.2   bouyer #endif
    277  1.45.2.2   bouyer 
    278       1.1      cgd static int
    279       1.1      cgd isp_pci_probe(parent, match, aux)
    280      1.44   mjacob 	struct device *parent;
    281      1.44   mjacob 	struct cfdata *match;
    282      1.44   mjacob 	void *aux;
    283      1.44   mjacob {
    284      1.44   mjacob 	struct pci_attach_args *pa = aux;
    285      1.44   mjacob 	switch (pa->pa_id) {
    286      1.36   mjacob #ifndef	ISP_DISABLE_1020_SUPPORT
    287      1.36   mjacob 	case PCI_QLOGIC_ISP:
    288      1.36   mjacob 		return (1);
    289      1.36   mjacob #endif
    290      1.36   mjacob #ifndef	ISP_DISABLE_1080_SUPPORT
    291      1.36   mjacob 	case PCI_QLOGIC_ISP1080:
    292      1.40   mjacob 	case PCI_QLOGIC_ISP1240:
    293  1.45.2.2   bouyer 	case PCI_QLOGIC_ISP1280:
    294  1.45.2.2   bouyer 		return (1);
    295  1.45.2.2   bouyer #endif
    296  1.45.2.2   bouyer #ifndef	ISP_DISABLE_12160_SUPPORT
    297  1.45.2.2   bouyer 	case PCI_QLOGIC_ISP12160:
    298      1.36   mjacob 		return (1);
    299      1.36   mjacob #endif
    300      1.36   mjacob #ifndef	ISP_DISABLE_2100_SUPPORT
    301      1.36   mjacob 	case PCI_QLOGIC_ISP2100:
    302       1.1      cgd 		return (1);
    303      1.36   mjacob #endif
    304      1.41   mjacob #ifndef	ISP_DISABLE_2200_SUPPORT
    305      1.41   mjacob 	case PCI_QLOGIC_ISP2200:
    306      1.41   mjacob 		return (1);
    307      1.41   mjacob #endif
    308      1.36   mjacob 	default:
    309       1.1      cgd 		return (0);
    310       1.1      cgd 	}
    311       1.1      cgd }
    312       1.1      cgd 
    313       1.1      cgd 
    314      1.44   mjacob static void
    315       1.1      cgd isp_pci_attach(parent, self, aux)
    316      1.44   mjacob 	struct device *parent, *self;
    317      1.44   mjacob 	void *aux;
    318       1.1      cgd {
    319      1.29   mjacob #ifdef	DEBUG
    320      1.27  thorpej 	static char oneshot = 1;
    321      1.27  thorpej #endif
    322  1.45.2.6   bouyer 	static const char nomem[] = "%s: no mem for sdparam table\n";
    323  1.45.2.2   bouyer 	u_int32_t data, rev, linesz = PCI_DFLT_LNSZ;
    324       1.1      cgd 	struct pci_attach_args *pa = aux;
    325       1.1      cgd 	struct isp_pcisoftc *pcs = (struct isp_pcisoftc *) self;
    326      1.21   mjacob 	struct ispsoftc *isp = &pcs->pci_isp;
    327      1.11      cgd 	bus_space_tag_t st, iot, memt;
    328      1.11      cgd 	bus_space_handle_t sh, ioh, memh;
    329       1.1      cgd 	pci_intr_handle_t ih;
    330       1.1      cgd 	const char *intrstr;
    331  1.45.2.2   bouyer 	int ioh_valid, memh_valid;
    332       1.1      cgd 
    333      1.12      cgd 	ioh_valid = (pci_mapreg_map(pa, IO_MAP_REG,
    334      1.11      cgd 	    PCI_MAPREG_TYPE_IO, 0,
    335      1.11      cgd 	    &iot, &ioh, NULL, NULL) == 0);
    336      1.12      cgd 	memh_valid = (pci_mapreg_map(pa, MEM_MAP_REG,
    337      1.11      cgd 	    PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT, 0,
    338      1.11      cgd 	    &memt, &memh, NULL, NULL) == 0);
    339      1.11      cgd 	if (memh_valid) {
    340      1.11      cgd 		st = memt;
    341      1.11      cgd 		sh = memh;
    342      1.11      cgd 	} else if (ioh_valid) {
    343      1.11      cgd 		st = iot;
    344      1.11      cgd 		sh = ioh;
    345       1.6      cgd 	} else {
    346      1.11      cgd 		printf(": unable to map device registers\n");
    347       1.9      cgd 		return;
    348       1.1      cgd 	}
    349       1.1      cgd 	printf("\n");
    350       1.1      cgd 
    351       1.6      cgd 	pcs->pci_st = st;
    352       1.6      cgd 	pcs->pci_sh = sh;
    353      1.13  thorpej 	pcs->pci_dmat = pa->pa_dmat;
    354      1.15   mjacob 	pcs->pci_pc = pa->pa_pc;
    355      1.15   mjacob 	pcs->pci_tag = pa->pa_tag;
    356      1.36   mjacob 	pcs->pci_poff[BIU_BLOCK >> _BLK_REG_SHFT] = BIU_REGS_OFF;
    357      1.36   mjacob 	pcs->pci_poff[MBOX_BLOCK >> _BLK_REG_SHFT] = PCI_MBOX_REGS_OFF;
    358      1.36   mjacob 	pcs->pci_poff[SXP_BLOCK >> _BLK_REG_SHFT] = PCI_SXP_REGS_OFF;
    359      1.36   mjacob 	pcs->pci_poff[RISC_BLOCK >> _BLK_REG_SHFT] = PCI_RISC_REGS_OFF;
    360      1.36   mjacob 	pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] = DMA_REGS_OFF;
    361  1.45.2.2   bouyer 	rev = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_CLASS_REG) & 0xff;
    362      1.36   mjacob 
    363      1.36   mjacob #ifndef	ISP_DISABLE_1020_SUPPORT
    364      1.15   mjacob 	if (pa->pa_id == PCI_QLOGIC_ISP) {
    365      1.21   mjacob 		isp->isp_mdvec = &mdvec;
    366      1.21   mjacob 		isp->isp_type = ISP_HA_SCSI_UNKNOWN;
    367      1.21   mjacob 		isp->isp_param = malloc(sizeof (sdparam), M_DEVBUF, M_NOWAIT);
    368      1.21   mjacob 		if (isp->isp_param == NULL) {
    369      1.40   mjacob 			printf(nomem, isp->isp_name);
    370      1.21   mjacob 			return;
    371      1.15   mjacob 		}
    372      1.21   mjacob 		bzero(isp->isp_param, sizeof (sdparam));
    373      1.36   mjacob 	}
    374      1.36   mjacob #endif
    375      1.36   mjacob #ifndef	ISP_DISABLE_1080_SUPPORT
    376      1.36   mjacob 	if (pa->pa_id == PCI_QLOGIC_ISP1080) {
    377      1.36   mjacob 		isp->isp_mdvec = &mdvec_1080;
    378      1.36   mjacob 		isp->isp_type = ISP_HA_SCSI_1080;
    379      1.36   mjacob 		isp->isp_param = malloc(sizeof (sdparam), M_DEVBUF, M_NOWAIT);
    380      1.36   mjacob 		if (isp->isp_param == NULL) {
    381      1.40   mjacob 			printf(nomem, isp->isp_name);
    382      1.36   mjacob 			return;
    383      1.36   mjacob 		}
    384      1.36   mjacob 		bzero(isp->isp_param, sizeof (sdparam));
    385      1.36   mjacob 		pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] =
    386      1.36   mjacob 		    ISP1080_DMA_REGS_OFF;
    387      1.36   mjacob 	}
    388      1.40   mjacob 	if (pa->pa_id == PCI_QLOGIC_ISP1240) {
    389      1.40   mjacob 		isp->isp_mdvec = &mdvec_1080;
    390  1.45.2.2   bouyer 		isp->isp_type = ISP_HA_SCSI_1240;
    391  1.45.2.2   bouyer 		isp->isp_param =
    392  1.45.2.2   bouyer 		    malloc(2 * sizeof (sdparam), M_DEVBUF, M_NOWAIT);
    393  1.45.2.2   bouyer 		if (isp->isp_param == NULL) {
    394  1.45.2.2   bouyer 			printf(nomem, isp->isp_name);
    395  1.45.2.2   bouyer 			return;
    396  1.45.2.2   bouyer 		}
    397  1.45.2.2   bouyer 		bzero(isp->isp_param, 2 * sizeof (sdparam));
    398  1.45.2.2   bouyer 		pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] =
    399  1.45.2.2   bouyer 		    ISP1080_DMA_REGS_OFF;
    400  1.45.2.2   bouyer 	}
    401  1.45.2.2   bouyer 	if (pa->pa_id == PCI_QLOGIC_ISP1280) {
    402  1.45.2.2   bouyer 		isp->isp_mdvec = &mdvec_1080;
    403  1.45.2.2   bouyer 		isp->isp_type = ISP_HA_SCSI_1280;
    404  1.45.2.2   bouyer 		isp->isp_param =
    405  1.45.2.2   bouyer 		    malloc(2 * sizeof (sdparam), M_DEVBUF, M_NOWAIT);
    406  1.45.2.2   bouyer 		if (isp->isp_param == NULL) {
    407  1.45.2.2   bouyer 			printf(nomem, isp->isp_name);
    408  1.45.2.2   bouyer 			return;
    409  1.45.2.2   bouyer 		}
    410  1.45.2.2   bouyer 		bzero(isp->isp_param, 2 * sizeof (sdparam));
    411  1.45.2.2   bouyer 		pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] =
    412  1.45.2.2   bouyer 		    ISP1080_DMA_REGS_OFF;
    413  1.45.2.2   bouyer 	}
    414  1.45.2.2   bouyer #endif
    415  1.45.2.2   bouyer #ifndef	ISP_DISABLE_12160_SUPPORT
    416  1.45.2.2   bouyer 	if (pa->pa_id == PCI_QLOGIC_ISP12160) {
    417  1.45.2.2   bouyer 		isp->isp_mdvec = &mdvec_12160;
    418  1.45.2.2   bouyer 		isp->isp_type = ISP_HA_SCSI_12160;
    419      1.40   mjacob 		isp->isp_param =
    420      1.40   mjacob 		    malloc(2 * sizeof (sdparam), M_DEVBUF, M_NOWAIT);
    421      1.40   mjacob 		if (isp->isp_param == NULL) {
    422      1.40   mjacob 			printf(nomem, isp->isp_name);
    423      1.40   mjacob 			return;
    424      1.40   mjacob 		}
    425      1.40   mjacob 		bzero(isp->isp_param, 2 * sizeof (sdparam));
    426      1.40   mjacob 		pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] =
    427      1.40   mjacob 		    ISP1080_DMA_REGS_OFF;
    428      1.40   mjacob 	}
    429      1.36   mjacob #endif
    430      1.36   mjacob #ifndef	ISP_DISABLE_2100_SUPPORT
    431      1.36   mjacob 	if (pa->pa_id == PCI_QLOGIC_ISP2100) {
    432      1.21   mjacob 		isp->isp_mdvec = &mdvec_2100;
    433      1.21   mjacob 		isp->isp_type = ISP_HA_FC_2100;
    434      1.21   mjacob 		isp->isp_param = malloc(sizeof (fcparam), M_DEVBUF, M_NOWAIT);
    435      1.21   mjacob 		if (isp->isp_param == NULL) {
    436      1.40   mjacob 			printf(nomem, isp->isp_name);
    437      1.21   mjacob 			return;
    438      1.15   mjacob 		}
    439      1.21   mjacob 		bzero(isp->isp_param, sizeof (fcparam));
    440      1.36   mjacob 		pcs->pci_poff[MBOX_BLOCK >> _BLK_REG_SHFT] =
    441      1.36   mjacob 		    PCI_MBOX_REGS2100_OFF;
    442  1.45.2.2   bouyer 		if (rev < 3) {
    443      1.39   mjacob 			/*
    444      1.39   mjacob 			 * XXX: Need to get the actual revision
    445      1.39   mjacob 			 * XXX: number of the 2100 FB. At any rate,
    446      1.39   mjacob 			 * XXX: lower cache line size for early revision
    447      1.39   mjacob 			 * XXX; boards.
    448      1.39   mjacob 			 */
    449      1.39   mjacob 			linesz = 1;
    450      1.39   mjacob 		}
    451      1.15   mjacob 	}
    452      1.36   mjacob #endif
    453      1.41   mjacob #ifndef	ISP_DISABLE_2200_SUPPORT
    454      1.41   mjacob 	if (pa->pa_id == PCI_QLOGIC_ISP2200) {
    455      1.41   mjacob 		isp->isp_mdvec = &mdvec_2200;
    456      1.41   mjacob 		isp->isp_type = ISP_HA_FC_2200;
    457      1.41   mjacob 		isp->isp_param = malloc(sizeof (fcparam), M_DEVBUF, M_NOWAIT);
    458      1.41   mjacob 		if (isp->isp_param == NULL) {
    459      1.41   mjacob 			printf(nomem, isp->isp_name);
    460      1.41   mjacob 			return;
    461      1.41   mjacob 		}
    462      1.41   mjacob 		bzero(isp->isp_param, sizeof (fcparam));
    463      1.41   mjacob 		pcs->pci_poff[MBOX_BLOCK >> _BLK_REG_SHFT] =
    464      1.41   mjacob 		    PCI_MBOX_REGS2100_OFF;
    465      1.41   mjacob 		data = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_CLASS_REG);
    466      1.41   mjacob 	}
    467      1.41   mjacob #endif
    468  1.45.2.2   bouyer 	/*
    469  1.45.2.2   bouyer 	 * Set up logging levels.
    470  1.45.2.2   bouyer 	 */
    471  1.45.2.2   bouyer #ifdef	ISP_LOGDEFAULT
    472  1.45.2.2   bouyer 	isp->isp_dblev = ISP_LOGDEFAULT;
    473  1.45.2.2   bouyer #else
    474  1.45.2.6   bouyer 	isp->isp_dblev = ISP_LOGWARN|ISP_LOGERR;
    475  1.45.2.6   bouyer 	if (bootverbose)
    476  1.45.2.6   bouyer 		isp->isp_dblev |= ISP_LOGCONFIG|ISP_LOGINFO;
    477  1.45.2.2   bouyer #ifdef	SCSIDEBUG
    478  1.45.2.2   bouyer 	isp->isp_dblev |= ISP_LOGDEBUG1|ISP_LOGDEBUG2;
    479  1.45.2.2   bouyer #endif
    480  1.45.2.2   bouyer #ifdef	DEBUG
    481  1.45.2.6   bouyer 	isp->isp_dblev |= ISP_LOGDEBUG0;
    482  1.45.2.2   bouyer #endif
    483  1.45.2.2   bouyer #endif
    484  1.45.2.2   bouyer 
    485  1.45.2.2   bouyer #ifdef	DEBUG
    486  1.45.2.2   bouyer 	if (oneshot) {
    487  1.45.2.2   bouyer 		oneshot = 0;
    488  1.45.2.2   bouyer 		isp_prt(isp, ISP_LOGCONFIG, vstring,
    489  1.45.2.2   bouyer 		    ISP_PLATFORM_VERSION_MAJOR, ISP_PLATFORM_VERSION_MINOR,
    490  1.45.2.2   bouyer 		    ISP_CORE_VERSION_MAJOR, ISP_CORE_VERSION_MINOR);
    491  1.45.2.2   bouyer 	}
    492  1.45.2.2   bouyer #endif
    493  1.45.2.2   bouyer 
    494  1.45.2.2   bouyer 	isp->isp_revision = rev;
    495      1.36   mjacob 
    496      1.35   mjacob 	/*
    497      1.35   mjacob 	 * Make sure that command register set sanely.
    498      1.35   mjacob 	 */
    499      1.35   mjacob 	data = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
    500      1.35   mjacob 	data |= PCI_COMMAND_MASTER_ENABLE | PCI_COMMAND_INVALIDATE_ENABLE;
    501      1.36   mjacob 
    502      1.35   mjacob 	/*
    503      1.35   mjacob 	 * Not so sure about these- but I think it's important that they get
    504      1.35   mjacob 	 * enabled......
    505      1.35   mjacob 	 */
    506      1.35   mjacob 	data |= PCI_COMMAND_PARITY_ENABLE | PCI_COMMAND_SERR_ENABLE;
    507      1.35   mjacob 	pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, data);
    508      1.36   mjacob 
    509      1.35   mjacob 	/*
    510      1.39   mjacob 	 * Make sure that the latency timer, cache line size,
    511      1.39   mjacob 	 * and ROM is disabled.
    512      1.35   mjacob 	 */
    513      1.35   mjacob 	data = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_BHLC_REG);
    514      1.35   mjacob 	data &= ~(PCI_LATTIMER_MASK << PCI_LATTIMER_SHIFT);
    515      1.35   mjacob 	data &= ~(PCI_CACHELINE_MASK << PCI_CACHELINE_SHIFT);
    516      1.39   mjacob 	data |= (PCI_DFLT_LTNCY	<< PCI_LATTIMER_SHIFT);
    517      1.39   mjacob 	data |= (linesz << PCI_CACHELINE_SHIFT);
    518      1.35   mjacob 	pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_BHLC_REG, data);
    519      1.39   mjacob 
    520      1.39   mjacob 	data = pci_conf_read(pa->pa_pc, pa->pa_tag, PCIR_ROMADDR);
    521      1.39   mjacob 	data &= ~1;
    522      1.39   mjacob 	pci_conf_write(pa->pa_pc, pa->pa_tag, PCIR_ROMADDR, data);
    523      1.35   mjacob 
    524  1.45.2.6   bouyer 	if (pci_intr_map(pa, &ih)) {
    525      1.21   mjacob 		printf("%s: couldn't map interrupt\n", isp->isp_name);
    526      1.21   mjacob 		free(isp->isp_param, M_DEVBUF);
    527       1.1      cgd 		return;
    528       1.1      cgd 	}
    529       1.1      cgd 	intrstr = pci_intr_string(pa->pa_pc, ih);
    530       1.1      cgd 	if (intrstr == NULL)
    531       1.1      cgd 		intrstr = "<I dunno>";
    532      1.44   mjacob 	pcs->pci_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO,
    533      1.44   mjacob 	    isp_pci_intr, isp);
    534       1.1      cgd 	if (pcs->pci_ih == NULL) {
    535       1.1      cgd 		printf("%s: couldn't establish interrupt at %s\n",
    536      1.21   mjacob 			isp->isp_name, intrstr);
    537      1.36   mjacob 		free(isp->isp_param, M_DEVBUF);
    538      1.36   mjacob 		return;
    539      1.36   mjacob 	}
    540  1.45.2.2   bouyer 
    541      1.36   mjacob 	printf("%s: interrupting at %s\n", isp->isp_name, intrstr);
    542      1.36   mjacob 
    543      1.43   mjacob 	if (IS_FC(isp)) {
    544  1.45.2.2   bouyer 		DEFAULT_NODEWWN(isp) = 0x400000007F000002;
    545  1.45.2.2   bouyer 		DEFAULT_PORTWWN(isp) = 0x400000007F000002;
    546      1.43   mjacob 	}
    547      1.41   mjacob 
    548  1.45.2.2   bouyer 	isp->isp_confopts = self->dv_cfdata->cf_flags;
    549      1.36   mjacob 	ISP_LOCK(isp);
    550  1.45.2.2   bouyer 	isp->isp_osinfo.no_mbox_ints = 1;
    551      1.36   mjacob 	isp_reset(isp);
    552      1.36   mjacob 	if (isp->isp_state != ISP_RESETSTATE) {
    553      1.36   mjacob 		ISP_UNLOCK(isp);
    554      1.36   mjacob 		free(isp->isp_param, M_DEVBUF);
    555      1.36   mjacob 		return;
    556      1.36   mjacob 	}
    557  1.45.2.2   bouyer 	ENABLE_INTS(isp);
    558      1.36   mjacob 	isp_init(isp);
    559      1.36   mjacob 	if (isp->isp_state != ISP_INITSTATE) {
    560      1.21   mjacob 		isp_uninit(isp);
    561      1.22   mjacob 		ISP_UNLOCK(isp);
    562      1.21   mjacob 		free(isp->isp_param, M_DEVBUF);
    563       1.1      cgd 		return;
    564       1.1      cgd 	}
    565       1.1      cgd 	/*
    566  1.45.2.2   bouyer 	 * Do platform attach.
    567       1.1      cgd 	 */
    568  1.45.2.2   bouyer 	ISP_UNLOCK(isp);
    569      1.21   mjacob 	isp_attach(isp);
    570      1.21   mjacob 	if (isp->isp_state != ISP_RUNSTATE) {
    571  1.45.2.2   bouyer 		ISP_LOCK(isp);
    572      1.21   mjacob 		isp_uninit(isp);
    573      1.21   mjacob 		free(isp->isp_param, M_DEVBUF);
    574  1.45.2.2   bouyer 		ISP_UNLOCK(isp);
    575       1.1      cgd 	}
    576       1.1      cgd }
    577       1.1      cgd 
    578       1.1      cgd static u_int16_t
    579       1.1      cgd isp_pci_rd_reg(isp, regoff)
    580       1.1      cgd 	struct ispsoftc *isp;
    581       1.1      cgd 	int regoff;
    582       1.1      cgd {
    583      1.15   mjacob 	u_int16_t rv;
    584       1.1      cgd 	struct isp_pcisoftc *pcs = (struct isp_pcisoftc *) isp;
    585      1.36   mjacob 	int offset, oldconf = 0;
    586      1.15   mjacob 
    587      1.36   mjacob 	if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) {
    588       1.1      cgd 		/*
    589      1.15   mjacob 		 * We will assume that someone has paused the RISC processor.
    590       1.1      cgd 		 */
    591      1.36   mjacob 		oldconf = isp_pci_rd_reg(isp, BIU_CONF1);
    592      1.36   mjacob 		isp_pci_wr_reg(isp, BIU_CONF1, oldconf | BIU_PCI_CONF1_SXP);
    593  1.45.2.2   bouyer 		delay(250);
    594       1.1      cgd 	}
    595      1.36   mjacob 	offset = pcs->pci_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT];
    596      1.36   mjacob 	offset += (regoff & 0xff);
    597      1.15   mjacob 	rv = bus_space_read_2(pcs->pci_st, pcs->pci_sh, offset);
    598      1.36   mjacob 	if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) {
    599      1.36   mjacob 		isp_pci_wr_reg(isp, BIU_CONF1, oldconf);
    600  1.45.2.2   bouyer 		delay(250);
    601      1.15   mjacob 	}
    602      1.15   mjacob 	return (rv);
    603       1.1      cgd }
    604       1.1      cgd 
    605       1.1      cgd static void
    606       1.1      cgd isp_pci_wr_reg(isp, regoff, val)
    607       1.1      cgd 	struct ispsoftc *isp;
    608       1.1      cgd 	int regoff;
    609       1.1      cgd 	u_int16_t val;
    610       1.1      cgd {
    611       1.1      cgd 	struct isp_pcisoftc *pcs = (struct isp_pcisoftc *) isp;
    612      1.36   mjacob 	int offset, oldconf = 0;
    613      1.36   mjacob 
    614      1.36   mjacob 	if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) {
    615       1.1      cgd 		/*
    616      1.15   mjacob 		 * We will assume that someone has paused the RISC processor.
    617       1.1      cgd 		 */
    618      1.36   mjacob 		oldconf = isp_pci_rd_reg(isp, BIU_CONF1);
    619      1.36   mjacob 		isp_pci_wr_reg(isp, BIU_CONF1, oldconf | BIU_PCI_CONF1_SXP);
    620  1.45.2.2   bouyer 		delay(250);
    621      1.36   mjacob 	}
    622      1.36   mjacob 	offset = pcs->pci_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT];
    623      1.36   mjacob 	offset += (regoff & 0xff);
    624      1.36   mjacob 	bus_space_write_2(pcs->pci_st, pcs->pci_sh, offset, val);
    625      1.36   mjacob 	if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) {
    626      1.36   mjacob 		isp_pci_wr_reg(isp, BIU_CONF1, oldconf);
    627  1.45.2.2   bouyer 		delay(250);
    628      1.36   mjacob 	}
    629      1.36   mjacob }
    630      1.36   mjacob 
    631  1.45.2.2   bouyer #if !(defined(ISP_DISABLE_1080_SUPPORT) && defined(ISP_DISABLE_12160_SUPPORT))
    632      1.36   mjacob static u_int16_t
    633      1.36   mjacob isp_pci_rd_reg_1080(isp, regoff)
    634      1.36   mjacob 	struct ispsoftc *isp;
    635      1.36   mjacob 	int regoff;
    636      1.36   mjacob {
    637  1.45.2.2   bouyer 	u_int16_t rv, oc = 0;
    638      1.36   mjacob 	struct isp_pcisoftc *pcs = (struct isp_pcisoftc *) isp;
    639  1.45.2.2   bouyer 	int offset;
    640      1.36   mjacob 
    641      1.36   mjacob 	if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) {
    642  1.45.2.2   bouyer 		u_int16_t tc;
    643      1.36   mjacob 		/*
    644      1.36   mjacob 		 * We will assume that someone has paused the RISC processor.
    645      1.36   mjacob 		 */
    646      1.36   mjacob 		oc = isp_pci_rd_reg(isp, BIU_CONF1);
    647  1.45.2.2   bouyer 		tc = oc & ~BIU_PCI1080_CONF1_DMA;
    648  1.45.2.2   bouyer 		if (IS_1280(isp)) {
    649  1.45.2.2   bouyer 			if (regoff & SXP_BANK1_SELECT)
    650  1.45.2.2   bouyer 				tc |= BIU_PCI1080_CONF1_SXP0;
    651  1.45.2.2   bouyer 			else
    652  1.45.2.2   bouyer 				tc |= BIU_PCI1080_CONF1_SXP1;
    653  1.45.2.2   bouyer 		} else {
    654  1.45.2.2   bouyer 			tc |= BIU_PCI1080_CONF1_SXP0;
    655  1.45.2.2   bouyer 		}
    656  1.45.2.2   bouyer 		isp_pci_wr_reg(isp, BIU_CONF1, tc);
    657  1.45.2.2   bouyer 		delay(250);
    658      1.36   mjacob 	} else if ((regoff & _BLK_REG_MASK) == DMA_BLOCK) {
    659      1.36   mjacob 		oc = isp_pci_rd_reg(isp, BIU_CONF1);
    660      1.36   mjacob 		isp_pci_wr_reg(isp, BIU_CONF1, oc | BIU_PCI1080_CONF1_DMA);
    661  1.45.2.2   bouyer 		delay(250);
    662      1.36   mjacob 	}
    663      1.36   mjacob 	offset = pcs->pci_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT];
    664      1.36   mjacob 	offset += (regoff & 0xff);
    665      1.36   mjacob 	rv = bus_space_read_2(pcs->pci_st, pcs->pci_sh, offset);
    666  1.45.2.2   bouyer 	/*
    667  1.45.2.2   bouyer 	 * Okay, because BIU_CONF1 is always nonzero
    668  1.45.2.2   bouyer 	 */
    669  1.45.2.2   bouyer 	if (oc) {
    670      1.36   mjacob 		isp_pci_wr_reg(isp, BIU_CONF1, oc);
    671  1.45.2.2   bouyer 		delay(250);
    672      1.36   mjacob 	}
    673      1.36   mjacob 	return (rv);
    674      1.36   mjacob }
    675      1.36   mjacob 
    676      1.36   mjacob static void
    677      1.36   mjacob isp_pci_wr_reg_1080(isp, regoff, val)
    678      1.36   mjacob 	struct ispsoftc *isp;
    679      1.36   mjacob 	int regoff;
    680      1.36   mjacob 	u_int16_t val;
    681      1.36   mjacob {
    682  1.45.2.2   bouyer 	u_int16_t oc = 0;
    683      1.36   mjacob 	struct isp_pcisoftc *pcs = (struct isp_pcisoftc *) isp;
    684  1.45.2.2   bouyer 	int offset;
    685      1.36   mjacob 
    686      1.36   mjacob 	if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) {
    687  1.45.2.2   bouyer 		u_int16_t tc;
    688      1.36   mjacob 		/*
    689      1.36   mjacob 		 * We will assume that someone has paused the RISC processor.
    690      1.36   mjacob 		 */
    691      1.36   mjacob 		oc = isp_pci_rd_reg(isp, BIU_CONF1);
    692  1.45.2.2   bouyer 		tc = oc & ~BIU_PCI1080_CONF1_DMA;
    693  1.45.2.2   bouyer 		if (IS_1280(isp)) {
    694  1.45.2.2   bouyer 			if (regoff & SXP_BANK1_SELECT)
    695  1.45.2.2   bouyer 				tc |= BIU_PCI1080_CONF1_SXP0;
    696  1.45.2.2   bouyer 			else
    697  1.45.2.2   bouyer 				tc |= BIU_PCI1080_CONF1_SXP1;
    698  1.45.2.2   bouyer 		} else {
    699  1.45.2.2   bouyer 			tc |= BIU_PCI1080_CONF1_SXP0;
    700  1.45.2.2   bouyer 		}
    701  1.45.2.2   bouyer 		isp_pci_wr_reg(isp, BIU_CONF1, tc);
    702  1.45.2.2   bouyer 		delay(250);
    703      1.36   mjacob 	} else if ((regoff & _BLK_REG_MASK) == DMA_BLOCK) {
    704      1.36   mjacob 		oc = isp_pci_rd_reg(isp, BIU_CONF1);
    705      1.36   mjacob 		isp_pci_wr_reg(isp, BIU_CONF1, oc | BIU_PCI1080_CONF1_DMA);
    706  1.45.2.2   bouyer 		delay(250);
    707       1.1      cgd 	}
    708      1.36   mjacob 	offset = pcs->pci_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT];
    709      1.36   mjacob 	offset += (regoff & 0xff);
    710       1.6      cgd 	bus_space_write_2(pcs->pci_st, pcs->pci_sh, offset, val);
    711  1.45.2.2   bouyer 	/*
    712  1.45.2.2   bouyer 	 * Okay, because BIU_CONF1 is always nonzero
    713  1.45.2.2   bouyer 	 */
    714  1.45.2.2   bouyer 	if (oc) {
    715      1.36   mjacob 		isp_pci_wr_reg(isp, BIU_CONF1, oc);
    716  1.45.2.2   bouyer 		delay(250);
    717      1.15   mjacob 	}
    718       1.1      cgd }
    719      1.36   mjacob #endif
    720       1.1      cgd 
    721      1.13  thorpej static int
    722      1.13  thorpej isp_pci_mbxdma(isp)
    723       1.1      cgd 	struct ispsoftc *isp;
    724       1.1      cgd {
    725  1.45.2.2   bouyer 	struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp;
    726  1.45.2.2   bouyer 	bus_dma_tag_t dmat = pcs->pci_dmat;
    727  1.45.2.2   bouyer 	bus_dma_segment_t sg;
    728      1.13  thorpej 	bus_size_t len;
    729      1.15   mjacob 	fcparam *fcp;
    730  1.45.2.2   bouyer 	int rs, i;
    731      1.13  thorpej 
    732      1.43   mjacob 	if (isp->isp_rquest_dma)	/* been here before? */
    733      1.43   mjacob 		return (0);
    734      1.43   mjacob 
    735  1.45.2.2   bouyer 	len = isp->isp_maxcmds * sizeof (XS_T);
    736  1.45.2.2   bouyer 	isp->isp_xflist = (XS_T **) malloc(len, M_DEVBUF, M_WAITOK);
    737      1.43   mjacob 	if (isp->isp_xflist == NULL) {
    738  1.45.2.2   bouyer 		isp_prt(isp, ISP_LOGERR, "cannot malloc xflist array");
    739      1.43   mjacob 		return (1);
    740      1.43   mjacob 	}
    741      1.45   mjacob 	bzero(isp->isp_xflist, len);
    742      1.45   mjacob 	len = isp->isp_maxcmds * sizeof (bus_dmamap_t);
    743  1.45.2.2   bouyer 	pcs->pci_xfer_dmap = (bus_dmamap_t *) malloc(len, M_DEVBUF, M_WAITOK);
    744  1.45.2.2   bouyer 	if (pcs->pci_xfer_dmap == NULL) {
    745  1.45.2.2   bouyer 		free(isp->isp_xflist, M_DEVBUF);
    746  1.45.2.2   bouyer 		isp->isp_xflist = NULL;
    747  1.45.2.2   bouyer 		isp_prt(isp, ISP_LOGERR, "cannot malloc dma map array");
    748  1.45.2.2   bouyer 		return (1);
    749  1.45.2.2   bouyer 	}
    750  1.45.2.2   bouyer 	for (i = 0; i < isp->isp_maxcmds; i++) {
    751  1.45.2.3   bouyer 		if (bus_dmamap_create(dmat, MAXPHYS, (MAXPHYS / PAGE_SIZE) + 1,
    752  1.45.2.2   bouyer 		    MAXPHYS, 0, BUS_DMA_NOWAIT, &pcs->pci_xfer_dmap[i])) {
    753  1.45.2.2   bouyer 			isp_prt(isp, ISP_LOGERR, "cannot create dma maps");
    754  1.45.2.2   bouyer 			break;
    755  1.45.2.2   bouyer 		}
    756  1.45.2.2   bouyer 	}
    757  1.45.2.2   bouyer 	if (i < isp->isp_maxcmds) {
    758  1.45.2.2   bouyer 		while (--i >= 0) {
    759  1.45.2.2   bouyer 			bus_dmamap_destroy(dmat, pcs->pci_xfer_dmap[i]);
    760  1.45.2.2   bouyer 		}
    761  1.45.2.2   bouyer 		free(isp->isp_xflist, M_DEVBUF);
    762  1.45.2.2   bouyer 		free(pcs->pci_xfer_dmap, M_DEVBUF);
    763  1.45.2.2   bouyer 		isp->isp_xflist = NULL;
    764  1.45.2.2   bouyer 		pcs->pci_xfer_dmap = NULL;
    765      1.45   mjacob 		return (1);
    766      1.45   mjacob 	}
    767      1.43   mjacob 
    768      1.13  thorpej 	/*
    769      1.13  thorpej 	 * Allocate and map the request queue.
    770      1.13  thorpej 	 */
    771  1.45.2.2   bouyer 	len = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp));
    772  1.45.2.3   bouyer 	if (bus_dmamem_alloc(dmat, len, PAGE_SIZE, 0, &sg, 1, &rs,
    773  1.45.2.3   bouyer 			     BUS_DMA_NOWAIT) ||
    774  1.45.2.2   bouyer 	    bus_dmamem_map(pcs->pci_dmat, &sg, rs, len,
    775  1.45.2.2   bouyer 	    (caddr_t *)&isp->isp_rquest, BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) {
    776  1.45.2.2   bouyer 		goto dmafail;
    777  1.45.2.2   bouyer 	}
    778  1.45.2.2   bouyer 
    779  1.45.2.2   bouyer 	if (bus_dmamap_create(dmat, len, 1, len, 0, BUS_DMA_NOWAIT,
    780  1.45.2.2   bouyer 	    &pcs->pci_rquest_dmap) || bus_dmamap_load(dmat,
    781  1.45.2.2   bouyer 	    pcs->pci_rquest_dmap, (caddr_t)isp->isp_rquest, len, NULL,
    782  1.45.2.2   bouyer 	    BUS_DMA_NOWAIT)) {
    783  1.45.2.2   bouyer 		goto dmafail;
    784  1.45.2.2   bouyer 	}
    785      1.13  thorpej 
    786  1.45.2.2   bouyer 	isp->isp_rquest_dma = pcs->pci_rquest_dmap->dm_segs[0].ds_addr;
    787      1.13  thorpej 
    788      1.13  thorpej 	/*
    789      1.13  thorpej 	 * Allocate and map the result queue.
    790      1.13  thorpej 	 */
    791  1.45.2.2   bouyer 	len = ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp));
    792  1.45.2.3   bouyer 	if (bus_dmamem_alloc(dmat, len, PAGE_SIZE, 0, &sg, 1, &rs,
    793  1.45.2.3   bouyer 			     BUS_DMA_NOWAIT) ||
    794  1.45.2.2   bouyer 	    bus_dmamem_map(dmat, &sg, rs, len, (caddr_t *)&isp->isp_result,
    795  1.45.2.2   bouyer 	    BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) {
    796  1.45.2.2   bouyer 		goto dmafail;
    797  1.45.2.2   bouyer 	}
    798  1.45.2.2   bouyer 	if (bus_dmamap_create(dmat, len, 1, len, 0, BUS_DMA_NOWAIT,
    799  1.45.2.2   bouyer 	    &pcs->pci_result_dmap) || bus_dmamap_load(pcs->pci_dmat,
    800  1.45.2.2   bouyer 	    pcs->pci_result_dmap, (caddr_t)isp->isp_result, len, NULL,
    801  1.45.2.2   bouyer 	    BUS_DMA_NOWAIT)) {
    802  1.45.2.2   bouyer 		goto dmafail;
    803  1.45.2.2   bouyer 	}
    804  1.45.2.2   bouyer 	isp->isp_result_dma = pcs->pci_result_dmap->dm_segs[0].ds_addr;
    805       1.1      cgd 
    806      1.41   mjacob 	if (IS_SCSI(isp)) {
    807      1.15   mjacob 		return (0);
    808      1.15   mjacob 	}
    809       1.1      cgd 
    810      1.15   mjacob 	fcp = isp->isp_param;
    811      1.15   mjacob 	len = ISP2100_SCRLEN;
    812  1.45.2.3   bouyer 	if (bus_dmamem_alloc(dmat, len, PAGE_SIZE, 0, &sg, 1, &rs,
    813  1.45.2.3   bouyer 			     BUS_DMA_NOWAIT) ||
    814  1.45.2.2   bouyer 	    bus_dmamem_map(dmat, &sg, rs, len, (caddr_t *)&fcp->isp_scratch,
    815  1.45.2.2   bouyer 	    BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) {
    816  1.45.2.2   bouyer 		goto dmafail;
    817  1.45.2.2   bouyer 	}
    818  1.45.2.2   bouyer 	if (bus_dmamap_create(dmat, len, 1, len, 0, BUS_DMA_NOWAIT,
    819  1.45.2.2   bouyer 	    &pcs->pci_scratch_dmap) || bus_dmamap_load(dmat,
    820  1.45.2.2   bouyer 	    pcs->pci_scratch_dmap, (caddr_t)fcp->isp_scratch, len, NULL,
    821  1.45.2.2   bouyer 	    BUS_DMA_NOWAIT)) {
    822  1.45.2.2   bouyer 		goto dmafail;
    823  1.45.2.2   bouyer 	}
    824  1.45.2.2   bouyer 	fcp->isp_scdma = pcs->pci_scratch_dmap->dm_segs[0].ds_addr;
    825      1.13  thorpej 	return (0);
    826  1.45.2.2   bouyer dmafail:
    827  1.45.2.2   bouyer 	isp_prt(isp, ISP_LOGERR, "mailbox dma setup failure");
    828  1.45.2.2   bouyer 	for (i = 0; i < isp->isp_maxcmds; i++) {
    829  1.45.2.2   bouyer 		bus_dmamap_destroy(dmat, pcs->pci_xfer_dmap[i]);
    830  1.45.2.2   bouyer 	}
    831  1.45.2.2   bouyer 	free(isp->isp_xflist, M_DEVBUF);
    832  1.45.2.2   bouyer 	free(pcs->pci_xfer_dmap, M_DEVBUF);
    833  1.45.2.2   bouyer 	isp->isp_xflist = NULL;
    834  1.45.2.2   bouyer 	pcs->pci_xfer_dmap = NULL;
    835  1.45.2.2   bouyer 	return (1);
    836       1.1      cgd }
    837       1.1      cgd 
    838       1.1      cgd static int
    839       1.1      cgd isp_pci_dmasetup(isp, xs, rq, iptrp, optr)
    840       1.1      cgd 	struct ispsoftc *isp;
    841      1.16   bouyer 	struct scsipi_xfer *xs;
    842       1.1      cgd 	ispreq_t *rq;
    843  1.45.2.2   bouyer 	u_int16_t *iptrp;
    844  1.45.2.2   bouyer 	u_int16_t optr;
    845       1.1      cgd {
    846  1.45.2.2   bouyer 	struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp;
    847  1.45.2.2   bouyer 	bus_dmamap_t dmap;
    848       1.1      cgd 	ispcontreq_t *crq;
    849      1.17   mjacob 	int segcnt, seg, error, ovseg, seglim, drq;
    850       1.1      cgd 
    851  1.45.2.2   bouyer 	dmap = pcs->pci_xfer_dmap[isp_handle_index(rq->req_handle)];
    852  1.45.2.2   bouyer 
    853       1.1      cgd 	if (xs->datalen == 0) {
    854       1.1      cgd 		rq->req_seg_count = 1;
    855      1.26   mjacob 		goto mbxsync;
    856       1.1      cgd 	}
    857      1.42  thorpej 	if (xs->xs_control & XS_CTL_DATA_IN) {
    858      1.17   mjacob 		drq = REQFLAG_DATA_IN;
    859       1.1      cgd 	} else {
    860      1.17   mjacob 		drq = REQFLAG_DATA_OUT;
    861       1.1      cgd 	}
    862       1.1      cgd 
    863      1.41   mjacob 	if (IS_FC(isp)) {
    864      1.15   mjacob 		seglim = ISP_RQDSEG_T2;
    865      1.15   mjacob 		((ispreqt2_t *)rq)->req_totalcnt = xs->datalen;
    866      1.17   mjacob 		((ispreqt2_t *)rq)->req_flags |= drq;
    867      1.15   mjacob 	} else {
    868      1.17   mjacob 		rq->req_flags |= drq;
    869  1.45.2.2   bouyer 		if (XS_CDBLEN(xs) > 12) {
    870  1.45.2.2   bouyer 			seglim = 0;
    871  1.45.2.2   bouyer 		} else {
    872  1.45.2.2   bouyer 			seglim = ISP_RQDSEG;
    873  1.45.2.2   bouyer 		}
    874      1.15   mjacob 	}
    875  1.45.2.2   bouyer 	error = bus_dmamap_load(pcs->pci_dmat, dmap, xs->data, xs->datalen,
    876  1.45.2.2   bouyer 	    NULL, xs->xs_control & XS_CTL_NOSLEEP ?
    877  1.45.2.2   bouyer 	    BUS_DMA_NOWAIT : BUS_DMA_WAITOK);
    878  1.45.2.2   bouyer 	if (error) {
    879      1.21   mjacob 		XS_SETERR(xs, HBA_BOTCH);
    880      1.30   mjacob 		return (CMD_COMPLETE);
    881      1.21   mjacob 	}
    882      1.13  thorpej 
    883      1.13  thorpej 	segcnt = dmap->dm_nsegs;
    884      1.13  thorpej 
    885  1.45.2.2   bouyer 	isp_prt(isp, ISP_LOGDEBUG2, "%d byte %s %p in %d segs",
    886  1.45.2.2   bouyer 	    xs->datalen, (xs->xs_control & XS_CTL_DATA_IN)? "read to" :
    887  1.45.2.2   bouyer 	    "write from", xs->data, segcnt);
    888  1.45.2.2   bouyer 
    889      1.13  thorpej 	for (seg = 0, rq->req_seg_count = 0;
    890  1.45.2.2   bouyer 	    seglim && seg < segcnt && rq->req_seg_count < seglim;
    891      1.44   mjacob 	    seg++, rq->req_seg_count++) {
    892      1.41   mjacob 		if (IS_FC(isp)) {
    893      1.15   mjacob 			ispreqt2_t *rq2 = (ispreqt2_t *)rq;
    894  1.45.2.5   bouyer #if	_BYTE_ORDER == _BIG_ENDIAN
    895  1.45.2.5   bouyer 			rq2->req_dataseg[rq2->req_seg_count].ds_count =
    896  1.45.2.5   bouyer 			    bswap32(dmap->dm_segs[seg].ds_len);
    897  1.45.2.5   bouyer 			rq2->req_dataseg[rq2->req_seg_count].ds_base =
    898  1.45.2.5   bouyer 			    bswap32(dmap->dm_segs[seg].ds_addr);
    899  1.45.2.5   bouyer #else
    900      1.15   mjacob 			rq2->req_dataseg[rq2->req_seg_count].ds_count =
    901      1.15   mjacob 			    dmap->dm_segs[seg].ds_len;
    902      1.15   mjacob 			rq2->req_dataseg[rq2->req_seg_count].ds_base =
    903      1.15   mjacob 			    dmap->dm_segs[seg].ds_addr;
    904  1.45.2.5   bouyer #endif
    905      1.15   mjacob 		} else {
    906  1.45.2.5   bouyer #if	_BYTE_ORDER == _BIG_ENDIAN
    907  1.45.2.5   bouyer 			rq->req_dataseg[rq->req_seg_count].ds_count =
    908  1.45.2.5   bouyer 			    bswap32(dmap->dm_segs[seg].ds_len);
    909  1.45.2.5   bouyer 			rq->req_dataseg[rq->req_seg_count].ds_base =
    910  1.45.2.5   bouyer 			    bswap32(dmap->dm_segs[seg].ds_addr);
    911  1.45.2.5   bouyer #else
    912      1.15   mjacob 			rq->req_dataseg[rq->req_seg_count].ds_count =
    913      1.15   mjacob 			    dmap->dm_segs[seg].ds_len;
    914      1.15   mjacob 			rq->req_dataseg[rq->req_seg_count].ds_base =
    915      1.15   mjacob 			    dmap->dm_segs[seg].ds_addr;
    916  1.45.2.5   bouyer #endif
    917      1.15   mjacob 		}
    918  1.45.2.6   bouyer 		isp_prt(isp, ISP_LOGDEBUG2, "seg0.[%d]={0x%lx,%lu}",
    919  1.45.2.6   bouyer 		    rq->req_seg_count, (long) dmap->dm_segs[seg].ds_addr,
    920  1.45.2.6   bouyer 		    (unsigned long) dmap->dm_segs[seg].ds_len);
    921       1.1      cgd 	}
    922       1.1      cgd 
    923      1.13  thorpej 	if (seg == segcnt)
    924      1.26   mjacob 		goto dmasync;
    925       1.1      cgd 
    926       1.1      cgd 	do {
    927  1.45.2.2   bouyer 		crq = (ispcontreq_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, *iptrp);
    928  1.45.2.2   bouyer 		*iptrp = ISP_NXT_QENTRY(*iptrp, RQUEST_QUEUE_LEN(isp));
    929       1.1      cgd 		if (*iptrp == optr) {
    930  1.45.2.2   bouyer 			isp_prt(isp, ISP_LOGDEBUG0, "Request Queue Overflow++");
    931  1.45.2.2   bouyer 			bus_dmamap_unload(pcs->pci_dmat, dmap);
    932      1.21   mjacob 			XS_SETERR(xs, HBA_BOTCH);
    933  1.45.2.2   bouyer 			return (CMD_EAGAIN);
    934       1.1      cgd 		}
    935       1.1      cgd 		rq->req_header.rqs_entry_count++;
    936       1.1      cgd 		bzero((void *)crq, sizeof (*crq));
    937       1.1      cgd 		crq->req_header.rqs_entry_count = 1;
    938       1.1      cgd 		crq->req_header.rqs_entry_type = RQSTYPE_DATASEG;
    939      1.13  thorpej 
    940      1.13  thorpej 		for (ovseg = 0; seg < segcnt && ovseg < ISP_CDSEG;
    941      1.13  thorpej 		    rq->req_seg_count++, seg++, ovseg++) {
    942  1.45.2.5   bouyer #if	_BYTE_ORDER == _BIG_ENDIAN
    943  1.45.2.5   bouyer 			crq->req_dataseg[ovseg].ds_count =
    944  1.45.2.5   bouyer 			    bswap32(dmap->dm_segs[seg].ds_len);
    945  1.45.2.5   bouyer 			crq->req_dataseg[ovseg].ds_base =
    946  1.45.2.5   bouyer 			    bswap32(dmap->dm_segs[seg].ds_addr);
    947  1.45.2.5   bouyer #else
    948      1.13  thorpej 			crq->req_dataseg[ovseg].ds_count =
    949      1.13  thorpej 			    dmap->dm_segs[seg].ds_len;
    950      1.13  thorpej 			crq->req_dataseg[ovseg].ds_base =
    951      1.13  thorpej 			    dmap->dm_segs[seg].ds_addr;
    952  1.45.2.5   bouyer #endif
    953  1.45.2.6   bouyer 			isp_prt(isp, ISP_LOGDEBUG2, "seg%d.[%d]={0x%lx,%lu}",
    954  1.45.2.2   bouyer 			    rq->req_header.rqs_entry_count - 1,
    955  1.45.2.6   bouyer 			    rq->req_seg_count, (long)dmap->dm_segs[seg].ds_addr,
    956  1.45.2.6   bouyer 			    (unsigned long) dmap->dm_segs[seg].ds_len);
    957       1.1      cgd 		}
    958      1.13  thorpej 	} while (seg < segcnt);
    959      1.13  thorpej 
    960  1.45.2.2   bouyer 
    961      1.26   mjacob dmasync:
    962  1.45.2.2   bouyer 	bus_dmamap_sync(pcs->pci_dmat, dmap, 0, dmap->dm_mapsize,
    963      1.42  thorpej 	    (xs->xs_control & XS_CTL_DATA_IN) ?  BUS_DMASYNC_PREREAD :
    964      1.30   mjacob 	    BUS_DMASYNC_PREWRITE);
    965      1.26   mjacob 
    966      1.26   mjacob mbxsync:
    967      1.43   mjacob 	ISP_SWIZZLE_REQUEST(isp, rq);
    968  1.45.2.2   bouyer 	bus_dmamap_sync(pcs->pci_dmat, pcs->pci_rquest_dmap, 0,
    969  1.45.2.2   bouyer 	    pcs->pci_rquest_dmap->dm_mapsize, BUS_DMASYNC_PREWRITE);
    970      1.30   mjacob 	return (CMD_QUEUED);
    971      1.26   mjacob }
    972      1.26   mjacob 
    973      1.26   mjacob static int
    974      1.26   mjacob isp_pci_intr(arg)
    975      1.26   mjacob 	void *arg;
    976      1.26   mjacob {
    977  1.45.2.2   bouyer 	int rv;
    978  1.45.2.2   bouyer 	struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)arg;
    979  1.45.2.2   bouyer 	bus_dmamap_sync(pcs->pci_dmat, pcs->pci_result_dmap, 0,
    980  1.45.2.2   bouyer 	    pcs->pci_result_dmap->dm_mapsize, BUS_DMASYNC_POSTREAD);
    981  1.45.2.2   bouyer 	pcs->pci_isp.isp_osinfo.onintstack = 1;
    982  1.45.2.2   bouyer 	rv = isp_intr(arg);
    983  1.45.2.2   bouyer 	pcs->pci_isp.isp_osinfo.onintstack = 0;
    984  1.45.2.2   bouyer 	return (rv);
    985      1.13  thorpej }
    986      1.13  thorpej 
    987      1.13  thorpej static void
    988      1.13  thorpej isp_pci_dmateardown(isp, xs, handle)
    989      1.13  thorpej 	struct ispsoftc *isp;
    990      1.16   bouyer 	struct scsipi_xfer *xs;
    991      1.13  thorpej 	u_int32_t handle;
    992      1.13  thorpej {
    993  1.45.2.2   bouyer 	struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp;
    994  1.45.2.2   bouyer 	bus_dmamap_t dmap = pcs->pci_xfer_dmap[isp_handle_index(handle)];
    995  1.45.2.2   bouyer 	bus_dmamap_sync(pcs->pci_dmat, dmap, 0, dmap->dm_mapsize,
    996      1.42  thorpej 	    xs->xs_control & XS_CTL_DATA_IN ?
    997      1.13  thorpej 	    BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
    998  1.45.2.2   bouyer 	bus_dmamap_unload(pcs->pci_dmat, dmap);
    999       1.1      cgd }
   1000       1.1      cgd 
   1001       1.1      cgd static void
   1002       1.1      cgd isp_pci_reset1(isp)
   1003       1.1      cgd 	struct ispsoftc *isp;
   1004       1.1      cgd {
   1005       1.1      cgd 	/* Make sure the BIOS is disabled */
   1006       1.1      cgd 	isp_pci_wr_reg(isp, HCCR, PCI_HCCR_CMD_BIOS);
   1007      1.15   mjacob }
   1008      1.15   mjacob 
   1009      1.15   mjacob static void
   1010  1.45.2.2   bouyer isp_pci_dumpregs(isp, msg)
   1011      1.15   mjacob 	struct ispsoftc *isp;
   1012  1.45.2.2   bouyer 	const char *msg;
   1013      1.15   mjacob {
   1014  1.45.2.2   bouyer 	struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp;
   1015  1.45.2.2   bouyer 	if (msg)
   1016  1.45.2.2   bouyer 		printf("%s: %s\n", isp->isp_name, msg);
   1017  1.45.2.2   bouyer 	if (IS_SCSI(isp))
   1018  1.45.2.2   bouyer 		printf("    biu_conf1=%x", ISP_READ(isp, BIU_CONF1));
   1019  1.45.2.2   bouyer 	else
   1020  1.45.2.2   bouyer 		printf("    biu_csr=%x", ISP_READ(isp, BIU2100_CSR));
   1021  1.45.2.2   bouyer 	printf(" biu_icr=%x biu_isr=%x biu_sema=%x ", ISP_READ(isp, BIU_ICR),
   1022  1.45.2.2   bouyer 	    ISP_READ(isp, BIU_ISR), ISP_READ(isp, BIU_SEMA));
   1023  1.45.2.2   bouyer 	printf("risc_hccr=%x\n", ISP_READ(isp, HCCR));
   1024  1.45.2.2   bouyer 
   1025  1.45.2.2   bouyer 
   1026  1.45.2.2   bouyer 	if (IS_SCSI(isp)) {
   1027  1.45.2.2   bouyer 		ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE);
   1028  1.45.2.2   bouyer 		printf("    cdma_conf=%x cdma_sts=%x cdma_fifostat=%x\n",
   1029  1.45.2.2   bouyer 			ISP_READ(isp, CDMA_CONF), ISP_READ(isp, CDMA_STATUS),
   1030  1.45.2.2   bouyer 			ISP_READ(isp, CDMA_FIFO_STS));
   1031  1.45.2.2   bouyer 		printf("    ddma_conf=%x ddma_sts=%x ddma_fifostat=%x\n",
   1032  1.45.2.2   bouyer 			ISP_READ(isp, DDMA_CONF), ISP_READ(isp, DDMA_STATUS),
   1033  1.45.2.2   bouyer 			ISP_READ(isp, DDMA_FIFO_STS));
   1034  1.45.2.2   bouyer 		printf("    sxp_int=%x sxp_gross=%x sxp(scsi_ctrl)=%x\n",
   1035  1.45.2.2   bouyer 			ISP_READ(isp, SXP_INTERRUPT),
   1036  1.45.2.2   bouyer 			ISP_READ(isp, SXP_GROSS_ERR),
   1037  1.45.2.2   bouyer 			ISP_READ(isp, SXP_PINS_CTRL));
   1038  1.45.2.2   bouyer 		ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE);
   1039  1.45.2.2   bouyer 	}
   1040  1.45.2.2   bouyer 	printf("    mbox regs: %x %x %x %x %x\n",
   1041  1.45.2.2   bouyer 	    ISP_READ(isp, OUTMAILBOX0), ISP_READ(isp, OUTMAILBOX1),
   1042  1.45.2.2   bouyer 	    ISP_READ(isp, OUTMAILBOX2), ISP_READ(isp, OUTMAILBOX3),
   1043  1.45.2.2   bouyer 	    ISP_READ(isp, OUTMAILBOX4));
   1044  1.45.2.2   bouyer 	printf("    PCI Status Command/Status=%x\n",
   1045  1.45.2.2   bouyer 	    pci_conf_read(pcs->pci_pc, pcs->pci_tag, PCI_COMMAND_STATUS_REG));
   1046       1.1      cgd }
   1047