1 /* $NetBSD: escvar.h,v 1.6 2005/12/11 12:16:05 christos Exp $ */
4 * Copyright (c) 1995 Daniel Widenfalk
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Daniel Widenfalk
17 * for the NetBSD Project.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 #include <acorn32/podulebus/escreg.h>
41 * MAXCHAIN is the anticipated maximum number of chain blocks needed. This
42 * assumes that we are NEVER requested to transfer more than MAXPHYS bytes.
44 #define MAXCHAIN (MAXPHYS/PAGE_SIZE+2)
47 * Maximum number of requests standing by. Could be anything, but I think 9
48 * looks nice :-) NOTE: This does NOT include requests already started!
50 #define MAXPENDING 9 /* 7 IDs + 2 extra */
53 * DMA chain block. If flg == ESC_CHAIN_PRG or flg == ESC_CHAIN_BUMP then
54 * ptr is a VIRTUAL address. If flg == ESC_CHAIN_DMA then ptr is a PHYSICAL
57 struct esc_dma_chain
{
62 #define ESC_CHAIN_DMA 0x00
63 #define ESC_CHAIN_BUMP 0x01
64 #define ESC_CHAIN_PRG 0x02
68 * This struct contains the necessary info for a pending request. Pointer to
69 * a scsipi_xfer struct.
72 TAILQ_ENTRY(esc_pending
) link
;
73 struct scsipi_xfer
*xs
;
77 * nexus contains all active data for one SCSI unit. Parts of the info in this
78 * struct survives between scsi commands.
81 struct scsipi_xfer
*xs
; /* Pointer to request */
83 u_char ID
; /* ID message to be sent */
84 u_char clen
; /* scsi command length + */
85 u_char cbuf
[14]; /* the actual command bytes */
87 struct esc_dma_chain dma
[MAXCHAIN
]; /* DMA chain blocks */
88 short max_link
; /* Maximum used of above */
89 short cur_link
; /* Currently handled block */
91 u_char
*buf
; /* Virtual address of data */
92 int len
; /* Bytes left to transfer */
94 void *dma_buf
; /* Current DMA address */
95 int dma_len
; /* Current DMA length */
97 void *dma_blk_ptr
; /* Current chain address */
98 int dma_blk_len
; /* Current chain length */
99 u_char dma_blk_flg
; /* Current chain flags */
101 u_char state
; /* Nexus state, see below */
102 u_short flags
; /* Nexus flags, see below */
104 short period
; /* Sync period to request */
105 u_char offset
; /* Sync offset to request */
107 u_char syncper
; /* FAS216 variable storage */
108 u_char syncoff
; /* FAS216 variable storage */
109 u_char config3
; /* FAS216 variable storage */
111 u_char lun_unit
; /* (Lun<<4) | Unit of nexus */
112 u_char status
; /* Status byte from unit*/
116 /* SCSI nexus_states */
117 #define ESC_NS_IDLE 0 /* Nexus idle */
118 #define ESC_NS_SELECTED 1 /* Last command was a SELECT command */
119 #define ESC_NS_DATA_IN 2 /* Last command was a TRANSFER_INFO */
120 /* command during a data in phase */
121 #define ESC_NS_DATA_OUT 3 /* Last command was a TRANSFER_INFO */
122 /* command during a data out phase */
123 #define ESC_NS_STATUS 4 /* We have send a COMMAND_COMPLETE */
124 /* command and are awaiting status */
125 #define ESC_NS_MSG_IN 5 /* Last phase was MESSAGE IN */
126 #define ESC_NS_MSG_OUT 6 /* Last phase was MESSAGE OUT */
127 #define ESC_NS_SVC 7 /* We have sent the command */
128 #define ESC_NS_DISCONNECTING 8 /* We have received a disconnect msg */
129 #define ESC_NS_DISCONNECTED 9 /* We are disconnected */
130 #define ESC_NS_RESELECTED 10 /* We was reselected */
131 #define ESC_NS_DONE 11 /* Done. Prephsase to FINISHED */
132 #define ESC_NS_FINISHED 12 /* Realy done. Call scsi_done */
133 #define ESC_NS_RESET 13 /* We are reseting this unit */
135 /* SCSI nexus flags */
136 #define ESC_NF_UNIT_BUSY 0x0001 /* Unit is not available */
138 #define ESC_NF_SELECT_ME 0x0002 /* Nexus is set up, waiting for bus */
140 #define ESC_NF_HAS_MSG 0x0010 /* We have received a complete msg */
142 #define ESC_NF_DO_SDTR 0x0020 /* We should send a SDTR */
143 #define ESC_NF_SDTR_SENT 0x0040 /* We have sent a SDTR */
144 #define ESC_NF_SYNC_TESTED 0x0080 /* We have negotiated sync */
146 #define ESC_NF_RESET 0x0100 /* Reset this nexus */
147 #define ESC_NF_IMMEDIATE 0x0200 /* We are operating from escicmd */
149 #define ESC_NF_RETRY_SELECT 0x1000 /* Selection needs retrying */
151 #define ESC_NF_DEBUG 0x8000 /* As it says: DEBUG */
154 struct device sc_dev
; /* System required struct */
155 struct scsipi_channel sc_channel
; /* For sub devices */
156 struct scsipi_adapter sc_adapter
;
157 irqhandler_t sc_ih
; /* Interrupt chain struct */
159 TAILQ_HEAD(,esc_pending
) sc_xs_pending
;
160 TAILQ_HEAD(,esc_pending
) sc_xs_free
;
161 struct esc_pending sc_xs_store
[MAXPENDING
];
163 esc_regmap_p sc_esc
; /* FAS216 Address */
164 void *sc_spec
; /* Board-specific data */
166 u_char
*sc_bump_va
; /* Bumpbuf virtual adr */
167 void *sc_bump_pa
; /* Bumpbuf physical adr */
168 int sc_bump_sz
; /* Bumpbuf size */
170 /* Configuration registers, must be set BEFORE escinitialize */
171 u_char sc_clock_freq
;
174 u_char sc_config_flags
;
176 /* Generic DMA functions */
177 int (*sc_setup_dma
)(struct esc_softc
*, void *,
179 int (*sc_build_dma_chain
)(struct esc_softc
*,
180 struct esc_dma_chain
*, void *, int);
181 int (*sc_need_bump
)(struct esc_softc
*, void *,
184 /* Generic Led data */
186 void (*sc_led
)(struct esc_softc
*, int);
189 struct nexus sc_nexus
[8];
190 struct nexus
*sc_cur_nexus
;
191 struct nexus
*sc_sel_nexus
;
193 /* Current transfer data */
194 u_char
*sc_buf
; /* va */
197 void *sc_dma_buf
; /* pa */
199 void *sc_dma_blk_ptr
;
201 short sc_dma_blk_flg
;
203 struct esc_dma_chain
*sc_chain
; /* Current DMA chain */
207 /* Interrupt registers */
212 u_char sc_units_disconnected
;
214 /* Storage for FAS216 config registers (current values) */
219 u_char sc_clock_conv_fact
;
220 u_char sc_timeout_val
;
221 u_char sc_clock_period
;
224 u_char sc_msg_in_len
;
226 u_char sc_msg_out
[7];
227 u_char sc_msg_out_len
;
234 #define ESC_DMA_READ 0
235 #define ESC_DMA_WRITE 1
236 #define ESC_DMA_CLEAR 2
239 #define ESC_ACTIVE 0x01
240 #define ESC_DONT_WAIT 0x02
242 /* SCSI Selection modes */
243 #define ESC_SELECT 0x00 /* Normal selection: No sync, no resel */
244 #define ESC_SELECT_R 0x01 /* Reselection allowed */
245 #define ESC_SELECT_S 0x02 /* Synchronous transfer allowed */
246 #define ESC_SELECT_I 0x04 /* Selection for escicmd */
247 #define ESC_SELECT_K 0x08 /* Send a BUS DEVICE RESET message (Kill) */
249 /* Nice abbreviations of the above */
250 #define ESC_SELECT_RS (ESC_SELECT_R|ESC_SELECT_S)
251 #define ESC_SELECT_RI (ESC_SELECT_R|ESC_SELECT_I)
252 #define ESC_SELECT_SI (ESC_SELECT_S|ESC_SELECT_I)
253 #define ESC_SELECT_RSI (ESC_SELECT_R|ESC_SELECT_S|ESC_SELECT_I)
255 /* sc_config_flags */
256 #define ESC_NO_SYNCH 0x01 /* Disable synchronous transfer */
257 #define ESC_NO_DMA 0x02 /* Do not use DMA! EVER! */
258 #define ESC_NO_RESELECT 0x04 /* Do not allow relesection */
259 #define ESC_SLOW_CABLE 0x08 /* Cable is "unsafe" for fast scsi-2 */
260 #define ESC_SLOW_START 0x10 /* There are slow starters on the bus */
262 void escinitialize(struct esc_softc
*sc
);
263 void esc_minphys(struct buf
*bp
);
264 void esc_scsi_request(struct scsipi_channel
*,
265 scsipi_adapter_req_t
, void *);
266 void escintr(struct esc_softc
*dev
);
268 #endif /* _ESCVAR_H_ */