ispvar.h revision 1.1 1 1.1 cgd /* $NetBSD: ispvar.h,v 1.1 1997/03/12 20:44:51 cgd 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.1 cgd * Copyright (c) 1997 by Matthew Jacob (for NASA/Ames Research Center)
7 1.1 cgd * All rights reserved.
8 1.1 cgd *
9 1.1 cgd * Redistribution and use in source and binary forms, with or without
10 1.1 cgd * modification, are permitted provided that the following conditions
11 1.1 cgd * are met:
12 1.1 cgd * 1. Redistributions of source code must retain the above copyright
13 1.1 cgd * notice immediately at the beginning of the file, without modification,
14 1.1 cgd * this list of conditions, and the following disclaimer.
15 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 cgd * notice, this list of conditions and the following disclaimer in the
17 1.1 cgd * documentation and/or other materials provided with the distribution.
18 1.1 cgd * 3. The name of the author may not be used to endorse or promote products
19 1.1 cgd * derived from this software without specific prior written permission.
20 1.1 cgd *
21 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
22 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
25 1.1 cgd * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 1.1 cgd * SUCH DAMAGE.
32 1.1 cgd *
33 1.1 cgd */
34 1.1 cgd #ifndef _ISPVAR_H
35 1.1 cgd #define _ISPVAR_H
36 1.1 cgd
37 1.1 cgd #include <dev/ic/ispmbox.h>
38 1.1 cgd
39 1.1 cgd /*
40 1.1 cgd * Vector for MD code to provide specific services.
41 1.1 cgd */
42 1.1 cgd struct ispsoftc;
43 1.1 cgd struct ispmdvec {
44 1.1 cgd u_int16_t (*dv_rd_reg) __P((struct ispsoftc *, int));
45 1.1 cgd void (*dv_wr_reg) __P((struct ispsoftc *, int, u_int16_t));
46 1.1 cgd vm_offset_t (*dv_mbxdma)
47 1.1 cgd __P((struct ispsoftc *, vm_offset_t, u_int32_t));
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.1 cgd u_int16_t * dv_ispfw; /* ptr to f/w */
55 1.1 cgd u_int16_t dv_fwlen; /* length of f/w */
56 1.1 cgd u_int16_t dv_codeorg; /* code ORG for f/w */
57 1.1 cgd /*
58 1.1 cgd * Initial values for conf1 register
59 1.1 cgd */
60 1.1 cgd u_int16_t dv_conf1;
61 1.1 cgd };
62 1.1 cgd
63 1.1 cgd #define MAX_TARGETS 16
64 1.1 cgd #define MAX_LUNS 8
65 1.1 cgd
66 1.1 cgd #define RQUEST_QUEUE_LEN 256
67 1.1 cgd #define RESULT_QUEUE_LEN (RQUEST_QUEUE_LEN >> 3)
68 1.1 cgd #define QENTRY_LEN 64
69 1.1 cgd
70 1.1 cgd /*
71 1.1 cgd * Soft Structure per host adapter
72 1.1 cgd */
73 1.1 cgd struct ispsoftc {
74 1.1 cgd struct device isp_dev;
75 1.1 cgd struct ispmdvec * isp_mdvec;
76 1.1 cgd #define isp_name isp_dev.dv_xname
77 1.1 cgd struct scsi_link isp_link;
78 1.1 cgd u_int8_t isp_max_target;
79 1.1 cgd u_int8_t isp_state;
80 1.1 cgd /*
81 1.1 cgd * Host Adapter Parameters, nominally stored in NVRAM
82 1.1 cgd */
83 1.1 cgd u_int16_t isp_adapter_enabled : 1,
84 1.1 cgd isp_req_ack_active_neg : 1,
85 1.1 cgd isp_data_line_active_neg: 1,
86 1.1 cgd isp_cmd_dma_burst_enable: 1,
87 1.1 cgd isp_data_dma_burst_enabl: 1,
88 1.1 cgd isp_fifo_threshold : 2,
89 1.1 cgd : 1,
90 1.1 cgd isp_initiator_id : 4,
91 1.1 cgd isp_async_data_setup : 4;
92 1.1 cgd u_int16_t isp_selection_timeout;
93 1.1 cgd u_int16_t isp_max_queue_depth;
94 1.1 cgd u_int8_t isp_tag_aging;
95 1.1 cgd u_int8_t isp_bus_reset_delay;
96 1.1 cgd u_int8_t isp_retry_count;
97 1.1 cgd u_int8_t isp_retry_delay;
98 1.1 cgd struct {
99 1.1 cgd u_int8_t dev_flags; /* Device Flags - see below */
100 1.1 cgd u_int8_t exc_throttle;
101 1.1 cgd u_int8_t sync_period;
102 1.1 cgd u_int8_t sync_offset : 4,
103 1.1 cgd dev_enable : 1;
104 1.1 cgd } isp_devparam[MAX_TARGETS];
105 1.1 cgd /*
106 1.1 cgd * Result and Request Queues.
107 1.1 cgd */
108 1.1 cgd volatile u_int8_t isp_reqidx; /* index of next request */
109 1.1 cgd volatile u_int8_t isp_residx; /* index of next result */
110 1.1 cgd volatile u_int8_t isp_sendmarker;
111 1.1 cgd volatile u_int8_t isp_seqno;
112 1.1 cgd /*
113 1.1 cgd * Sheer laziness, but it gets us around the problem
114 1.1 cgd * where we don't have a clean way of remembering
115 1.1 cgd * which scsi_xfer is bound to which ISP queue entry.
116 1.1 cgd *
117 1.1 cgd * There are other more clever ways to do this, but,
118 1.1 cgd * jeez, so I blow a couple of KB per host adapter...
119 1.1 cgd * and it *is* faster.
120 1.1 cgd */
121 1.1 cgd volatile struct scsi_xfer *isp_xflist[RQUEST_QUEUE_LEN];
122 1.1 cgd /*
123 1.1 cgd * request/result queue
124 1.1 cgd */
125 1.1 cgd volatile u_int8_t isp_rquest[RQUEST_QUEUE_LEN][QENTRY_LEN];
126 1.1 cgd volatile u_int8_t isp_result[RESULT_QUEUE_LEN][QENTRY_LEN];
127 1.1 cgd };
128 1.1 cgd
129 1.1 cgd /*
130 1.1 cgd * ISP States
131 1.1 cgd */
132 1.1 cgd #define ISP_NILSTATE 0
133 1.1 cgd #define ISP_RESETSTATE 1
134 1.1 cgd #define ISP_INITSTATE 2
135 1.1 cgd #define ISP_RUNSTATE 3
136 1.1 cgd
137 1.1 cgd
138 1.1 cgd /*
139 1.1 cgd * Device Flags
140 1.1 cgd */
141 1.1 cgd #define DPARM_DISC 0x80
142 1.1 cgd #define DPARM_PARITY 0x40
143 1.1 cgd #define DPARM_WIDE 0x20
144 1.1 cgd #define DPARM_SYNC 0x10
145 1.1 cgd #define DPARM_TQING 0x08
146 1.1 cgd #define DPARM_ARQ 0x04
147 1.1 cgd #define DPARM_QFRZ 0x02
148 1.1 cgd #define DPARM_RENEG 0x01
149 1.1 cgd
150 1.1 cgd #define DPARM_DEFAULT (0xff & ~DPARM_QFRZ)
151 1.1 cgd
152 1.1 cgd
153 1.1 cgd /*
154 1.1 cgd * Macros to read, write ISP registers through MD code
155 1.1 cgd */
156 1.1 cgd
157 1.1 cgd #define ISP_READ(isp, reg) \
158 1.1 cgd (*(isp)->isp_mdvec->dv_rd_reg)((isp), (reg))
159 1.1 cgd
160 1.1 cgd #define ISP_WRITE(isp, reg, val) \
161 1.1 cgd (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), (val))
162 1.1 cgd
163 1.1 cgd #define ISP_MBOXDMASETUP(isp, kva, len) \
164 1.1 cgd (*(isp)->isp_mdvec->dv_mbxdma)((isp), (vm_offset_t) (kva), (len))
165 1.1 cgd
166 1.1 cgd #define ISP_DMASETUP(isp, xs, req, iptrp, optr) \
167 1.1 cgd (*(isp)->isp_mdvec->dv_dmaset)((isp), (xs), (req), (iptrp), (optr))
168 1.1 cgd
169 1.1 cgd #define ISP_DMAFREE(isp, xs, seqno) \
170 1.1 cgd if ((isp)->isp_mdvec->dv_dmaclr) \
171 1.1 cgd (*(isp)->isp_mdvec->dv_dmaclr)((isp), (xs), (seqno))
172 1.1 cgd
173 1.1 cgd #define ISP_RESET0(isp) \
174 1.1 cgd if ((isp)->isp_mdvec->dv_reset0) (*(isp)->isp_mdvec->dv_reset0)((isp))
175 1.1 cgd #define ISP_RESET1(isp) \
176 1.1 cgd if ((isp)->isp_mdvec->dv_reset1) (*(isp)->isp_mdvec->dv_reset1)((isp))
177 1.1 cgd
178 1.1 cgd
179 1.1 cgd #define ISP_SETBITS(isp, reg, val) \
180 1.1 cgd (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) | (val))
181 1.1 cgd
182 1.1 cgd #define ISP_CLRBITS(isp, reg, val) \
183 1.1 cgd (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) & ~(val))
184 1.1 cgd
185 1.1 cgd /*
186 1.1 cgd * Function Prototypes
187 1.1 cgd */
188 1.1 cgd /*
189 1.1 cgd * Reset Hardware.
190 1.1 cgd *
191 1.1 cgd * Only looks at sc_dev.dv_xname, sc_iot and sc_ioh fields.
192 1.1 cgd */
193 1.1 cgd void isp_reset __P((struct ispsoftc *));
194 1.1 cgd
195 1.1 cgd /*
196 1.1 cgd * Initialize Hardware to known state
197 1.1 cgd */
198 1.1 cgd void isp_init __P((struct ispsoftc *));
199 1.1 cgd
200 1.1 cgd /*
201 1.1 cgd * Complete attachment of Hardware
202 1.1 cgd */
203 1.1 cgd void isp_attach __P((struct ispsoftc *));
204 1.1 cgd
205 1.1 cgd /*
206 1.1 cgd * Free any associated resources prior to decommissioning.
207 1.1 cgd */
208 1.1 cgd void isp_uninit __P((struct ispsoftc *));
209 1.1 cgd
210 1.1 cgd /*
211 1.1 cgd * Interrupt Service Routine
212 1.1 cgd */
213 1.1 cgd int isp_intr __P((void *));
214 1.1 cgd
215 1.1 cgd
216 1.1 cgd
217 1.1 cgd
218 1.1 cgd #endif /* _ISPVAR_H */
219