Add PCCARD match routines sio and the disk drivers.
[dragonfly.git] / sys / dev / disk / aic / aic6360reg.h
1 /*
2  * Copyright (c) 1994 Charles Hannum.
3  * Copyright (c) 1994 Jarle Greipsland.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
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 Jarle Greipsland
17  * 4. The name of the author may not be used to endorse or promote products
18  *    derived from this software without specific prior written permission.
19  * 
20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
28  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  * $FreeBSD: src/sys/dev/aic/aic6360reg.h,v 1.1 1999/10/21 08:56:52 luoqi Exp $
33  * $DragonFly: src/sys/dev/disk/aic/aic6360reg.h,v 1.2 2003/06/17 04:28:21 dillon Exp $
34  */
35
36 #define SCSISEQ         0x00    /* SCSI sequence control */
37 #define SXFRCTL0        0x01    /* SCSI transfer control 0 */
38 #define SXFRCTL1        0x02    /* SCSI transfer control 1 */
39 #define SCSISIGI        0x03    /* SCSI signal in */
40 #define SCSISIGO        0x03    /* SCSI signal out */
41 #define SCSIRATE        0x04    /* SCSI rate control */
42 #define SCSIID          0x05    /* SCSI ID */
43 #define SELID           0x05    /* Selection/Reselection ID */
44 #define SCSIDAT         0x06    /* SCSI Latched Data */
45 #define SCSIBUS         0x07    /* SCSI Data Bus*/
46 #define STCNT0          0x08    /* SCSI transfer count */
47 #define STCNT1          0x09
48 #define STCNT2          0x0a
49 #define CLRSINT0        0x0b    /* Clear SCSI interrupts 0 */
50 #define SSTAT0          0x0b    /* SCSI interrupt status 0 */
51 #define CLRSINT1        0x0c    /* Clear SCSI interrupts 1 */
52 #define SSTAT1          0x0c    /* SCSI status 1 */
53 #define SSTAT2          0x0d    /* SCSI status 2 */
54 #define SCSITEST        0x0e    /* SCSI test control */
55 #define SSTAT3          0x0e    /* SCSI status 3 */
56 #define CLRSERR         0x0f    /* Clear SCSI errors */
57 #define SSTAT4          0x0f    /* SCSI status 4 */
58 #define SIMODE0         0x10    /* SCSI interrupt mode 0 */
59 #define SIMODE1         0x11    /* SCSI interrupt mode 1 */
60 #define DMACNTRL0       0x12    /* DMA control 0 */
61 #define DMACNTRL1       0x13    /* DMA control 1 */
62 #define DMASTAT         0x14    /* DMA status */
63 #define FIFOSTAT        0x15    /* FIFO status */
64 #define DMADATA         0x16    /* DMA data */
65 #define DMADATAL        0x16    /* DMA data low byte */
66 #define DMADATAH        0x17    /* DMA data high byte */
67 #define BRSTCNTRL       0x18    /* Burst Control */
68 #define DMADATALONG     0x18
69 #define PORTA           0x1a    /* Port A */
70 #define PORTB           0x1b    /* Port B */
71 #define REV             0x1c    /* Revision (001 for 6360) */
72 #define STACK           0x1d    /* Stack */
73 #define TEST            0x1e    /* Test register */
74 #define ID              0x1f    /* ID register */
75
76 #define IDSTRING "(C)1991ADAPTECAIC6360           "
77
78 /* What all the bits do */
79
80 /* SCSISEQ */
81 #define TEMODEO         0x80
82 #define ENSELO          0x40
83 #define ENSELI          0x20
84 #define ENRESELI        0x10
85 #define ENAUTOATNO      0x08
86 #define ENAUTOATNI      0x04
87 #define ENAUTOATNP      0x02
88 #define SCSIRSTO        0x01
89
90 /* SXFRCTL0 */
91 #define SCSIEN          0x80
92 #define DMAEN           0x40
93 #define CHEN            0x20
94 #define CLRSTCNT        0x10
95 #define SPIOEN          0x08
96 #define CLRCH           0x02
97
98 /* SXFRCTL1 */
99 #define BITBUCKET       0x80
100 #define SWRAPEN         0x40
101 #define ENSPCHK         0x20
102 #define STIMESEL1       0x10
103 #define STIMESEL0       0x08
104 #define STIMO_256ms     0x00
105 #define STIMO_128ms     0x08
106 #define STIMO_64ms      0x10
107 #define STIMO_32ms      0x18
108 #define ENSTIMER        0x04
109 #define BYTEALIGN       0x02
110
111 /* SCSISIGI */
112 #define CDI             0x80
113 #define IOI             0x40
114 #define MSGI            0x20
115 #define ATNI            0x10
116 #define SELI            0x08
117 #define BSYI            0x04
118 #define REQI            0x02
119 #define ACKI            0x01
120
121 /* Important! The 3 most significant bits of this register, in initiator mode,
122  * represents the "expected" SCSI bus phase and can be used to trigger phase
123  * mismatch and phase change interrupts.  But more important:  If there is a
124  * phase mismatch the chip will not transfer any data!  This is actually a nice
125  * feature as it gives us a bit more control over what is happening when we are
126  * bursting data (in) through the FIFOs and the phase suddenly changes from
127  * DATA IN to STATUS or MESSAGE IN.  The transfer will stop and wait for the
128  * proper phase to be set in this register instead of dumping the bits into the
129  * FIFOs.
130  */
131 /* SCSISIGO */
132 #define CDO             0x80
133 #define IOO             0x40
134 #define MSGO            0x20
135 #define ATNO            0x10
136 #define SELO            0x08
137 #define BSYO            0x04
138 #define REQO            0x02
139 #define ACKO            0x01
140
141 /* Information transfer phases */
142 #define PH_DATAOUT      (0)
143 #define PH_DATAIN       (IOI)
144 #define PH_CMD          (CDI)
145 #define PH_STAT         (CDI|IOI)
146 #define PH_MSGOUT       (MSGI|CDI)
147 #define PH_MSGIN        (MSGI|CDI|IOI)
148 #define PH_MASK         (MSGI|CDI|IOI)
149
150 /* SCSIRATE */
151 #define SXFR2           0x40
152 #define SXFR1           0x20
153 #define SXFR0           0x10
154 #define SOFS3           0x08
155 #define SOFS2           0x04
156 #define SOFS1           0x02
157 #define SOFS0           0x01
158
159 /* SCSI ID */
160 #define OID2            0x40
161 #define OID1            0x20
162 #define OID0            0x10
163 #define OID_S           4       /* shift value */
164 #define TID2            0x04
165 #define TID1            0x02
166 #define TID0            0x01
167 #define SCSI_ID_MASK    0x7
168
169 /* SCSI selection/reselection ID (both target *and* initiator) */
170 #define SELID7          0x80
171 #define SELID6          0x40
172 #define SELID5          0x20
173 #define SELID4          0x10
174 #define SELID3          0x08
175 #define SELID2          0x04
176 #define SELID1          0x02
177 #define SELID0          0x01
178
179 /* CLRSINT0                      Clears what? (interrupt and/or status bit) */
180 #define SETSDONE        0x80
181 #define CLRSELDO        0x40    /* I */
182 #define CLRSELDI        0x20    /* I+ */
183 #define CLRSELINGO      0x10    /* I */
184 #define CLRSWRAP        0x08    /* I+S */
185 #define CLRSDONE        0x04    /* I+S */
186 #define CLRSPIORDY      0x02    /* I */
187 #define CLRDMADONE      0x01    /* I */
188
189 /* SSTAT0                          Howto clear */
190 #define TARGET          0x80
191 #define SELDO           0x40    /* Selfclearing */
192 #define SELDI           0x20    /* Selfclearing when CLRSELDI is set */
193 #define SELINGO         0x10    /* Selfclearing */
194 #define SWRAP           0x08    /* CLRSWAP */
195 #define SDONE           0x04    /* Not used in initiator mode */
196 #define SPIORDY         0x02    /* Selfclearing (op on SCSIDAT) */
197 #define DMADONE         0x01    /* Selfclearing (all FIFOs empty & T/C */
198
199 /* CLRSINT1                      Clears what? */
200 #define CLRSELTIMO      0x80    /* I+S */
201 #define CLRATNO         0x40
202 #define CLRSCSIRSTI     0x20    /* I+S */
203 #define CLRBUSFREE      0x08    /* I+S */
204 #define CLRSCSIPERR     0x04    /* I+S */
205 #define CLRPHASECHG     0x02    /* I+S */
206 #define CLRREQINIT      0x01    /* I+S */
207
208 /* SSTAT1                       How to clear?  When set?*/
209 #define SELTO           0x80    /* C            select out timeout */
210 #define ATNTARG         0x40    /* Not used in initiator mode */
211 #define SCSIRSTI        0x20    /* C            RST asserted */
212 #define PHASEMIS        0x10    /* Selfclearing */
213 #define BUSFREE         0x08    /* C            bus free condition */
214 #define SCSIPERR        0x04    /* C            parity error on inbound data */
215 #define PHASECHG        0x02    /* C         phase in SCSISIGI doesn't match */
216 #define REQINIT         0x01    /* C or ACK     asserting edge of REQ */
217
218 /* SSTAT2 */
219 #define SOFFSET         0x20
220 #define SEMPTY          0x10
221 #define SFULL           0x08
222 #define SFCNT2          0x04
223 #define SFCNT1          0x02
224 #define SFCNT0          0x01
225
226 /* SCSITEST */
227 #define SCTESTU         0x08
228 #define SCTESTD         0x04
229 #define STCTEST         0x01
230
231 /* SSTAT3 */
232 #define SCSICNT3        0x80
233 #define SCSICNT2        0x40
234 #define SCSICNT1        0x20
235 #define SCSICNT0        0x10
236 #define OFFCNT3         0x08
237 #define OFFCNT2         0x04
238 #define OFFCNT1         0x02
239 #define OFFCNT0         0x01
240
241 /* CLRSERR */
242 #define CLRSYNCERR      0x04
243 #define CLRFWERR        0x02
244 #define CLRFRERR        0x01
245
246 /* SSTAT4 */
247 #define SYNCERR         0x04
248 #define FWERR           0x02
249 #define FRERR           0x01
250
251 /* SIMODE0 */
252 #define ENSELDO         0x40
253 #define ENSELDI         0x20
254 #define ENSELINGO       0x10
255 #define ENSWRAP         0x08
256 #define ENSDONE         0x04
257 #define ENSPIORDY       0x02
258 #define ENDMADONE       0x01
259
260 /* SIMODE1 */
261 #define ENSELTIMO       0x80
262 #define ENATNTARG       0x40
263 #define ENSCSIRST       0x20
264 #define ENPHASEMIS      0x10
265 #define ENBUSFREE       0x08
266 #define ENSCSIPERR      0x04
267 #define ENPHASECHG      0x02
268 #define ENREQINIT       0x01
269
270 /* DMACNTRL0 */
271 #define ENDMA           0x80
272 #define B8MODE          0x40
273 #define DMA             0x20
274 #define DWORDPIO        0x10
275 #define WRITE           0x08
276 #define INTEN           0x04
277 #define RSTFIFO         0x02
278 #define SWINT           0x01
279
280 /* DMACNTRL1 */
281 #define PWRDWN          0x80
282 #define ENSTK32         0x40
283 #define STK4            0x10
284 #define STK3            0x08
285 #define STK2            0x04
286 #define STK1            0x02
287 #define STK0            0x01
288
289 /* DMASTAT */
290 #define ATDONE          0x80
291 #define WORDRDY         0x40
292 #define INTSTAT         0x20
293 #define DFIFOFULL       0x10
294 #define DFIFOEMP        0x08
295 #define DFIFOHF         0x04
296 #define DWORDRDY        0x02
297
298 /* BRSTCNTRL */
299 #define BON3            0x80
300 #define BON2            0x40
301 #define BON1            0x20
302 #define BON0            0x10
303 #define BOFF3           0x08
304 #define BOFF2           0x04
305 #define BOFF1           0x02
306 #define BOFF0           0x01
307
308 /* TEST */
309 #define BOFFTMR         0x40
310 #define BONTMR          0x20
311 #define STCNTH          0x10
312 #define STCNTM          0x08
313 #define STCNTL          0x04
314 #define SCSIBLK         0x02
315 #define DMABLK          0x01
316
317 /* PORTA */
318 #define PORTA_ID(a)     ((a) & 7)
319 #define PORTA_IRQ(a)    ((((a) >> 3) & 3) + 9)
320 #define PORTA_DRQ(a)    ((((a) >> 5) & 3) ? (((a) >> 5) & 3) + 4 : 0)
321 #define PORTA_PARITY(a) ((a) & 0x80)
322
323 /* PORTB */
324 #define PORTB_DISC(b)   ((b) & 4)
325 #define PORTB_SYNC(b)   ((b) & 8)
326 #define PORTB_BOOT(b)   ((b) & 0x40)
327 #define PORTB_DMA(b)    ((b) & 0x80)
328
329 /* How to behave on the (E)ISA bus when/if DMAing (on<<4) + off in us */
330 #define EISA_BRST_TIM   ((15<<4) + 1)   /* 15us on, 1us off */
331
332 #define FIFOSIZE        128