1 |
/* gxemul: $Id: wdsc_sbicreg.h,v 1.2 2005/03/05 12:34:03 debug Exp $ */ |
2 |
/* $NetBSD: sbicreg.h,v 1.4 2002/03/13 13:12:27 simonb Exp $ */ |
3 |
|
4 |
/* |
5 |
* Copyright (c) 2001 Wayne Knowles |
6 |
* Copyright (c) 1990 The Regents of the University of California. |
7 |
* All rights reserved. |
8 |
* |
9 |
* This code is derived from software contributed to Berkeley by |
10 |
* Van Jacobson of Lawrence Berkeley Laboratory. |
11 |
* |
12 |
* Redistribution and use in source and binary forms, with or without |
13 |
* modification, are permitted provided that the following conditions |
14 |
* are met: |
15 |
* 1. Redistributions of source code must retain the above copyright |
16 |
* notice, this list of conditions and the following disclaimer. |
17 |
* 2. Redistributions in binary form must reproduce the above copyright |
18 |
* notice, this list of conditions and the following disclaimer in the |
19 |
* documentation and/or other materials provided with the distribution. |
20 |
* 3. All advertising materials mentioning features or use of this software |
21 |
* must display the following acknowledgement: |
22 |
* This product includes software developed by the University of |
23 |
* California, Berkeley and its contributors. |
24 |
* 4. Neither the name of the University nor the names of its contributors |
25 |
* may be used to endorse or promote products derived from this software |
26 |
* without specific prior written permission. |
27 |
* |
28 |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
29 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
30 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
31 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
32 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
33 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
34 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
35 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
36 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
37 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
38 |
* SUCH DAMAGE. |
39 |
* |
40 |
* @(#)scsireg.h 7.3 (Berkeley) 2/5/91 |
41 |
*/ |
42 |
|
43 |
/* |
44 |
* WD33C93 SCSI interface hardware description. |
45 |
* |
46 |
* Using parts of the Mach scsi driver for the 33C93 |
47 |
*/ |
48 |
|
49 |
#define SBIC_myid 0 |
50 |
#define SBIC_cdbsize 0 |
51 |
#define SBIC_control 1 |
52 |
#define SBIC_timeo 2 |
53 |
#define SBIC_cdb1 3 |
54 |
#define SBIC_tsecs 3 |
55 |
#define SBIC_cdb2 4 |
56 |
#define SBIC_theads 4 |
57 |
#define SBIC_cdb3 5 |
58 |
#define SBIC_tcyl_hi 5 |
59 |
#define SBIC_cdb4 6 |
60 |
#define SBIC_tcyl_lo 6 |
61 |
#define SBIC_cdb5 7 |
62 |
#define SBIC_addr_hi 7 |
63 |
#define SBIC_cdb6 8 |
64 |
#define SBIC_addr_2 8 |
65 |
#define SBIC_cdb7 9 |
66 |
#define SBIC_addr_3 9 |
67 |
#define SBIC_cdb8 10 |
68 |
#define SBIC_addr_lo 10 |
69 |
#define SBIC_cdb9 11 |
70 |
#define SBIC_secno 11 |
71 |
#define SBIC_cdb10 12 |
72 |
#define SBIC_headno 12 |
73 |
#define SBIC_cdb11 13 |
74 |
#define SBIC_cylno_hi 13 |
75 |
#define SBIC_cdb12 14 |
76 |
#define SBIC_cylno_lo 14 |
77 |
#define SBIC_tlun 15 |
78 |
#define SBIC_cmd_phase 16 |
79 |
#define SBIC_syn 17 |
80 |
#define SBIC_count_hi 18 |
81 |
#define SBIC_count_med 19 |
82 |
#define SBIC_count_lo 20 |
83 |
#define SBIC_selid 21 |
84 |
#define SBIC_rselid 22 |
85 |
#define SBIC_csr 23 |
86 |
#define SBIC_cmd 24 |
87 |
#define SBIC_data 25 |
88 |
#define SBIC_queue_tag 26 |
89 |
#define SBIC_aux_status 27 |
90 |
|
91 |
/* wd33c93_asr is addressed directly */ |
92 |
|
93 |
/* |
94 |
* Register defines |
95 |
*/ |
96 |
|
97 |
/* |
98 |
* Auxiliary Status Register |
99 |
*/ |
100 |
|
101 |
#define SBIC_ASR_INT 0x80 /* Interrupt pending */ |
102 |
#define SBIC_ASR_LCI 0x40 /* Last command ignored */ |
103 |
#define SBIC_ASR_BSY 0x20 /* Busy, only cmd/data/asr readable */ |
104 |
#define SBIC_ASR_CIP 0x10 /* Busy, cmd unavail also */ |
105 |
#define SBIC_ASR_xxx 0x0c |
106 |
#define SBIC_ASR_PE 0x02 /* Parity error (even) */ |
107 |
#define SBIC_ASR_DBR 0x01 /* Data Buffer Ready */ |
108 |
|
109 |
/* |
110 |
* My ID register, and/or CDB Size |
111 |
*/ |
112 |
|
113 |
#define SBIC_ID_FS_8_10 0x00 /* Input clock is 8-10 Mhz */ |
114 |
/* 11 Mhz is invalid */ |
115 |
#define SBIC_ID_FS_12_15 0x40 /* Input clock is 12-15 Mhz */ |
116 |
#define SBIC_ID_FS_16_20 0x80 /* Input clock is 16-20 Mhz */ |
117 |
#define SBIC_ID_RAF 0x20 /* */ |
118 |
#define SBIC_ID_EHP 0x10 /* Enable host parity */ |
119 |
#define SBIC_ID_EAF 0x08 /* Enable Advanced Features */ |
120 |
#define SBIC_ID_MASK 0x07 |
121 |
#define SBIC_ID_CBDSIZE_MASK 0x0f /* if unk SCSI cmd group */ |
122 |
|
123 |
/* |
124 |
* Control register |
125 |
*/ |
126 |
|
127 |
#define SBIC_CTL_DMA 0x80 /* Single byte dma */ |
128 |
#define SBIC_CTL_DBA_DMA 0x40 /* direct buffer acces (bus master)*/ |
129 |
#define SBIC_CTL_BURST_DMA 0x20 /* continuous mode (8237) */ |
130 |
#define SBIC_CTL_NO_DMA 0x00 /* Programmed I/O */ |
131 |
#define SBIC_CTL_HHP 0x10 /* Halt on host parity error */ |
132 |
#define SBIC_CTL_EDI 0x08 /* Ending disconnect interrupt */ |
133 |
#define SBIC_CTL_IDI 0x04 /* Intermediate disconnect interrupt*/ |
134 |
#define SBIC_CTL_HA 0x02 /* Halt on ATN */ |
135 |
#define SBIC_CTL_HSP 0x01 /* Halt on SCSI parity error */ |
136 |
|
137 |
/* |
138 |
* Timeout period register |
139 |
* [val in msecs, input clk in 0.1 Mhz] |
140 |
*/ |
141 |
|
142 |
#define SBIC_TIMEOUT(val,clk) ((((val) * (clk)) / 800) + 1) |
143 |
|
144 |
/* |
145 |
* CDBn registers, note that |
146 |
* cdb11 is used for status byte in target mode (send-status-and-cc) |
147 |
* cdb12 sez if linked command complete, and w/flag if so |
148 |
*/ |
149 |
|
150 |
/* |
151 |
* Target LUN register |
152 |
* [holds target status when select-and-xfer] |
153 |
*/ |
154 |
|
155 |
#define SBIC_TLUN_VALID 0x80 /* did we receive an Identify msg */ |
156 |
#define SBIC_TLUN_DOK 0x40 /* Disconnect OK */ |
157 |
#define SBIC_TLUN_xxx 0x38 |
158 |
#define SBIC_TLUN_MASK 0x07 |
159 |
|
160 |
/* |
161 |
* Command Phase register |
162 |
*/ |
163 |
|
164 |
#define SBIC_CPH_MASK 0x7f /* values/restarts are cmd specific */ |
165 |
#define SBIC_CPH(p) ((p) & SBIC_CPH_MASK) |
166 |
|
167 |
/* |
168 |
* FIFO register |
169 |
*/ |
170 |
|
171 |
#define SBIC_FIFO_DEEP 12 |
172 |
|
173 |
/* |
174 |
* maximum possible size in TC registers. Since this is 24 bit, it's easy |
175 |
*/ |
176 |
#define SBIC_TC_MAX ((1 << 24) - 1) |
177 |
|
178 |
/* |
179 |
* Synchronous xfer register |
180 |
*/ |
181 |
|
182 |
#define SBIC_SYN_OFF_MASK 0x0f |
183 |
#define SBIC_SYN_MAX_OFFSET SBIC_FIFO_DEEP |
184 |
#define SBIC_SYN_PER_MASK 0x70 |
185 |
#define SBIC_SYN_MIN_PERIOD 2 /* upto 8, encoded as 0 */ |
186 |
|
187 |
#define SBIC_SYN(o,p) \ |
188 |
(((o) & SBIC_SYN_OFF_MASK) | (((p) << 4) & SBIC_SYN_PER_MASK)) |
189 |
|
190 |
/* |
191 |
* Transfer count register |
192 |
* optimal access macros depend on addressing |
193 |
*/ |
194 |
|
195 |
/* |
196 |
* Destination ID (selid) register |
197 |
*/ |
198 |
|
199 |
#define SBIC_SID_SCC 0x80 /* Select command chaining (tgt) */ |
200 |
#define SBIC_SID_DPD 0x40 /* Data phase direction (inittor) */ |
201 |
#define SBIC_SID_FROM_SCSI 0x40 |
202 |
#define SBIC_SID_TO_SCSI 0x00 |
203 |
#define SBIC_SID_xxx 0x38 |
204 |
#define SBIC_SID_IDMASK 0x07 |
205 |
|
206 |
/* |
207 |
* Source ID (rselid) register |
208 |
*/ |
209 |
|
210 |
#define SBIC_RID_ER 0x80 /* Enable reselection */ |
211 |
#define SBIC_RID_ES 0x40 /* Enable selection */ |
212 |
#define SBIC_RID_DSP 0x20 /* Disable select parity */ |
213 |
#define SBIC_RID_SIV 0x08 /* Source ID valid */ |
214 |
#define SBIC_RID_MASK 0x07 |
215 |
|
216 |
/* |
217 |
* Status register |
218 |
*/ |
219 |
|
220 |
#define SBIC_CSR_CAUSE 0xf0 |
221 |
#define SBIC_CSR_RESET 0x00 /* chip was reset */ |
222 |
#define SBIC_CSR_CMD_DONE 0x10 /* cmd completed */ |
223 |
#define SBIC_CSR_CMD_STOPPED 0x20 /* interrupted or abrted*/ |
224 |
#define SBIC_CSR_CMD_ERR 0x40 /* end with error */ |
225 |
#define SBIC_CSR_BUS_SERVICE 0x80 /* REQ pending on the bus */ |
226 |
|
227 |
|
228 |
#define SBIC_CSR_QUALIFIER 0x0f |
229 |
/* Reset State Interrupts */ |
230 |
#define SBIC_CSR_RESET 0x00 /* reset w/advanced features*/ |
231 |
#define SBIC_CSR_RESET_AM 0x01 /* reset w/advanced features*/ |
232 |
/* Successful Completion Interrupts */ |
233 |
#define SBIC_CSR_TARGET 0x10 /* reselect complete */ |
234 |
#define SBIC_CSR_INITIATOR 0x11 /* select complete */ |
235 |
#define SBIC_CSR_WO_ATN 0x13 /* tgt mode completion */ |
236 |
#define SBIC_CSR_W_ATN 0x14 /* ditto */ |
237 |
#define SBIC_CSR_XLATED 0x15 /* translate address cmd */ |
238 |
#define SBIC_CSR_S_XFERRED 0x16 /* initiator mode completion*/ |
239 |
#define SBIC_CSR_XFERRED 0x18 /* phase in low bits */ |
240 |
/* Paused or Aborted Interrupts */ |
241 |
#define SBIC_CSR_MSGIN_W_ACK 0x20 /* (I) msgin, ACK asserted*/ |
242 |
#define SBIC_CSR_SDP 0x21 /* (I) SDP msg received */ |
243 |
#define SBIC_CSR_SEL_ABRT 0x22 /* sel/resel aborted */ |
244 |
#define SBIC_CSR_XFR_PAUSED 0x23 /* (T) no ATN */ |
245 |
#define SBIC_CSR_XFR_PAUSED_ATN 0x24 /* (T) ATN is asserted */ |
246 |
#define SBIC_CSR_RSLT_AM 0x27 /* (I) lost selection (AM) */ |
247 |
#define SBIC_CSR_MIS 0x28 /* (I) xfer aborted, ph mis */ |
248 |
/* Terminated Interrupts */ |
249 |
#define SBIC_CSR_CMD_INVALID 0x40 |
250 |
#define SBIC_CSR_DISC 0x41 /* (I) tgt disconnected */ |
251 |
#define SBIC_CSR_SEL_TIMEO 0x42 |
252 |
#define SBIC_CSR_PE 0x43 /* parity error */ |
253 |
#define SBIC_CSR_PE_ATN 0x44 /* ditto, ATN is asserted */ |
254 |
#define SBIC_CSR_XLATE_TOOBIG 0x45 |
255 |
#define SBIC_CSR_RSLT_NOAM 0x46 /* (I) lost sel, no AM mode */ |
256 |
#define SBIC_CSR_BAD_STATUS 0x47 /* status byte was nok */ |
257 |
#define SBIC_CSR_MIS_1 0x48 /* ph mis, see low bits */ |
258 |
/* Service Required Interrupts */ |
259 |
#define SBIC_CSR_RSLT_NI 0x80 /* reselected, no ify msg */ |
260 |
#define SBIC_CSR_RSLT_IFY 0x81 /* ditto, AM mode, got ify */ |
261 |
#define SBIC_CSR_SLT 0x82 /* selected, no ATN */ |
262 |
#define SBIC_CSR_SLT_ATN 0x83 /* selected with ATN */ |
263 |
#define SBIC_CSR_ATN 0x84 /* (T) ATN asserted */ |
264 |
#define SBIC_CSR_DISC_1 0x85 /* (I) bus is free */ |
265 |
#define SBIC_CSR_UNK_GROUP 0x87 /* strange CDB1 */ |
266 |
#define SBIC_CSR_MIS_2 0x88 /* (I) ph mis, see low bits */ |
267 |
|
268 |
#define SBIC_PHASE(csr) SCSI_PHASE(csr) |
269 |
|
270 |
/* |
271 |
* Command register (command codes) |
272 |
*/ |
273 |
|
274 |
#define SBIC_CMD_SBT 0x80 /* Single byte xfer qualifier */ |
275 |
#define SBIC_CMD_MASK 0x7f |
276 |
|
277 |
/* Miscellaneous */ |
278 |
#define SBIC_CMD_RESET 0x00 /* (DTI) lev I */ |
279 |
#define SBIC_CMD_ABORT 0x01 /* (DTI) lev I */ |
280 |
#define SBIC_CMD_DISC 0x04 /* ( TI) lev I */ |
281 |
#define SBIC_CMD_SSCC 0x0d /* ( TI) lev I */ |
282 |
#define SBIC_CMD_SET_IDI 0x0f /* (DTI) lev I */ |
283 |
#define SBIC_CMD_XLATE 0x18 /* (DT ) lev II */ |
284 |
|
285 |
/* Initiator state */ |
286 |
#define SBIC_CMD_SET_ATN 0x02 /* ( I) lev I */ |
287 |
#define SBIC_CMD_CLR_ACK 0x03 /* ( I) lev I */ |
288 |
#define SBIC_CMD_XFER_PAD 0x19 /* ( I) lev II */ |
289 |
#define SBIC_CMD_XFER_INFO 0x20 /* ( I) lev II */ |
290 |
|
291 |
/* Target state */ |
292 |
#define SBIC_CMD_SND_DISC 0x0e /* ( T ) lev II */ |
293 |
#define SBIC_CMD_RCV_CMD 0x10 /* ( T ) lev II */ |
294 |
#define SBIC_CMD_RCV_DATA 0x11 /* ( T ) lev II */ |
295 |
#define SBIC_CMD_RCV_MSG_OUT 0x12 /* ( T ) lev II */ |
296 |
#define SBIC_CMD_RCV 0x13 /* ( T ) lev II */ |
297 |
#define SBIC_CMD_SND_STATUS 0x14 /* ( T ) lev II */ |
298 |
#define SBIC_CMD_SND_DATA 0x15 /* ( T ) lev II */ |
299 |
#define SBIC_CMD_SND_MSG_IN 0x16 /* ( T ) lev II */ |
300 |
#define SBIC_CMD_SND 0x17 /* ( T ) lev II */ |
301 |
|
302 |
/* Disconnected state */ |
303 |
#define SBIC_CMD_RESELECT 0x05 /* (D ) lev II */ |
304 |
#define SBIC_CMD_SEL_ATN 0x06 /* (D ) lev II */ |
305 |
#define SBIC_CMD_SEL 0x07 /* (D ) lev II */ |
306 |
#define SBIC_CMD_SEL_ATN_XFER 0x08 /* (D I) lev II */ |
307 |
#define SBIC_CMD_SEL_XFER 0x09 /* (D I) lev II */ |
308 |
#define SBIC_CMD_RESELECT_RECV 0x0a /* (DT ) lev II */ |
309 |
#define SBIC_CMD_RESELECT_SEND 0x0b /* (DT ) lev II */ |
310 |
#define SBIC_CMD_WAIT_SEL_RECV 0x0c /* (DT ) lev II */ |
311 |
|
312 |
|
313 |
#define PHASE_MASK 0x07 /* mask for psns/pctl phase */ |
314 |
#define DATA_OUT_PHASE 0x00 |
315 |
#define DATA_IN_PHASE 0x01 |
316 |
#define CMD_PHASE 0x02 |
317 |
#define STATUS_PHASE 0x03 |
318 |
#define BUS_FREE_PHASE 0x04 |
319 |
#define ARB_SEL_PHASE 0x05 /* Fuji chip combines bus arb with sel. */ |
320 |
#define MESG_OUT_PHASE 0x06 |
321 |
#define MESG_IN_PHASE 0x07 |
322 |
|
323 |
#define SCSI_PHASE(reg) ((reg) & PHASE_MASK) |
324 |
|
325 |
#define SCSI_STATUS_MASK 0x3e /* Mask unused bits in status byte */ |
326 |
|
327 |
/* approximate, but we won't do SBT on selects */ |
328 |
#define wd33c93_isa_select(cmd) (((cmd) > 0x5) && ((cmd) < 0xa)) |
329 |
|
330 |
#define PAD(n) char n; |
331 |
#define SBIC_MACHINE_DMA_MODE SBIC_CTL_DMA |
332 |
|
333 |
typedef struct { |
334 |
volatile unsigned char wd33c93_asr; /* r : Aux Status Register */ |
335 |
#define wd33c93_address wd33c93_asr /* w : desired register no */ |
336 |
volatile unsigned char wd33c93_value; /* rw: register value */ |
337 |
} wd33c93_padded_ind_regmap_t; |
338 |
typedef volatile wd33c93_padded_ind_regmap_t *wd33c93_regmap_p; |
339 |
|
340 |
#define SBIC_ASR 0 /* offset to ASC register */ |
341 |
#define SBIC_ADDR 0 /* offset to address reg */ |
342 |
#define SBIC_VAL 1 /* offset to data register */ |
343 |
|
344 |
#define wd33c93_read_reg(sc,regno,val) \ |
345 |
do { \ |
346 |
bus_space_write_1((sc)->sc_regt,(sc)->sc_regh,SBIC_ADDR,(regno)); \ |
347 |
(val) = bus_space_read_1((sc)->sc_regt,(sc)->sc_regh,SBIC_VAL); \ |
348 |
} while (0) |
349 |
|
350 |
#define wd33c93_write_reg(sc,regno,val) \ |
351 |
do { \ |
352 |
bus_space_write_1((sc)->sc_regt, (sc)->sc_regh, SBIC_ADDR, (regno)); \ |
353 |
bus_space_write_1((sc)->sc_regt, (sc)->sc_regh, SBIC_VAL, (val)); \ |
354 |
} while (0) |
355 |
|
356 |
#define SET_SBIC_myid(sc,val) wd33c93_write_reg(sc,SBIC_myid,val) |
357 |
#define GET_SBIC_myid(sc,val) wd33c93_read_reg(sc,SBIC_myid,val) |
358 |
#define SET_SBIC_cdbsize(sc,val) wd33c93_write_reg(sc,SBIC_cdbsize,val) |
359 |
#define GET_SBIC_cdbsize(sc,val) wd33c93_read_reg(sc,SBIC_cdbsize,val) |
360 |
#define SET_SBIC_control(sc,val) wd33c93_write_reg(sc,SBIC_control,val) |
361 |
#define GET_SBIC_control(sc,val) wd33c93_read_reg(sc,SBIC_control,val) |
362 |
#define SET_SBIC_timeo(sc,val) wd33c93_write_reg(sc,SBIC_timeo,val) |
363 |
#define GET_SBIC_timeo(sc,val) wd33c93_read_reg(sc,SBIC_timeo,val) |
364 |
#define SET_SBIC_cdb1(sc,val) wd33c93_write_reg(sc,SBIC_cdb1,val) |
365 |
#define GET_SBIC_cdb1(sc,val) wd33c93_read_reg(sc,SBIC_cdb1,val) |
366 |
#define SET_SBIC_cdb2(sc,val) wd33c93_write_reg(sc,SBIC_cdb2,val) |
367 |
#define GET_SBIC_cdb2(sc,val) wd33c93_read_reg(sc,SBIC_cdb2,val) |
368 |
#define SET_SBIC_cdb3(sc,val) wd33c93_write_reg(sc,SBIC_cdb3,val) |
369 |
#define GET_SBIC_cdb3(sc,val) wd33c93_read_reg(sc,SBIC_cdb3,val) |
370 |
#define SET_SBIC_cdb4(sc,val) wd33c93_write_reg(sc,SBIC_cdb4,val) |
371 |
#define GET_SBIC_cdb4(sc,val) wd33c93_read_reg(sc,SBIC_cdb4,val) |
372 |
#define SET_SBIC_cdb5(sc,val) wd33c93_write_reg(sc,SBIC_cdb5,val) |
373 |
#define GET_SBIC_cdb5(sc,val) wd33c93_read_reg(sc,SBIC_cdb5,val) |
374 |
#define SET_SBIC_cdb6(sc,val) wd33c93_write_reg(sc,SBIC_cdb6,val) |
375 |
#define GET_SBIC_cdb6(sc,val) wd33c93_read_reg(sc,SBIC_cdb6,val) |
376 |
#define SET_SBIC_cdb7(sc,val) wd33c93_write_reg(sc,SBIC_cdb7,val) |
377 |
#define GET_SBIC_cdb7(sc,val) wd33c93_read_reg(sc,SBIC_cdb7,val) |
378 |
#define SET_SBIC_cdb8(sc,val) wd33c93_write_reg(sc,SBIC_cdb8,val) |
379 |
#define GET_SBIC_cdb8(sc,val) wd33c93_read_reg(sc,SBIC_cdb8,val) |
380 |
#define SET_SBIC_cdb9(sc,val) wd33c93_write_reg(sc,SBIC_cdb9,val) |
381 |
#define GET_SBIC_cdb9(sc,val) wd33c93_read_reg(sc,SBIC_cdb9,val) |
382 |
#define SET_SBIC_cdb10(sc,val) wd33c93_write_reg(sc,SBIC_cdb10,val) |
383 |
#define GET_SBIC_cdb10(sc,val) wd33c93_read_reg(sc,SBIC_cdb10,val) |
384 |
#define SET_SBIC_cdb11(sc,val) wd33c93_write_reg(sc,SBIC_cdb11,val) |
385 |
#define GET_SBIC_cdb11(sc,val) wd33c93_read_reg(sc,SBIC_cdb11,val) |
386 |
#define SET_SBIC_cdb12(sc,val) wd33c93_write_reg(sc,SBIC_cdb12,val) |
387 |
#define GET_SBIC_cdb12(sc,val) wd33c93_read_reg(sc,SBIC_cdb12,val) |
388 |
#define SET_SBIC_tlun(sc,val) wd33c93_write_reg(sc,SBIC_tlun,val) |
389 |
#define GET_SBIC_tlun(sc,val) wd33c93_read_reg(sc,SBIC_tlun,val) |
390 |
#define SET_SBIC_cmd_phase(sc,val) wd33c93_write_reg(sc,SBIC_cmd_phase,val) |
391 |
#define GET_SBIC_cmd_phase(sc,val) wd33c93_read_reg(sc,SBIC_cmd_phase,val) |
392 |
#define SET_SBIC_syn(sc,val) wd33c93_write_reg(sc,SBIC_syn,val) |
393 |
#define GET_SBIC_syn(sc,val) wd33c93_read_reg(sc,SBIC_syn,val) |
394 |
#define SET_SBIC_count_hi(sc,val) wd33c93_write_reg(sc,SBIC_count_hi,val) |
395 |
#define GET_SBIC_count_hi(sc,val) wd33c93_read_reg(sc,SBIC_count_hi,val) |
396 |
#define SET_SBIC_count_med(sc,val) wd33c93_write_reg(sc,SBIC_count_med,val) |
397 |
#define GET_SBIC_count_med(sc,val) wd33c93_read_reg(sc,SBIC_count_med,val) |
398 |
#define SET_SBIC_count_lo(sc,val) wd33c93_write_reg(sc,SBIC_count_lo,val) |
399 |
#define GET_SBIC_count_lo(sc,val) wd33c93_read_reg(sc,SBIC_count_lo,val) |
400 |
#define SET_SBIC_selid(sc,val) wd33c93_write_reg(sc,SBIC_selid,val) |
401 |
#define GET_SBIC_selid(sc,val) wd33c93_read_reg(sc,SBIC_selid,val) |
402 |
#define SET_SBIC_rselid(sc,val) wd33c93_write_reg(sc,SBIC_rselid,val) |
403 |
#define GET_SBIC_rselid(sc,val) wd33c93_read_reg(sc,SBIC_rselid,val) |
404 |
#define SET_SBIC_csr(sc,val) wd33c93_write_reg(sc,SBIC_csr,val) |
405 |
#define GET_SBIC_csr(sc,val) wd33c93_read_reg(sc,SBIC_csr,val) |
406 |
#define SET_SBIC_cmd(sc,val) wd33c93_write_reg(sc,SBIC_cmd,val) |
407 |
#define GET_SBIC_cmd(sc,val) wd33c93_read_reg(sc,SBIC_cmd,val) |
408 |
#define SET_SBIC_data(sc,val) wd33c93_write_reg(sc,SBIC_data,val) |
409 |
#define GET_SBIC_data(sc,val) wd33c93_read_reg(sc,SBIC_data,val) |
410 |
#define SET_SBIC_queue_tag(sc,val) wd33c93_write_reg(sc,SBIC_queue_tag,val) |
411 |
#define GET_SBIC_queue_tag(sc,val) wd33c93_read_reg(sc,SBIC_queue_tag,val) |
412 |
|
413 |
#define SBIC_TC_PUT(sc,val) \ |
414 |
do { \ |
415 |
wd33c93_write_reg(sc,SBIC_count_hi,((val)>>16)); \ |
416 |
bus_space_write_1((sc)->sc_regt, (sc)->sc_regh, \ |
417 |
SBIC_VAL, (val)>>8); \ |
418 |
bus_space_write_1((sc)->sc_regt, (sc)->sc_regh, \ |
419 |
SBIC_VAL, (val)); \ |
420 |
} while (0) |
421 |
|
422 |
#define SBIC_TC_GET(sc,val) \ |
423 |
do { \ |
424 |
wd33c93_read_reg(sc,SBIC_count_hi,(val)); \ |
425 |
(val) = ((val)<<8) | bus_space_read_1((sc)->sc_regt, \ |
426 |
(sc)->sc_regh,SBIC_VAL); \ |
427 |
(val) = ((val)<<8) | bus_space_read_1((sc)->sc_regt, \ |
428 |
(sc)->sc_regh,SBIC_VAL); \ |
429 |
} while (0) |
430 |
|
431 |
#define SBIC_LOAD_COMMAND(sc,cmd,cmdsize) \ |
432 |
do { \ |
433 |
int n = (cmdsize) - 1; \ |
434 |
char *ptr = (char *)(cmd); \ |
435 |
wd33c93_write_reg(regs, SBIC_cdb1, *ptr++); \ |
436 |
while(n-- > 0) \ |
437 |
bus_space_write_1((sc)->sc_regt, (sc)->sc_regh, \ |
438 |
SBIC_VAL, *ptr++); /* XXX write_multi */ \ |
439 |
} while (0) |
440 |
|
441 |
#define GET_SBIC_asr(sc,val) \ |
442 |
do { \ |
443 |
(val) = bus_space_read_1((sc)->sc_regt,(sc)->sc_regh,SBIC_ASR); \ |
444 |
} while (0) |
445 |
|
446 |
|
447 |
#define WAIT_CIP(sc) \ |
448 |
do { \ |
449 |
while (bus_space_read_1((sc)->sc_regt,(sc)->sc_regh, \ |
450 |
SBIC_ASR) & SBIC_ASR_CIP) \ |
451 |
/*nop*/; \ |
452 |
} while (0) |
453 |
|
454 |
/* |
455 |
* transmit a byte in programmed I/O mode |
456 |
*/ |
457 |
#define SEND_BYTE(sc, ch) \ |
458 |
do { \ |
459 |
WAIT_CIP(sc); \ |
460 |
SET_SBIC_cmd(sc, SBIC_CMD_SBT | SBIC_CMD_XFER_INFO); \ |
461 |
SBIC_WAIT(sc, SBIC_ASR_DBR, 0); \ |
462 |
SET_SBIC_data(sc, ch); \ |
463 |
} while (0) |
464 |
|
465 |
/* |
466 |
* receive a byte in programmed I/O mode |
467 |
*/ |
468 |
#define RECV_BYTE(sc, ch) \ |
469 |
do { \ |
470 |
WAIT_CIP(sc); \ |
471 |
SET_SBIC_cmd(sc, SBIC_CMD_SBT | SBIC_CMD_XFER_INFO); \ |
472 |
SBIC_WAIT(sc, SBIC_ASR_DBR, 0); \ |
473 |
GET_SBIC_data(sc, ch); \ |
474 |
} while (0) |