sfasvar.h revision 1.4 1 1.4 wiz /* $NetBSD: sfasvar.h,v 1.4 2003/11/10 08:51:51 wiz Exp $ */
2 1.1 reinoud
3 1.1 reinoud /*
4 1.1 reinoud * Copyright (c) 1995 Daniel Widenfalk
5 1.1 reinoud *
6 1.1 reinoud * Redistribution and use in source and binary forms, with or without
7 1.1 reinoud * modification, are permitted provided that the following conditions
8 1.1 reinoud * are met:
9 1.1 reinoud * 1. Redistributions of source code must retain the above copyright
10 1.1 reinoud * notice, this list of conditions and the following disclaimer.
11 1.1 reinoud * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 reinoud * notice, this list of conditions and the following disclaimer in the
13 1.1 reinoud * documentation and/or other materials provided with the distribution.
14 1.1 reinoud * 3. All advertising materials mentioning features or use of this software
15 1.1 reinoud * must display the following acknowledgement:
16 1.1 reinoud * This product includes software developed by Daniel Widenfalk
17 1.1 reinoud * for the NetBSD Project.
18 1.1 reinoud * 4. The name of the author may not be used to endorse or promote products
19 1.1 reinoud * derived from this software without specific prior written permission
20 1.1 reinoud *
21 1.1 reinoud * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 1.1 reinoud * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 1.1 reinoud * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 1.1 reinoud * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 1.1 reinoud * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 1.1 reinoud * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.1 reinoud * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.1 reinoud * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.1 reinoud * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 1.1 reinoud * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.1 reinoud */
32 1.1 reinoud
33 1.1 reinoud #ifndef _SFASVAR_H_
34 1.1 reinoud #define _SFASVAR_H_
35 1.1 reinoud
36 1.1 reinoud #ifndef _SFASREG_H_
37 1.1 reinoud #include <acorn32/podulebus/sfasreg.h>
38 1.1 reinoud #endif
39 1.1 reinoud
40 1.1 reinoud /*
41 1.1 reinoud * MAXCHAIN is the anticipated maximum number of chain blocks needed. This
42 1.1 reinoud * assumes that we are NEVER requested to transfer more than MAXPHYS bytes.
43 1.1 reinoud */
44 1.3 thorpej #define MAXCHAIN (MAXPHYS/PAGE_SIZE+2)
45 1.1 reinoud
46 1.1 reinoud /*
47 1.1 reinoud * Maximum number of requests standing by. Could be anything, but I think 9
48 1.1 reinoud * looks nice :-) NOTE: This does NOT include requests already started!
49 1.1 reinoud */
50 1.1 reinoud #define MAXPENDING 9 /* 7 IDs + 2 extra */
51 1.1 reinoud
52 1.1 reinoud /*
53 1.1 reinoud * DMA chain block. If flg == SFAS_CHAIN_PRG or flg == SFAS_CHAIN_BUMP then
54 1.4 wiz * ptr is a VIRTUAL address. If flg == SFAS_CHAIN_DMA then ptr is a PHYSICAL
55 1.4 wiz * address.
56 1.1 reinoud */
57 1.1 reinoud struct sfas_dma_chain {
58 1.2 chs void *ptr;
59 1.1 reinoud u_short len;
60 1.1 reinoud short flg;
61 1.1 reinoud };
62 1.1 reinoud #define SFAS_CHAIN_DMA 0x00
63 1.1 reinoud #define SFAS_CHAIN_BUMP 0x01
64 1.1 reinoud #define SFAS_CHAIN_PRG 0x02
65 1.1 reinoud
66 1.1 reinoud
67 1.1 reinoud /*
68 1.1 reinoud * This struct contains the necessary info for a pending request. Pointer to
69 1.1 reinoud * a scsipi_xfer struct.
70 1.1 reinoud */
71 1.1 reinoud struct sfas_pending {
72 1.1 reinoud TAILQ_ENTRY(sfas_pending) link;
73 1.1 reinoud struct scsipi_xfer *xs;
74 1.1 reinoud };
75 1.1 reinoud
76 1.1 reinoud /*
77 1.1 reinoud * nexus contains all active data for one SCSI unit. Parts of the info in this
78 1.1 reinoud * struct survives between scsi commands.
79 1.1 reinoud */
80 1.1 reinoud struct nexus {
81 1.1 reinoud struct scsipi_xfer *xs; /* Pointer to request */
82 1.1 reinoud
83 1.1 reinoud u_char ID; /* ID message to be sent */
84 1.1 reinoud u_char clen; /* scsi command length + */
85 1.1 reinoud u_char cbuf[14]; /* the actual command bytes */
86 1.1 reinoud
87 1.1 reinoud struct sfas_dma_chain dma[MAXCHAIN]; /* DMA chain blocks */
88 1.1 reinoud short max_link; /* Maximum used of above */
89 1.1 reinoud short cur_link; /* Currently handled block */
90 1.1 reinoud
91 1.4 wiz u_char *buf; /* Virtual address of data */
92 1.1 reinoud int len; /* Bytes left to transfer */
93 1.1 reinoud
94 1.4 wiz void *dma_buf; /* Current DMA address */
95 1.1 reinoud int dma_len; /* Current DMA length */
96 1.1 reinoud
97 1.4 wiz void *dma_blk_ptr; /* Current chain address */
98 1.1 reinoud int dma_blk_len; /* Current chain length */
99 1.1 reinoud u_char dma_blk_flg; /* Current chain flags */
100 1.1 reinoud
101 1.1 reinoud u_char state; /* Nexus state, see below */
102 1.1 reinoud u_short flags; /* Nexus flags, see below */
103 1.1 reinoud
104 1.1 reinoud short period; /* Sync period to request */
105 1.1 reinoud u_char offset; /* Sync offset to request */
106 1.1 reinoud
107 1.1 reinoud u_char syncper; /* FAS216 variable storage */
108 1.1 reinoud u_char syncoff; /* FAS216 variable storage */
109 1.1 reinoud u_char config3; /* FAS216 variable storage */
110 1.1 reinoud
111 1.1 reinoud u_char lun_unit; /* (Lun<<4) | Unit of nexus */
112 1.1 reinoud u_char status; /* Status byte from unit*/
113 1.1 reinoud };
114 1.1 reinoud
115 1.1 reinoud /* SCSI nexus_states */
116 1.1 reinoud #define SFAS_NS_IDLE 0 /* Nexus idle */
117 1.1 reinoud #define SFAS_NS_SELECTED 1 /* Last command was a SELECT command */
118 1.1 reinoud #define SFAS_NS_DATA_IN 2 /* Last command was a TRANSFER_INFO */
119 1.1 reinoud /* command during a data in phase */
120 1.1 reinoud #define SFAS_NS_DATA_OUT 3 /* Last command was a TRANSFER_INFO */
121 1.1 reinoud /* command during a data out phase */
122 1.1 reinoud #define SFAS_NS_STATUS 4 /* We have send a COMMAND_COMPLETE */
123 1.1 reinoud /* command and are awaiting status */
124 1.1 reinoud #define SFAS_NS_MSG_IN 5 /* Last phase was MESSAGE IN */
125 1.1 reinoud #define SFAS_NS_MSG_OUT 6 /* Last phase was MESSAGE OUT */
126 1.1 reinoud #define SFAS_NS_SVC 7 /* We have sent the command */
127 1.1 reinoud #define SFAS_NS_DISCONNECTING 8 /* We have received a disconnect msg */
128 1.1 reinoud #define SFAS_NS_DISCONNECTED 9 /* We are disconnected */
129 1.1 reinoud #define SFAS_NS_RESELECTED 10 /* We was reselected */
130 1.1 reinoud #define SFAS_NS_DONE 11 /* Done. Prephsase to FINISHED */
131 1.1 reinoud #define SFAS_NS_FINISHED 12 /* Realy done. Call scsi_done */
132 1.1 reinoud #define SFAS_NS_RESET 13 /* We are reseting this unit */
133 1.1 reinoud
134 1.1 reinoud /* SCSI nexus flags */
135 1.1 reinoud #define SFAS_NF_UNIT_BUSY 0x0001 /* Unit is not available */
136 1.1 reinoud
137 1.1 reinoud #define SFAS_NF_SELECT_ME 0x0002 /* Nexus is set up, waiting for bus */
138 1.1 reinoud
139 1.1 reinoud #define SFAS_NF_HAS_MSG 0x0010 /* We have received a complete msg */
140 1.1 reinoud
141 1.1 reinoud #define SFAS_NF_DO_SDTR 0x0020 /* We should send a SDTR */
142 1.1 reinoud #define SFAS_NF_SDTR_SENT 0x0040 /* We have sent a SDTR */
143 1.1 reinoud #define SFAS_NF_SYNC_TESTED 0x0080 /* We have negotiated sync */
144 1.1 reinoud
145 1.1 reinoud #define SFAS_NF_RESET 0x0100 /* Reset this nexus */
146 1.1 reinoud #define SFAS_NF_IMMEDIATE 0x0200 /* We are operating from sfasicmd */
147 1.1 reinoud
148 1.1 reinoud #define SFAS_NF_RETRY_SELECT 0x1000 /* Selection needs retrying */
149 1.1 reinoud
150 1.1 reinoud #define SFAS_NF_DEBUG 0x8000 /* As it says: DEBUG */
151 1.1 reinoud
152 1.1 reinoud struct sfas_softc {
153 1.1 reinoud struct device sc_dev; /* System required struct */
154 1.1 reinoud struct scsipi_channel sc_channel;
155 1.1 reinoud struct scsipi_adapter sc_adapter;
156 1.1 reinoud void *sc_ih;
157 1.1 reinoud struct evcnt sc_intrcnt;
158 1.1 reinoud
159 1.1 reinoud TAILQ_HEAD(,sfas_pending) sc_xs_pending;
160 1.1 reinoud TAILQ_HEAD(,sfas_pending) sc_xs_free;
161 1.1 reinoud struct sfas_pending sc_xs_store[MAXPENDING];
162 1.1 reinoud
163 1.1 reinoud sfas_regmap_p sc_fas; /* FAS216 Address */
164 1.1 reinoud void *sc_spec; /* Board-specific data */
165 1.1 reinoud
166 1.1 reinoud u_char *sc_bump_va; /* Bumpbuf virtual adr */
167 1.2 chs void *sc_bump_pa; /* Bumpbuf physical adr */
168 1.1 reinoud int sc_bump_sz; /* Bumpbuf size */
169 1.1 reinoud
170 1.1 reinoud /* Configuration registers, must be set BEFORE sfasinitialize */
171 1.1 reinoud u_char sc_clock_freq;
172 1.1 reinoud u_short sc_timeout;
173 1.1 reinoud u_char sc_host_id;
174 1.1 reinoud u_char sc_config_flags;
175 1.1 reinoud
176 1.1 reinoud /* Generic DMA functions */
177 1.2 chs int (*sc_setup_dma)(void *, void *, int, int);
178 1.2 chs int (*sc_build_dma_chain)(void *, void *, void *,
179 1.2 chs int);
180 1.2 chs int (*sc_need_bump)(void *, void *, int);
181 1.1 reinoud
182 1.1 reinoud /* Optional replacement ixfer */
183 1.2 chs void (*sc_ixfer)(void *, int);
184 1.1 reinoud
185 1.1 reinoud /* Generic Led data */
186 1.1 reinoud int sc_led_status;
187 1.2 chs void (*sc_led)(void *, int);
188 1.1 reinoud
189 1.1 reinoud /* Nexus list */
190 1.1 reinoud struct nexus sc_nexus[8];
191 1.1 reinoud struct nexus *sc_cur_nexus;
192 1.1 reinoud struct nexus *sc_sel_nexus;
193 1.1 reinoud
194 1.1 reinoud /* Current transfer data */
195 1.1 reinoud u_char *sc_buf; /* va */
196 1.1 reinoud int sc_len;
197 1.1 reinoud
198 1.2 chs void *sc_dma_buf; /* pa */
199 1.1 reinoud int sc_dma_len;
200 1.2 chs void *sc_dma_blk_ptr;
201 1.1 reinoud int sc_dma_blk_len;
202 1.1 reinoud short sc_dma_blk_flg;
203 1.1 reinoud
204 1.1 reinoud struct sfas_dma_chain *sc_chain; /* Current DMA chain */
205 1.1 reinoud short sc_max_link;
206 1.1 reinoud short sc_cur_link;
207 1.1 reinoud
208 1.1 reinoud /* Interrupt registers */
209 1.1 reinoud u_char sc_status;
210 1.1 reinoud u_char sc_interrupt;
211 1.1 reinoud u_char sc_resel[2];
212 1.1 reinoud
213 1.1 reinoud u_char sc_units_disconnected;
214 1.1 reinoud
215 1.1 reinoud /* Storage for FAS216 config registers (current values) */
216 1.1 reinoud u_char sc_config1;
217 1.1 reinoud u_char sc_config2;
218 1.1 reinoud u_char sc_config3;
219 1.1 reinoud u_char sc_clock_conv_fact;
220 1.1 reinoud u_char sc_timeout_val;
221 1.1 reinoud u_char sc_clock_period;
222 1.1 reinoud
223 1.1 reinoud u_char sc_msg_in[7];
224 1.1 reinoud u_char sc_msg_in_len;
225 1.1 reinoud
226 1.1 reinoud u_char sc_msg_out[7];
227 1.1 reinoud u_char sc_msg_out_len;
228 1.1 reinoud
229 1.1 reinoud u_char sc_unit;
230 1.1 reinoud u_char sc_lun;
231 1.1 reinoud u_char sc_flags;
232 1.1 reinoud };
233 1.1 reinoud
234 1.1 reinoud #define SFAS_DMA_READ 0
235 1.1 reinoud #define SFAS_DMA_WRITE 1
236 1.1 reinoud #define SFAS_DMA_CLEAR 2
237 1.1 reinoud
238 1.1 reinoud /* sc_flags */
239 1.1 reinoud #define SFAS_ACTIVE 0x01
240 1.1 reinoud #define SFAS_DONT_WAIT 0x02
241 1.1 reinoud
242 1.1 reinoud /* SCSI Selection modes */
243 1.1 reinoud #define SFAS_SELECT 0x00 /* Normal selection: No sync, no resel */
244 1.1 reinoud #define SFAS_SELECT_R 0x01 /* Reselection allowed */
245 1.1 reinoud #define SFAS_SELECT_S 0x02 /* Synchronous transfer allowed */
246 1.1 reinoud #define SFAS_SELECT_I 0x04 /* Selection for sfasicmd */
247 1.1 reinoud #define SFAS_SELECT_K 0x08 /* Send a BUS DEVICE RESET message (Kill) */
248 1.1 reinoud
249 1.1 reinoud /* Nice abbreviations of the above */
250 1.1 reinoud #define SFAS_SELECT_RS (SFAS_SELECT_R|SFAS_SELECT_S)
251 1.1 reinoud #define SFAS_SELECT_RI (SFAS_SELECT_R|SFAS_SELECT_I)
252 1.1 reinoud #define SFAS_SELECT_SI (SFAS_SELECT_S|SFAS_SELECT_I)
253 1.1 reinoud #define SFAS_SELECT_RSI (SFAS_SELECT_R|SFAS_SELECT_S|SFAS_SELECT_I)
254 1.1 reinoud
255 1.1 reinoud /* sc_config_flags */
256 1.1 reinoud #define SFAS_NO_SYNCH 0x01 /* Disable synchronous transfer */
257 1.1 reinoud #define SFAS_NO_DMA 0x02 /* Do not use DMA! EVER! */
258 1.1 reinoud #define SFAS_NO_RESELECT 0x04 /* Do not allow relesection */
259 1.1 reinoud #define SFAS_SLOW_CABLE 0x08 /* Cable is "unsafe" for fast scsi-2 */
260 1.1 reinoud #define SFAS_SLOW_START 0x10 /* There are slow starters on the bus */
261 1.1 reinoud
262 1.1 reinoud void sfasinitialize __P((struct sfas_softc *sc));
263 1.1 reinoud void sfas_minphys __P((struct buf *bp));
264 1.1 reinoud void sfas_scsi_request __P((struct scsipi_channel *,
265 1.1 reinoud scsipi_adapter_req_t, void *));
266 1.1 reinoud void sfasintr __P((struct sfas_softc *dev));
267 1.1 reinoud
268 1.1 reinoud #endif /* _SFASVAR_H_ */
269