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