aic7xxx.reg revision 28169
1/*
2 * Aic7xxx register and scratch ram definitions.
3 *
4 * Copyright (c) 1994-1997 Justin Gibbs.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions, and the following disclaimer,
12 *    without modification, immediately at the beginning of the file.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 *    derived from this software without specific prior written permission.
18 *
19 * Where this Software is combined with software released under the terms of 
20 * the GNU Public License ("GPL") and the terms of the GPL would require the 
21 * combined work to also be released under the terms of the GPL, the terms
22 * and conditions of this License will apply in addition to those of the
23 * GPL with the exception of any terms or conditions of this License that
24 * conflict with, or are expressly prohibited by, the GPL.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
30 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 *	$Id: aic7xxx.reg,v 1.4 1997/06/27 19:38:39 gibbs Exp $
39 */
40
41/*
42 * This file is processed by the aic7xxx_asm utility for use in assembling
43 * firmware for the aic7xxx family of SCSI host adapters as well as to generate
44 * a C header file for use in the kernel portion of the Aic7xxx driver.
45 *
46 * All page numbers refer to the Adaptec AIC-7770 Data Book available from
47 * Adaptec's Technical Documents Department 1-800-934-2766
48 */
49
50/*
51 * SCSI Sequence Control (p. 3-11).
52 * Each bit, when set starts a specific SCSI sequence on the bus
53 */
54register SCSISEQ {
55	address			0x000
56	access_mode RW
57	bit	TEMODE		0x80
58	bit	ENSELO		0x40
59	bit	ENSELI		0x20
60	bit	ENRSELI		0x10
61	bit	ENAUTOATNO	0x08
62	bit	ENAUTOATNI	0x04
63	bit	ENAUTOATNP	0x02
64	bit	SCSIRSTO	0x01
65}
66
67/*
68 * SCSI Transfer Control 0 Register (pp. 3-13).
69 * Controls the SCSI module data path.
70 */
71register SXFRCTL0 {
72	address			0x001
73	access_mode RW
74	bit	DFON		0x80
75	bit	DFPEXP		0x40
76	bit	FAST20		0x20
77	bit	CLRSTCNT	0x10
78	bit	SPIOEN		0x08
79	bit	SCAMEN		0x04
80	bit	CLRCHN		0x02
81}
82
83/*
84 * SCSI Transfer Control 1 Register (pp. 3-14,15).
85 * Controls the SCSI module data path.
86 */
87register SXFRCTL1 {
88	address			0x002
89	access_mode RW
90	bit	BITBUCKET	0x80
91	bit	SWRAPEN		0x40
92	bit	ENSPCHK		0x20
93	mask	STIMESEL	0x18
94	bit	ENSTIMER	0x04
95	bit	ACTNEGEN	0x02
96	bit	STPWEN		0x01	/* Powered Termination */
97}
98
99/*
100 * SCSI Control Signal Read Register (p. 3-15).
101 * Reads the actual state of the SCSI bus pins
102 */
103register SCSISIGI {
104	address			0x003
105	access_mode RO
106	bit	CDI		0x80
107	bit	IOI		0x40
108	bit	MSGI		0x20
109	bit	ATNI		0x10
110	bit	SELI		0x08
111	bit	BSYI		0x04
112	bit	REQI		0x02
113	bit	ACKI		0x01
114/*
115 * Possible phases in SCSISIGI
116 */
117	mask	PHASE_MASK	CDI|IOI|MSGI
118	mask	P_DATAOUT	0x00
119	mask	P_DATAIN	IOI
120	mask	P_COMMAND	CDI
121	mask	P_MESGOUT	CDI|MSGI
122	mask	P_STATUS	CDI|IOI
123	mask	P_MESGIN	CDI|IOI|MSGI
124}
125
126/*
127 * SCSI Control Signal Write Register (p. 3-16).
128 * Writing to this register modifies the control signals on the bus.  Only
129 * those signals that are allowed in the current mode (Initiator/Target) are
130 * asserted.
131 */
132register SCSISIGO {
133	address			0x003
134	access_mode WO
135	bit	CDO		0x80
136	bit	IOO		0x40
137	bit	MSGO		0x20
138	bit	ATNO		0x10
139	bit	SELO		0x08
140	bit	BSYO		0x04
141	bit	REQO		0x02
142	bit	ACKO		0x01
143/*
144 * Possible phases to write into SCSISIG0
145 */
146	mask	PHASE_MASK	CDI|IOI|MSGI
147	mask	P_DATAOUT	0x00
148	mask	P_DATAIN	IOI
149	mask	P_COMMAND	CDI
150	mask	P_MESGOUT	CDI|MSGI
151	mask	P_STATUS	CDI|IOI
152	mask	P_MESGIN	CDI|IOI|MSGI
153}
154
155/* 
156 * SCSI Rate Control (p. 3-17).
157 * Contents of this register determine the Synchronous SCSI data transfer
158 * rate and the maximum synchronous Req/Ack offset.  An offset of 0 in the
159 * SOFS (3:0) bits disables synchronous data transfers.  Any offset value
160 * greater than 0 enables synchronous transfers.
161 */
162register SCSIRATE {
163	address			0x004
164	access_mode RW
165	bit	WIDEXFER	0x80		/* Wide transfer control */
166	mask	SXFR		0x70		/* Sync transfer rate */
167	mask	SOFS		0x0f		/* Sync offset */
168}
169
170/*
171 * SCSI ID (p. 3-18).
172 * Contains the ID of the board and the current target on the
173 * selected channel.
174 */
175register SCSIID	{
176	address			0x005
177	access_mode RW
178	mask	TID		0xf0		/* Target ID mask */
179	mask	OID		0x0f		/* Our ID mask */
180}
181
182/*
183 * SCSI Latched Data (p. 3-19).
184 * Read/Write latches used to transfer data on the SCSI bus during
185 * Automatic or Manual PIO mode.  SCSIDATH can be used for the
186 * upper byte of a 16bit wide asynchronouse data phase transfer.
187 */
188register SCSIDATL {
189	address			0x006
190	access_mode RW
191}
192
193register SCSIDATH {
194	address			0x007
195	access_mode RW
196}
197
198/*
199 * SCSI Transfer Count (pp. 3-19,20)
200 * These registers count down the number of bytes transferred
201 * across the SCSI bus.  The counter is decremented only once
202 * the data has been safely transferred.  SDONE in SSTAT0 is
203 * set when STCNT goes to 0
204 */ 
205register STCNT {
206	address			0x008
207	size	3
208	access_mode RW
209}
210
211/*
212 * Clear SCSI Interrupt 0 (p. 3-20)
213 * Writing a 1 to a bit clears the associated SCSI Interrupt in SSTAT0.
214 */
215register CLRSINT0 {
216	address			0x00b
217	access_mode WO
218	bit	CLRSELDO	0x40
219	bit	CLRSELDI	0x20
220	bit	CLRSELINGO	0x10
221	bit	CLRSWRAP	0x08
222	bit	CLRSPIORDY	0x02
223}
224
225/*
226 * SCSI Status 0 (p. 3-21)
227 * Contains one set of SCSI Interrupt codes
228 * These are most likely of interest to the sequencer
229 */
230register SSTAT0	{
231	address			0x00b
232	access_mode RO
233	bit	TARGET		0x80		/* Board acting as target */
234	bit	SELDO		0x40		/* Selection Done */
235	bit	SELDI		0x20		/* Board has been selected */
236	bit	SELINGO		0x10		/* Selection In Progress */
237	bit	SWRAP		0x08		/* 24bit counter wrap */
238	bit	SDONE		0x04		/* STCNT = 0x000000 */
239	bit	SPIORDY		0x02		/* SCSI PIO Ready */
240	bit	DMADONE		0x01		/* DMA transfer completed */
241}
242
243/*
244 * Clear SCSI Interrupt 1 (p. 3-23)
245 * Writing a 1 to a bit clears the associated SCSI Interrupt in SSTAT1.
246 */
247register CLRSINT1 {
248	address			0x00c
249	access_mode WO
250	bit	CLRSELTIMEO	0x80
251	bit	CLRATNO		0x40
252	bit	CLRSCSIRSTI	0x20
253	bit	CLRBUSFREE	0x08
254	bit	CLRSCSIPERR	0x04
255	bit	CLRPHASECHG	0x02
256	bit	CLRREQINIT	0x01
257}
258
259/*
260 * SCSI Status 1 (p. 3-24)
261 */
262register SSTAT1	{
263	address			0x00c
264	access_mode RO
265	bit	SELTO		0x80
266	bit	ATNTARG 	0x40
267	bit	SCSIRSTI	0x20
268	bit	PHASEMIS	0x10
269	bit	BUSFREE		0x08
270	bit	SCSIPERR	0x04
271	bit	PHASECHG	0x02
272	bit	REQINIT		0x01
273}
274
275/*
276 * SCSI Status 2 (pp. 3-25,26)
277 */
278register SSTAT2 {
279	address			0x00d
280	access_mode RO
281	bit	OVERRUN		0x80
282	mask	SFCNT		0x1f
283}
284
285/*
286 * SCSI Status 3 (p. 3-26)
287 */
288register SSTAT3 {
289	address			0x00e
290	access_mode RO
291	mask	SCSICNT		0xf0
292	mask	OFFCNT		0x0f
293}
294
295/*
296 * SCSI Test Control (p. 3-27)
297 */
298register SCSITEST {
299	address			0x00f
300	access_mode RW
301	bit	RQAKCNT		0x04
302	bit	CNTRTEST	0x02
303	bit	CMODE		0x01
304}
305
306/*
307 * SCSI Interrupt Mode 1 (p. 3-28)
308 * Setting any bit will enable the corresponding function
309 * in SIMODE0 to interrupt via the IRQ pin.
310 */
311register SIMODE0 {
312	address			0x010
313	access_mode RW
314	bit	ENSELDO		0x40
315	bit	ENSELDI		0x20
316	bit	ENSELINGO	0x10
317	bit	ENSWRAP		0x08
318	bit	ENSDONE		0x04
319	bit	ENSPIORDY	0x02
320	bit	ENDMADONE	0x01
321}
322
323/*
324 * SCSI Interrupt Mode 1 (pp. 3-28,29)
325 * Setting any bit will enable the corresponding function
326 * in SIMODE1 to interrupt via the IRQ pin.
327 */
328register SIMODE1 {
329	address			0x011
330	access_mode RW
331	bit	ENSELTIMO	0x80
332	bit	ENATNTARG	0x40
333	bit	ENSCSIRST	0x20
334	bit	ENPHASEMIS	0x10
335	bit	ENBUSFREE	0x08
336	bit	ENSCSIPERR	0x04
337	bit	ENPHASECHG	0x02
338	bit	ENREQINIT	0x01
339}
340
341/*
342 * SCSI Data Bus (High) (p. 3-29)
343 * This register reads data on the SCSI Data bus directly.
344 */
345register SCSIBUSL {
346	address			0x012
347	access_mode RO
348}
349
350register SCSIBUSH {
351	address			0x013
352	access_mode RO
353}
354
355/*
356 * SCSI/Host Address (p. 3-30)
357 * These registers hold the host address for the byte about to be
358 * transferred on the SCSI bus.  They are counted up in the same
359 * manner as STCNT is counted down.  SHADDR should always be used
360 * to determine the address of the last byte transferred since HADDR
361 * can be skewed by write ahead.
362 */
363register SHADDR {
364	address			0x014
365	size	4
366	access_mode RO
367}
368
369/*
370 * Selection Timeout Timer (p. 3-30)
371 */
372register SELTIMER {
373	address			0x018
374	access_mode RW
375	bit	STAGE6		0x20
376	bit	STAGE5		0x10
377	bit	STAGE4		0x08
378	bit	STAGE3		0x04
379	bit	STAGE2		0x02
380	bit	STAGE1		0x01
381}
382
383/*
384 * Selection/Reselection ID (p. 3-31)
385 * Upper four bits are the device id.  The ONEBIT is set when the re/selecting
386 * device did not set its own ID.
387 */
388register SELID {
389	address			0x019
390	access_mode RW
391	mask	SELID_MASK	0xf0
392	bit	ONEBIT		0x08
393}
394
395/*
396 * SCSI Block Control (p. 3-32)
397 * Controls Bus type and channel selection.  In a twin channel configuration
398 * addresses 0x00-0x1e are gated to the appropriate channel based on this
399 * register.  SELWIDE allows for the coexistence of 8bit and 16bit devices
400 * on a wide bus.
401 */
402register SBLKCTL {
403	address			0x01f
404	access_mode RW
405	bit	DIAGLEDEN	0x80	/* Aic78X0 only */
406	bit	DIAGLEDON	0x40	/* Aic78X0 only */
407	bit	AUTOFLUSHDIS	0x20
408	bit	SELBUSB		0x08
409	bit	SELWIDE		0x02
410}
411
412/*
413 * Sequencer Control (p. 3-33)
414 * Error detection mode and speed configuration
415 */
416register SEQCTL {
417	address			0x060
418	access_mode RW
419	bit	PERRORDIS	0x80
420	bit	PAUSEDIS	0x40
421	bit	FAILDIS		0x20
422	bit	FASTMODE	0x10
423	bit	BRKADRINTEN	0x08
424	bit	STEP		0x04
425	bit	SEQRESET	0x02
426	bit	LOADRAM		0x01
427}
428
429/*
430 * Sequencer RAM Data (p. 3-34)
431 * Single byte window into the Scratch Ram area starting at the address
432 * specified by SEQADDR0 and SEQADDR1.  To write a full word, simply write
433 * four bytes in sucessesion.  The SEQADDRs will increment after the most
434 * significant byte is written
435 */
436register SEQRAM {
437	address			0x061
438	access_mode RW
439}
440
441/*
442 * Sequencer Address Registers (p. 3-35)
443 * Only the first bit of SEQADDR1 holds addressing information
444 */
445register SEQADDR0 {
446	address			0x062
447	access_mode RW
448}
449
450register SEQADDR1 {
451	address			0x063
452	access_mode RW
453	mask	SEQADDR1_MASK	0x01
454}
455
456/*
457 * Accumulator
458 * We cheat by passing arguments in the Accumulator up to the kernel driver
459 */
460register ACCUM {
461	address			0x064
462	access_mode RW
463	accumulator
464}
465
466register SINDEX	{
467	address			0x065
468	access_mode RW
469	sindex
470}
471
472register DINDEX {
473	address			0x066
474	access_mode RW
475}
476
477register ALLONES {
478	address			0x069
479	access_mode RO
480	allones
481}
482
483register ALLZEROS {
484	address			0x06a
485	access_mode RO
486	allzeros
487}
488
489register NONE {
490	address			0x06a
491	access_mode WO
492	none
493}
494
495register FLAGS {
496	address			0x06b
497	access_mode RO
498	bit	ZERO		0x02
499	bit	CARRY		0x01
500}
501
502register SINDIR	{
503	address			0x06c
504	access_mode RO
505}
506
507register DINDIR	 {
508	address			0x06d
509	access_mode WO
510}
511
512register FUNCTION1 {
513	address			0x06e
514	access_mode RW
515}
516
517register STACK {
518	address			0x06f
519	access_mode RO
520}
521
522/*
523 * Board Control (p. 3-43)
524 */
525register BCTL {
526	address			0x084
527	access_mode RW
528	bit	ACE		0x08
529	bit	ENABLE		0x01
530}
531
532/*
533 * On the aic78X0 chips, Board Control is replaced by the DSCommand
534 * register (p. 4-64)
535 */
536register DSCOMMAND {
537	address			0x084
538	access_mode RW
539	bit	CACHETHEN	0x80	/* Cache Threshold enable */
540	bit	DPARCKEN	0x40	/* Data Parity Check Enable */
541	bit	MPARCKEN	0x20	/* Memory Parity Check Enable */
542	bit	EXTREQLCK	0x10	/* External Request Lock */
543}
544
545/*
546 * Bus On/Off Time (p. 3-44)
547 */
548register BUSTIME {
549	address			0x085
550	access_mode RW
551	mask	BOFF		0xf0
552	mask	BON		0x0f
553}
554
555/*
556 * Bus Speed (p. 3-45)
557 */
558register BUSSPD {
559	address			0x086
560	access_mode RW
561	mask	DFTHRSH		0xc0
562	mask	STBOFF		0x38
563	mask	STBON		0x07
564	mask	DFTHRSH_100	0xc0
565}
566
567/*
568 * Host Control (p. 3-47) R/W
569 * Overall host control of the device.
570 */
571register HCNTRL {
572	address			0x087
573	access_mode RW
574	bit	POWRDN		0x40
575	bit	SWINT		0x10
576	bit	IRQMS		0x08
577	bit	PAUSE		0x04
578	bit	INTEN		0x02
579	bit	CHIPRST		0x01
580	bit	CHIPRSTACK	0x01
581}
582
583/*
584 * Host Address (p. 3-48)
585 * This register contains the address of the byte about
586 * to be transferred across the host bus.
587 */
588register HADDR {
589	address			0x088
590	size	4
591	access_mode RW
592}
593
594register HCNT {
595	address			0x08c
596	size	3
597	access_mode RW
598}
599
600/*
601 * SCB Pointer (p. 3-49)
602 * Gate one of the four SCBs into the SCBARRAY window.
603 */
604register SCBPTR {
605	address			0x090
606	access_mode RW
607}
608
609/*
610 * Interrupt Status (p. 3-50)
611 * Status for system interrupts
612 */
613register INTSTAT {
614	address			0x091
615	access_mode RW
616	bit	BRKADRINT 0x08
617	bit	SCSIINT	  0x04
618	bit	CMDCMPLT  0x02
619	bit	SEQINT    0x01
620	mask	BAD_PHASE	SEQINT		/* unknown scsi bus phase */
621	mask	SEND_REJECT	0x10|SEQINT	/* sending a message reject */
622	mask	NO_IDENT	0x20|SEQINT	/* no IDENTIFY after reconnect*/
623	mask	NO_MATCH	0x30|SEQINT	/* no cmd match for reconnect */
624	mask	EXTENDED_MSG	0x40|SEQINT	/* Extended message received */
625	mask	NO_MATCH_BUSY	0x50|SEQINT	/* Couldn't find BUSY SCB */
626	mask	REJECT_MSG	0x60|SEQINT	/* Reject message received */
627	mask	BAD_STATUS	0x70|SEQINT	/* Bad status from target */
628	mask	RESIDUAL	0x80|SEQINT	/* Residual byte count != 0 */
629	mask	ABORT_CMDCMPLT	0x91		/*
630						 * Command tagged for abort
631						 * completed successfully.
632						 */
633	mask	AWAITING_MSG	0xa0|SEQINT	/*
634						 * Kernel requested to specify
635                                                 * a message to this target
636                                                 * (command was null), so tell
637                                                 * it that it can fill the
638                                                 * message buffer.
639                                                 */
640	mask	MSG_BUFFER_BUSY	0xc0|SEQINT	/*
641						 * Sequencer wants to use the
642						 * message buffer, but it
643						 * already contains a message
644						 */
645	mask	MSGIN_PHASEMIS	0xd0|SEQINT	/*
646						 * Target changed phase on us
647						 * when we were expecting
648						 * another msgin byte.
649						 */
650	mask	DATA_OVERRUN	0xe0|SEQINT	/*
651						 * Target attempted to write
652						 * beyond the bounds of its
653						 * command.
654						 */
655
656	mask	SEQINT_MASK	0xf0|SEQINT	/* SEQINT Status Codes */
657	mask	INT_PEND  (BRKADRINT|SEQINT|SCSIINT|CMDCMPLT)
658}
659
660/*
661 * Hard Error (p. 3-53)
662 * Reporting of catastrophic errors.  You usually cannot recover from
663 * these without a full board reset.
664 */
665register ERROR {
666	address			0x092
667	access_mode RO
668	bit	PARERR		0x08
669	bit	ILLOPCODE	0x04
670	bit	ILLSADDR	0x02
671	bit	ILLHADDR	0x01
672}
673
674/*
675 * Clear Interrupt Status (p. 3-52)
676 */
677register CLRINT {
678	address			0x092
679	access_mode WO
680	bit	CLRBRKADRINT	0x08
681	bit	CLRSCSIINT      0x04
682	bit	CLRCMDINT 	0x02
683	bit	CLRSEQINT 	0x01
684}
685
686register DFCNTRL {
687	address			0x093
688	access_mode RW
689	bit	WIDEODD		0x40
690	bit	SCSIEN		0x20
691	bit	SDMAEN		0x10
692	bit	SDMAENACK	0x10
693	bit	HDMAEN		0x08
694	bit	HDMAENACK	0x08
695	bit	DIRECTION	0x04
696	bit	FIFOFLUSH	0x02
697	bit	FIFORESET	0x01
698}
699
700register DFSTATUS {
701	address			0x094
702	access_mode RO
703	bit	DWORDEMP	0x20
704	bit	MREQPEND	0x10
705	bit	HDONE		0x08
706	bit	DFTHRESH	0x04
707	bit	FIFOFULL	0x02
708	bit	FIFOEMP		0x01
709}
710
711register DFDAT {
712	address			0x099
713	access_mode RW
714}
715
716/*
717 * SCB Auto Increment (p. 3-59)
718 * Byte offset into the SCB Array and an optional bit to allow auto
719 * incrementing of the address during download and upload operations
720 */
721register SCBCNT {
722	address			0x09a
723	access_mode RW
724	bit	SCBAUTO		0x80
725	mask	SCBCNT_MASK	0x1f
726}
727
728/*
729 * Queue In FIFO (p. 3-60)
730 * Input queue for queued SCBs (commands that the seqencer has yet to start)
731 */
732register QINFIFO {
733	address			0x09b
734	access_mode RW
735}
736
737/*
738 * Queue In Count (p. 3-60)
739 * Number of queued SCBs
740 */
741register QINCNT	{
742	address			0x09c
743	access_mode RO
744}
745
746/*
747 * Queue Out FIFO (p. 3-61)
748 * Queue of SCBs that have completed and await the host
749 */
750register QOUTFIFO {
751	address			0x09d
752	access_mode WO
753}
754
755/*
756 * Queue Out Count (p. 3-61)
757 * Number of queued SCBs in the Out FIFO
758 */
759register QOUTCNT {
760	address			0x09e
761	access_mode RO
762}
763
764/*
765 * SCB Definition (p. 5-4)
766 */
767scb {
768	address			0x0a0
769	SCB_CONTROL {
770		size	1
771		bit	MK_MESSAGE      0x80
772		bit	DISCENB         0x40
773		bit	TAG_ENB		0x20
774		bit	MUST_DMAUP_SCB	0x10
775		bit	ABORT_SCB	0x08
776		bit	DISCONNECTED	0x04
777		mask	SCB_TAG_TYPE	0x03
778	}
779	SCB_TCL {
780		size	1
781		bit	SELBUSB		0x08
782		mask	TID		0xf0
783		mask	LID		0x07
784	}
785	SCB_TARGET_STATUS {
786		size	1
787	}
788	SCB_SGCOUNT {
789		size	1
790	}
791	SCB_SGPTR {
792		size	4
793	}
794	SCB_RESID_SGCNT {
795		size	1
796	}
797	SCB_RESID_DCNT	{
798		size	3
799	}
800	SCB_DATAPTR {
801		size	4
802	}
803	SCB_DATACNT {
804		size	3
805	}
806	SCB_LINKED_NEXT {
807		size	1
808	}
809	SCB_CMDPTR {
810		size	4
811	}
812	SCB_CMDLEN {
813		size	1
814	}
815	SCB_TAG {
816		size	1
817	}
818	SCB_NEXT {
819		size	1
820	}
821	SCB_PREV {
822		size	1
823	}
824	SCB_BUSYTARGETS {
825		size	4
826	}
827}
828
829const	SG_SIZEOF	0x08		/* sizeof(struct ahc_dma) */
830
831/* --------------------- AHA-2840-only definitions -------------------- */
832
833register SEECTL_2840 {
834	address			0x0c0
835	access_mode RW
836	bit	CS_2840		0x04
837	bit	CK_2840		0x02
838	bit	DO_2840		0x01
839}
840
841register STATUS_2840 {
842	address			0x0c1
843	access_mode RW
844	bit	EEPROM_TF	0x80
845	mask	BIOS_SEL	0x60
846	mask	ADSEL		0x1e
847	bit	DI_2840		0x01
848}
849
850/* --------------------- AIC-7870-only definitions -------------------- */
851
852register DSPCISTATUS {
853	address			0x086
854}
855
856register BRDCTL	{
857	address			0x01d
858	bit	BRDDAT7		0x80
859	bit	BRDDAT6		0x40
860	bit	BRDDAT5		0x20
861	bit	BRDSTB		0x10
862	bit	BRDCS		0x08
863	bit	BRDRW		0x04
864	bit	BRDCTL1		0x02
865	bit	BRDCTL0		0x01
866}
867
868/*
869 * Serial EEPROM Control (p. 4-92 in 7870 Databook)
870 * Controls the reading and writing of an external serial 1-bit
871 * EEPROM Device.  In order to access the serial EEPROM, you must
872 * first set the SEEMS bit that generates a request to the memory
873 * port for access to the serial EEPROM device.  When the memory
874 * port is not busy servicing another request, it reconfigures
875 * to allow access to the serial EEPROM.  When this happens, SEERDY
876 * gets set high to verify that the memory port access has been
877 * granted.  
878 *
879 * After successful arbitration for the memory port, the SEECS bit of 
880 * the SEECTL register is connected to the chip select.  The SEECK, 
881 * SEEDO, and SEEDI are connected to the clock, data out, and data in 
882 * lines respectively.  The SEERDY bit of SEECTL is useful in that it 
883 * gives us an 800 nsec timer.  After a write to the SEECTL register, 
884 * the SEERDY goes high 800 nsec later.  The one exception to this is 
885 * when we first request access to the memory port.  The SEERDY goes 
886 * high to signify that access has been granted and, for this case, has 
887 * no implied timing.
888 *
889 * See 93cx6.c for detailed information on the protocol necessary to 
890 * read the serial EEPROM.
891 */
892register SEECTL {
893	address			0x01e
894	bit	EXTARBACK	0x80
895	bit	EXTARBREQ	0x40
896	bit	SEEMS		0x20
897	bit	SEERDY		0x10
898	bit	SEECS		0x08
899	bit	SEECK		0x04
900	bit	SEEDO		0x02
901	bit	SEEDI		0x01
902}
903/* ---------------------- Scratch RAM Offsets ------------------------- */
904/* These offsets are either to values that are initialized by the board's
905 * BIOS or are specified by the sequencer code.
906 *
907 * The host adapter card (at least the BIOS) uses 20-2f for SCSI
908 * device information, 32-33 and 5a-5f as well. As it turns out, the
909 * BIOS trashes 20-2f, writing the synchronous negotiation results
910 * on top of the BIOS values, so we re-use those for our per-target
911 * scratchspace (actually a value that can be copied directly into
912 * SCSIRATE).  The kernel driver will enable synchronous negotiation
913 * for all targets that have a value other than 0 in the lower four
914 * bits of the target scratch space.  This should work regardless of
915 * whether the bios has been installed.
916 */
917
918scratch_ram {
919	address			0x020
920
921	/*
922	 * 1 byte per target starting at this address for configuration values
923	 */
924	TARG_SCRATCH {
925		size		16
926	}
927	ULTRA_ENB {
928		size		2
929	}
930	/*
931	 * Bit vector of targets that have disconnection disabled.
932	 */
933	DISC_DSB {
934		size		2
935	}
936	/*
937	 * Length of pending message
938	 */
939	MSG_LEN	{
940		size		1
941	}
942	/* We reserve 8bytes to store outgoing messages */
943	MSG_OUT {
944		size		8
945	}
946	/* Parameters for DMA Logic */
947	DMAPARAMS {
948		size		1
949		bit	WIDEODD		0x40
950		bit	SCSIEN		0x20
951		bit	SDMAEN		0x10
952		bit	SDMAENACK	0x10
953		bit	HDMAEN		0x08
954		bit	HDMAENACK	0x08
955		bit	DIRECTION	0x04
956		bit	FIFOFLUSH	0x02
957		bit	FIFORESET	0x01
958	}
959	/*
960	 * Number of SCBs supported by
961	 * this card.
962	 */
963	SCBCOUNT {
964		size		1
965	}
966	/*
967	 * Two's complement of SCBCOUNT
968	 */
969	COMP_SCBCOUNT {
970		size		1
971	}
972	/*
973	 * Mask of bits to test against
974	 * when looking at the Queue Count
975	 * registers.  Works around a bug
976	 * on aic7850 chips. 
977	 */
978	QCNTMASK {
979		size		1
980	}
981	SEQ_FLAGS {
982		size		1
983		bit	RESELECTED	0x80
984		bit	IDENTIFY_SEEN	0x40
985		bit	TAGGED_SCB	0x20
986		bit	DPHASE		0x10
987		bit	PAGESCBS	0x04
988		bit	WIDE_BUS	0x02
989		bit	TWIN_BUS	0x01
990	}
991	/*
992	 * Temporary storage for the
993	 * target/channel/lun of a
994	 * reconnecting target
995	 */
996	SAVED_TCL {
997		size		1
998	}
999	SG_COUNT {
1000		size		1
1001	}
1002	/* working value of SG pointer */
1003	SG_NEXT	{
1004		size		4
1005	}
1006	/*
1007	 * head of list of SCBs awaiting
1008	 * selection
1009	 */
1010	WAITING_SCBH {
1011		size		1
1012	}
1013	SAVED_LINKPTR {
1014		size		1
1015	}
1016	SAVED_SCBPTR {
1017		size		1
1018	}
1019	/*
1020	 * The sequencer will stick the frist byte of any rejected message here
1021	 * so we can see what is getting thrown away.
1022	 */
1023	REJBYTE	{
1024		size		1
1025	}
1026	/*
1027	 * The last bus phase as seen by the sequencer. 
1028	 */
1029	LASTPHASE {
1030		size		1
1031		bit	CDI		0x80
1032		bit	IOI		0x40
1033		bit	MSGI		0x20
1034		mask	PHASE_MASK	CDI|IOI|MSGI
1035		mask	P_DATAOUT	0x00
1036		mask	P_DATAIN	IOI
1037		mask	P_COMMAND	CDI
1038		mask	P_MESGOUT	CDI|MSGI
1039		mask	P_STATUS	CDI|IOI
1040		mask	P_MESGIN	CDI|IOI|MSGI
1041		mask	P_BUSFREE	0x01
1042	}
1043	MSGIN_EXT_LEN {
1044		size		1
1045	}
1046	MSGIN_EXT_OPCODE {
1047		size		1
1048	}
1049	/*
1050	 * location 3, stores the last
1051	 * byte of an extended message if
1052	 * it passes the two bytes of space
1053	 * we allow now.  This byte isn't
1054	 * used for anything, it just makes
1055	 * the code shorter for tossing
1056	 * extra bytes.
1057	 */
1058	MSGIN_EXT_BYTES	{
1059		size		3
1060	}
1061	/*
1062	 * head of list of SCBs that are
1063	 * disconnected.  Used for SCB
1064	 * paging.
1065	 */
1066	DISCONNECTED_SCBH {
1067		size		1
1068	}
1069	/*
1070	 * head of list of SCBs that are
1071	 * not in use.  Used for SCB paging.
1072	 */
1073	FREE_SCBH {
1074		size		1
1075	}
1076	HSCB_ADDR {
1077		size		4
1078	}
1079	CUR_SCBID {
1080		size		1
1081	}
1082	/*
1083	 * Running count of commands placed in
1084	 * the QOUTFIFO.  This is cleared by the
1085	 * kernel driver every FIFODEPTH commands.
1086	 */
1087	CMDOUTCNT {
1088		size		1
1089	}
1090	/*
1091	 * Maximum number of entries allowed in
1092	 * the QOUT/INFIFO.
1093	 */
1094	FIFODEPTH {
1095		size		1
1096	}
1097	ARG_1 {
1098		size		1
1099		mask	SEND_MSG	0x80
1100		mask	SEND_SENSE	0x40
1101		mask	SEND_REJ	0x20
1102		alias	RETURN_1
1103	}
1104	/*
1105	 * These are reserved registers in the card's scratch ram.  Some of
1106	 * the values are specified in the AHA2742 technical reference manual
1107	 * and are initialized by the BIOS at boot time.
1108	 */
1109	SCSICONF {
1110		address		0x05a
1111		size		1
1112		bit	RESET_SCSI	0x40
1113	}
1114	HOSTCONF {
1115		address		0x05d
1116		size		1
1117	}
1118	HA_274_BIOSCTRL	{
1119		address		0x05f
1120		size		1
1121		mask	BIOSMODE		0x30
1122		mask	BIOSDISABLED		0x30	
1123		bit	CHANNEL_B_PRIMARY	0x08
1124	}
1125}
1126
1127const SCB_LIST_NULL	0xff
1128
1129
1130/* WDTR Message values */
1131const BUS_8_BIT		0x00
1132const BUS_16_BIT		0x01
1133const BUS_32_BIT		0x02
1134const MAX_OFFSET_8BIT		0x0f
1135const MAX_OFFSET_16BIT	0x08
1136