Home | History | Annotate | Line # | Download | only in ic
ispvar.h revision 1.5.4.1
      1  1.5.4.1  thorpej /*	$NetBSD: ispvar.h,v 1.5.4.1 1997/08/23 07:12:59 thorpej Exp $	*/
      2      1.1      cgd 
      3      1.1      cgd /*
      4      1.1      cgd  * Soft Definitions for for Qlogic ISP SCSI adapters.
      5      1.1      cgd  *
      6      1.2      cgd  * Copyright (c) 1997 by Matthew Jacob
      7      1.2      cgd  * NASA/Ames Research Center
      8      1.1      cgd  * All rights reserved.
      9      1.1      cgd  *
     10      1.1      cgd  * Redistribution and use in source and binary forms, with or without
     11      1.1      cgd  * modification, are permitted provided that the following conditions
     12      1.1      cgd  * are met:
     13      1.1      cgd  * 1. Redistributions of source code must retain the above copyright
     14      1.1      cgd  *    notice immediately at the beginning of the file, without modification,
     15      1.1      cgd  *    this list of conditions, and the following disclaimer.
     16      1.1      cgd  * 2. Redistributions in binary form must reproduce the above copyright
     17      1.1      cgd  *    notice, this list of conditions and the following disclaimer in the
     18      1.1      cgd  *    documentation and/or other materials provided with the distribution.
     19      1.1      cgd  * 3. The name of the author may not be used to endorse or promote products
     20      1.1      cgd  *    derived from this software without specific prior written permission.
     21      1.1      cgd  *
     22      1.1      cgd  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     23      1.1      cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24      1.1      cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25      1.1      cgd  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
     26      1.1      cgd  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27      1.1      cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28      1.1      cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29      1.1      cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30      1.1      cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31      1.1      cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32      1.1      cgd  * SUCH DAMAGE.
     33      1.1      cgd  */
     34      1.2      cgd 
     35      1.1      cgd #ifndef	_ISPVAR_H
     36      1.1      cgd #define	_ISPVAR_H
     37      1.1      cgd 
     38      1.1      cgd #include <dev/ic/ispmbox.h>
     39      1.1      cgd 
     40      1.1      cgd /*
     41      1.1      cgd  * Vector for MD code to provide specific services.
     42      1.1      cgd  */
     43      1.1      cgd struct ispsoftc;
     44      1.1      cgd struct ispmdvec {
     45      1.1      cgd 	u_int16_t	(*dv_rd_reg) __P((struct ispsoftc *, int));
     46      1.1      cgd 	void		(*dv_wr_reg) __P((struct ispsoftc *, int, u_int16_t));
     47      1.5  thorpej 	int		(*dv_mbxdma) __P((struct ispsoftc *));
     48      1.1      cgd 	int		(*dv_dmaset) __P((struct ispsoftc *,
     49      1.1      cgd 		struct scsi_xfer *, ispreq_t *, u_int8_t *, u_int8_t));
     50      1.1      cgd 	void		(*dv_dmaclr)
     51      1.1      cgd 		__P((struct ispsoftc *, struct scsi_xfer *, u_int32_t));
     52      1.1      cgd 	void		(*dv_reset0) __P((struct ispsoftc *));
     53      1.1      cgd 	void		(*dv_reset1) __P((struct ispsoftc *));
     54  1.5.4.1  thorpej 	void		(*dv_dregs) __P((struct ispsoftc *));
     55      1.3  mycroft 	const u_int16_t *dv_ispfw;	/* ptr to f/w */
     56      1.1      cgd 	u_int16_t 	dv_fwlen;	/* length of f/w */
     57      1.1      cgd 	u_int16_t	dv_codeorg;	/* code ORG for f/w */
     58  1.5.4.1  thorpej 	u_int16_t	dv_fwrev;	/* f/w revision */
     59      1.1      cgd 	/*
     60      1.1      cgd 	 * Initial values for conf1 register
     61      1.1      cgd 	 */
     62      1.1      cgd 	u_int16_t	dv_conf1;
     63      1.4   mjacob 	u_int16_t	dv_clock;	/* clock frequency */
     64      1.1      cgd };
     65      1.1      cgd 
     66      1.1      cgd #define	MAX_TARGETS	16
     67      1.1      cgd #define	MAX_LUNS	8
     68  1.5.4.1  thorpej #define	MAX_FC_TARG	126
     69      1.1      cgd 
     70  1.5.4.1  thorpej #define	MAXISPREQUEST	256
     71  1.5.4.1  thorpej #define	RQUEST_QUEUE_LEN(isp)	MAXISPREQUEST
     72  1.5.4.1  thorpej #define	RESULT_QUEUE_LEN(isp)	(RQUEST_QUEUE_LEN(isp) >> 2)
     73      1.1      cgd #define	QENTRY_LEN		64
     74      1.1      cgd 
     75      1.5  thorpej #define	ISP_QUEUE_ENTRY(q, idx)	((q) + ((idx) * QENTRY_LEN))
     76      1.5  thorpej #define	ISP_QUEUE_SIZE(n)	((n) * QENTRY_LEN)
     77      1.5  thorpej 
     78      1.1      cgd /*
     79  1.5.4.1  thorpej  * SCSI (as opposed to FC-PH) Specific Host Adapter Parameters
     80  1.5.4.1  thorpej  */
     81  1.5.4.1  thorpej 
     82  1.5.4.1  thorpej typedef struct {
     83  1.5.4.1  thorpej         u_int16_t	isp_adapter_enabled	: 1,
     84  1.5.4.1  thorpej         		isp_req_ack_active_neg	: 1,
     85  1.5.4.1  thorpej 	        	isp_data_line_active_neg: 1,
     86  1.5.4.1  thorpej 			isp_cmd_dma_burst_enable: 1,
     87  1.5.4.1  thorpej 			isp_data_dma_burst_enabl: 1,
     88  1.5.4.1  thorpej 			isp_fifo_threshold	: 2,
     89  1.5.4.1  thorpej 			isp_diffmode		: 1,
     90  1.5.4.1  thorpej 			isp_initiator_id	: 4,
     91  1.5.4.1  thorpej         		isp_async_data_setup	: 4;
     92  1.5.4.1  thorpej         u_int16_t	isp_selection_timeout;
     93  1.5.4.1  thorpej         u_int16_t	isp_max_queue_depth;
     94  1.5.4.1  thorpej 	u_int16_t	isp_clock;
     95  1.5.4.1  thorpej 	u_int8_t	isp_tag_aging;
     96  1.5.4.1  thorpej        	u_int8_t	isp_bus_reset_delay;
     97  1.5.4.1  thorpej         u_int8_t	isp_retry_count;
     98  1.5.4.1  thorpej         u_int8_t	isp_retry_delay;
     99  1.5.4.1  thorpej 	struct {
    100  1.5.4.1  thorpej 		u_int8_t	dev_flags;	/* Device Flags - see below */
    101  1.5.4.1  thorpej 		u_int8_t	exc_throttle;
    102  1.5.4.1  thorpej 		u_int8_t	sync_period;
    103  1.5.4.1  thorpej 		u_int8_t	sync_offset	: 4,
    104  1.5.4.1  thorpej 				dev_enable	: 1;
    105  1.5.4.1  thorpej 	} isp_devparam[MAX_TARGETS];
    106  1.5.4.1  thorpej } sdparam;	/* scsi device parameters */
    107  1.5.4.1  thorpej 
    108  1.5.4.1  thorpej /*
    109  1.5.4.1  thorpej  * Device Flags
    110  1.5.4.1  thorpej  */
    111  1.5.4.1  thorpej #define	DPARM_DISC	0x80
    112  1.5.4.1  thorpej #define	DPARM_PARITY	0x40
    113  1.5.4.1  thorpej #define	DPARM_WIDE	0x20
    114  1.5.4.1  thorpej #define	DPARM_SYNC	0x10
    115  1.5.4.1  thorpej #define	DPARM_TQING	0x08
    116  1.5.4.1  thorpej #define	DPARM_ARQ	0x04
    117  1.5.4.1  thorpej #define	DPARM_QFRZ	0x02
    118  1.5.4.1  thorpej #define	DPARM_RENEG	0x01
    119  1.5.4.1  thorpej #define	DPARM_DEFAULT	(0xff & ~DPARM_QFRZ)
    120  1.5.4.1  thorpej 
    121  1.5.4.1  thorpej #define ISP_20M_SYNCPARMS	0x080c
    122  1.5.4.1  thorpej #define ISP_10M_SYNCPARMS	0x0c19
    123  1.5.4.1  thorpej #define ISP_08M_SYNCPARMS	0x0c25
    124  1.5.4.1  thorpej #define ISP_05M_SYNCPARMS	0x0c32
    125  1.5.4.1  thorpej #define ISP_04M_SYNCPARMS	0x0c41
    126  1.5.4.1  thorpej 
    127  1.5.4.1  thorpej /*
    128  1.5.4.1  thorpej  * Fibre Channel Specifics
    129  1.5.4.1  thorpej  */
    130  1.5.4.1  thorpej typedef struct {
    131  1.5.4.1  thorpej 	u_int64_t		isp_wwn;	/* WWN of adapter */
    132  1.5.4.1  thorpej 	u_int8_t		isp_loopid;	/* FCAL of this adapter inst */
    133  1.5.4.1  thorpej         u_int8_t		isp_retry_count;
    134  1.5.4.1  thorpej         u_int8_t		isp_retry_delay;
    135  1.5.4.1  thorpej 	u_int8_t		isp_fwstate;	/* ISP F/W state */
    136  1.5.4.1  thorpej 
    137  1.5.4.1  thorpej 	/*
    138  1.5.4.1  thorpej 	 * Scratch DMA mapped in area to fetch Port Database stuff, etc.
    139  1.5.4.1  thorpej 	 */
    140  1.5.4.1  thorpej 	volatile caddr_t	isp_scratch;
    141  1.5.4.1  thorpej 	u_int32_t		isp_scdma;
    142  1.5.4.1  thorpej } fcparam;
    143  1.5.4.1  thorpej 
    144  1.5.4.1  thorpej #define	ISP2100_SCRLEN		0x100
    145  1.5.4.1  thorpej 
    146  1.5.4.1  thorpej #define	FW_CONFIG_WAIT		0x0000
    147  1.5.4.1  thorpej #define	FW_WAIT_AL_PA		0x0001
    148  1.5.4.1  thorpej #define	FW_WAIT_LOGIN		0x0002
    149  1.5.4.1  thorpej #define	FW_READY		0x0003
    150  1.5.4.1  thorpej #define	FW_LOSS_OF_SYNC		0x0004
    151  1.5.4.1  thorpej #define	FW_ERROR		0x0005
    152  1.5.4.1  thorpej #define	FW_REINIT		0x0006
    153  1.5.4.1  thorpej #define	FW_NON_PART		0x0007
    154  1.5.4.1  thorpej 
    155  1.5.4.1  thorpej /*
    156      1.1      cgd  * Soft Structure per host adapter
    157      1.1      cgd  */
    158      1.1      cgd struct ispsoftc {
    159      1.1      cgd 	struct device		isp_dev;
    160      1.1      cgd 	struct ispmdvec *	isp_mdvec;
    161      1.1      cgd #define	isp_name	isp_dev.dv_xname
    162      1.1      cgd 	struct scsi_link	isp_link;
    163      1.1      cgd 	u_int8_t		isp_state;
    164  1.5.4.1  thorpej 	int8_t			isp_dblev;
    165  1.5.4.1  thorpej 	u_int16_t		isp_fwrev;
    166  1.5.4.1  thorpej 
    167      1.1      cgd 	/*
    168  1.5.4.1  thorpej 	 * Host Adapter Type and Parameters.
    169  1.5.4.1  thorpej 	 * Some parameters nominally stored in NVRAM on card.
    170      1.1      cgd 	 */
    171  1.5.4.1  thorpej 	u_int8_t		isp_type;
    172  1.5.4.1  thorpej 	void * 			isp_param;
    173  1.5.4.1  thorpej 
    174      1.1      cgd 	/*
    175      1.1      cgd 	 * Result and Request Queues.
    176      1.1      cgd 	 */
    177      1.1      cgd 	volatile u_int8_t	isp_reqidx;	/* index of next request */
    178      1.1      cgd 	volatile u_int8_t	isp_residx;	/* index of next result */
    179      1.1      cgd 	volatile u_int8_t	isp_sendmarker;
    180      1.1      cgd 	volatile u_int8_t	isp_seqno;
    181  1.5.4.1  thorpej 
    182      1.1      cgd 	/*
    183      1.1      cgd 	 * Sheer laziness, but it gets us around the problem
    184      1.1      cgd 	 * where we don't have a clean way of remembering
    185      1.1      cgd 	 * which scsi_xfer is bound to which ISP queue entry.
    186      1.1      cgd 	 *
    187      1.1      cgd 	 * There are other more clever ways to do this, but,
    188      1.1      cgd 	 * jeez, so I blow a couple of KB per host adapter...
    189      1.1      cgd 	 * and it *is* faster.
    190      1.1      cgd 	 */
    191  1.5.4.1  thorpej 	volatile struct scsi_xfer *isp_xflist[MAXISPREQUEST];
    192  1.5.4.1  thorpej 
    193      1.1      cgd 	/*
    194  1.5.4.1  thorpej 	 * request/result queues
    195      1.1      cgd 	 */
    196      1.5  thorpej 	volatile caddr_t	isp_rquest;
    197      1.5  thorpej 	volatile caddr_t	isp_result;
    198      1.5  thorpej 	u_int32_t		isp_rquest_dma;
    199      1.5  thorpej 	u_int32_t		isp_result_dma;
    200      1.1      cgd };
    201      1.1      cgd 
    202      1.1      cgd /*
    203  1.5.4.1  thorpej  * Adapter Variants
    204  1.5.4.1  thorpej  */
    205  1.5.4.1  thorpej #define	ISP_HA_SCSI		0xf
    206  1.5.4.1  thorpej #define	ISP_HA_SCSI_UNKNOWN	0x0
    207  1.5.4.1  thorpej #define	ISP_HA_SCSI_1020	0x1
    208  1.5.4.1  thorpej #define	ISP_HA_SCSI_1040A	0x2
    209  1.5.4.1  thorpej #define	ISP_HA_SCSI_1040B	0x3
    210  1.5.4.1  thorpej #define	ISP_HA_FC		0xf0
    211  1.5.4.1  thorpej #define	ISP_HA_FC_2100		0x10
    212  1.5.4.1  thorpej 
    213  1.5.4.1  thorpej /*
    214      1.1      cgd  * ISP States
    215      1.1      cgd  */
    216      1.1      cgd #define	ISP_NILSTATE	0
    217      1.1      cgd #define	ISP_RESETSTATE	1
    218      1.1      cgd #define	ISP_INITSTATE	2
    219      1.1      cgd #define	ISP_RUNSTATE	3
    220      1.1      cgd 
    221      1.1      cgd 
    222      1.1      cgd 
    223      1.1      cgd 
    224      1.1      cgd /*
    225      1.1      cgd  * Macros to read, write ISP registers through MD code
    226      1.1      cgd  */
    227      1.1      cgd 
    228      1.1      cgd #define	ISP_READ(isp, reg)	\
    229      1.1      cgd 	(*(isp)->isp_mdvec->dv_rd_reg)((isp), (reg))
    230      1.1      cgd 
    231      1.1      cgd #define	ISP_WRITE(isp, reg, val)	\
    232      1.1      cgd 	(*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), (val))
    233      1.1      cgd 
    234      1.5  thorpej #define	ISP_MBOXDMASETUP(isp)	\
    235      1.5  thorpej 	(*(isp)->isp_mdvec->dv_mbxdma)((isp))
    236      1.1      cgd 
    237      1.1      cgd #define	ISP_DMASETUP(isp, xs, req, iptrp, optr)	\
    238      1.1      cgd 	(*(isp)->isp_mdvec->dv_dmaset)((isp), (xs), (req), (iptrp), (optr))
    239      1.1      cgd 
    240      1.1      cgd #define	ISP_DMAFREE(isp, xs, seqno)	\
    241      1.1      cgd 	if ((isp)->isp_mdvec->dv_dmaclr) \
    242      1.1      cgd 		 (*(isp)->isp_mdvec->dv_dmaclr)((isp), (xs), (seqno))
    243      1.1      cgd 
    244      1.1      cgd #define	ISP_RESET0(isp)	\
    245      1.1      cgd 	if ((isp)->isp_mdvec->dv_reset0) (*(isp)->isp_mdvec->dv_reset0)((isp))
    246      1.1      cgd #define	ISP_RESET1(isp)	\
    247      1.1      cgd 	if ((isp)->isp_mdvec->dv_reset1) (*(isp)->isp_mdvec->dv_reset1)((isp))
    248  1.5.4.1  thorpej #define	ISP_DUMPREGS(isp)	\
    249  1.5.4.1  thorpej 	if ((isp)->isp_mdvec->dv_dregs) (*(isp)->isp_mdvec->dv_dregs)((isp))
    250      1.1      cgd 
    251      1.1      cgd #define	ISP_SETBITS(isp, reg, val)	\
    252      1.1      cgd  (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) | (val))
    253      1.1      cgd 
    254      1.1      cgd #define	ISP_CLRBITS(isp, reg, val)	\
    255      1.1      cgd  (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) & ~(val))
    256      1.1      cgd 
    257      1.1      cgd /*
    258      1.1      cgd  * Function Prototypes
    259      1.1      cgd  */
    260      1.1      cgd /*
    261      1.1      cgd  * Reset Hardware.
    262      1.1      cgd  *
    263      1.1      cgd  * Only looks at sc_dev.dv_xname, sc_iot and sc_ioh fields.
    264      1.1      cgd  */
    265      1.1      cgd void isp_reset __P((struct ispsoftc *));
    266      1.1      cgd 
    267      1.1      cgd /*
    268      1.1      cgd  * Initialize Hardware to known state
    269      1.1      cgd  */
    270      1.1      cgd void isp_init __P((struct ispsoftc *));
    271      1.1      cgd 
    272      1.1      cgd /*
    273      1.1      cgd  * Complete attachment of Hardware
    274      1.1      cgd  */
    275      1.1      cgd void isp_attach __P((struct ispsoftc *));
    276      1.1      cgd 
    277      1.1      cgd /*
    278      1.1      cgd  * Free any associated resources prior to decommissioning.
    279      1.1      cgd  */
    280      1.1      cgd void isp_uninit __P((struct ispsoftc *));
    281      1.1      cgd 
    282      1.1      cgd /*
    283      1.1      cgd  * Interrupt Service Routine
    284      1.1      cgd  */
    285      1.1      cgd int isp_intr __P((void *));
    286      1.1      cgd 
    287      1.1      cgd 
    288      1.1      cgd 
    289      1.1      cgd 
    290      1.1      cgd #endif	/* _ISPVAR_H */
    291