2 * Aic7xxx register and scratch ram definitions.
4 * Copyright (c) 1994-1998 Justin Gibbs.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * Where this Software is combined with software released under the terms of
17 * the GNU Public License ("GPL") and the terms of the GPL would require the
18 * combined work to also be released under the terms of the GPL, the terms
19 * and conditions of this License will apply in addition to those of the
20 * GPL with the exception of any terms or conditions of this License that
21 * conflict with, or are expressly prohibited by, the GPL.
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
27 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * $Id: aic7xxx.reg,v 1.4 1997/06/27 19:38:39 gibbs Exp $
39 * This file is processed by the aic7xxx_asm utility for use in assembling
40 * firmware for the aic7xxx family of SCSI host adapters as well as to generate
41 * a C header file for use in the kernel portion of the Aic7xxx driver.
43 * All page numbers refer to the Adaptec AIC-7770 Data Book available from
44 * Adaptec's Technical Documents Department 1-800-934-2766
48 * SCSI Sequence Control (p. 3-11).
49 * Each bit, when set starts a specific SCSI sequence on the bus
65 * SCSI Transfer Control 0 Register (pp. 3-13).
66 * Controls the SCSI module data path.
81 * SCSI Transfer Control 1 Register (pp. 3-14,15).
82 * Controls the SCSI module data path.
93 bit STPWEN 0x01 /* Powered Termination */
97 * SCSI Control Signal Read Register (p. 3-15).
98 * Reads the actual state of the SCSI bus pins
112 * Possible phases in SCSISIGI
114 mask PHASE_MASK CDI|IOI|MSGI
118 mask P_MESGOUT CDI|MSGI
119 mask P_STATUS CDI|IOI
120 mask P_MESGIN CDI|IOI|MSGI
124 * SCSI Control Signal Write Register (p. 3-16).
125 * Writing to this register modifies the control signals on the bus. Only
126 * those signals that are allowed in the current mode (Initiator/Target) are
141 * Possible phases to write into SCSISIG0
143 mask PHASE_MASK CDI|IOI|MSGI
147 mask P_MESGOUT CDI|MSGI
148 mask P_STATUS CDI|IOI
149 mask P_MESGIN CDI|IOI|MSGI
153 * SCSI Rate Control (p. 3-17).
154 * Contents of this register determine the Synchronous SCSI data transfer
155 * rate and the maximum synchronous Req/Ack offset. An offset of 0 in the
156 * SOFS (3:0) bits disables synchronous data transfers. Any offset value
157 * greater than 0 enables synchronous transfers.
162 bit WIDEXFER 0x80 /* Wide transfer control */
163 mask SXFR 0x70 /* Sync transfer rate */
164 mask SXFR_ULTRA2 0x7f /* Sync transfer rate */
165 mask SOFS 0x0f /* Sync offset */
170 * Contains the ID of the board and the current target on the
176 mask TID 0xf0 /* Target ID mask */
177 mask OID 0x0f /* Our ID mask */
179 * SCSI Maximum Offset (p. 4-61 aic7890/91 Data Book)
180 * The aic7890/91 allow an offset of up to 127 transfers in both wide
184 mask SOFS_ULTRA2 0x7f /* Sync offset U2 chips */
188 * SCSI Latched Data (p. 3-19).
189 * Read/Write latches used to transfer data on the SCSI bus during
190 * Automatic or Manual PIO mode. SCSIDATH can be used for the
191 * upper byte of a 16bit wide asynchronouse data phase transfer.
204 * SCSI Transfer Count (pp. 3-19,20)
205 * These registers count down the number of bytes transferred
206 * across the SCSI bus. The counter is decremented only once
207 * the data has been safely transferred. SDONE in SSTAT0 is
208 * set when STCNT goes to 0
217 * Option Mode Register (Alternate Mode) (p. 5-198)
218 * This register is used to set certain options on Ultra3 based chips.
219 * The chip must be in alternate mode (bit ALT_MODE in SFUNCT must be set)
221 register OPTIONMODE {
229 bit SCSIDATL_IMGEN 0x04
230 bit AUTO_MSGOUT_DE 0x02
231 bit DIS_MSGIN_DUALEDGE 0x01
236 * Clear SCSI Interrupt 0 (p. 3-20)
237 * Writing a 1 to a bit clears the associated SCSI Interrupt in SSTAT0.
250 * SCSI Status 0 (p. 3-21)
251 * Contains one set of SCSI Interrupt codes
252 * These are most likely of interest to the sequencer
257 bit TARGET 0x80 /* Board acting as target */
258 bit SELDO 0x40 /* Selection Done */
259 bit SELDI 0x20 /* Board has been selected */
260 bit SELINGO 0x10 /* Selection In Progress */
261 bit SWRAP 0x08 /* 24bit counter wrap */
262 bit IOERR 0x08 /* LVD Tranceiver mode changed */
263 bit SDONE 0x04 /* STCNT = 0x000000 */
264 bit SPIORDY 0x02 /* SCSI PIO Ready */
265 bit DMADONE 0x01 /* DMA transfer completed */
269 * Clear SCSI Interrupt 1 (p. 3-23)
270 * Writing a 1 to a bit clears the associated SCSI Interrupt in SSTAT1.
285 * SCSI Status 1 (p. 3-24)
301 * SCSI Status 2 (pp. 3-25,26)
309 bit EXP_ACTIVE 0x10 /* SCSI Expander Active */
310 bit CRCVALERR 0x08 /* CRC Value Error */
311 bit CRCENDERR 0x04 /* CRC End Error */
312 bit CRCREQERR 0x02 /* CRC REQ Error */
313 bit DUAL_EDGE_ERROR 0x01 /* Invalid pins for Dual Edge phase */
318 * SCSI Status 3 (p. 3-26)
328 * SCSI ID for the aic7890/91 chips
330 register SCSIID_ULTRA2 {
333 mask TID 0xf0 /* Target ID mask */
334 mask OID 0x0f /* Our ID mask */
338 * SCSI Interrupt Mode 1 (p. 3-28)
339 * Setting any bit will enable the corresponding function
340 * in SIMODE0 to interrupt via the IRQ pin.
349 bit ENIOERR 0x08 /* LVD Tranceiver mode changes */
356 * SCSI Interrupt Mode 1 (pp. 3-28,29)
357 * Setting any bit will enable the corresponding function
358 * in SIMODE1 to interrupt via the IRQ pin.
374 * SCSI Data Bus (High) (p. 3-29)
375 * This register reads data on the SCSI Data bus directly.
388 * SCSI/Host Address (p. 3-30)
389 * These registers hold the host address for the byte about to be
390 * transferred on the SCSI bus. They are counted up in the same
391 * manner as STCNT is counted down. SHADDR should always be used
392 * to determine the address of the last byte transferred since HADDR
393 * can be skewed by write ahead.
402 * Selection Timeout Timer (p. 3-30)
416 * Selection/Reselection ID (p. 3-31)
417 * Upper four bits are the device id. The ONEBIT is set when the re/selecting
418 * device did not set its own ID.
428 * Serial Port I/O Cabability register (p. 4-95 aic7860 Data Book)
429 * Indicates if external logic has been attached to the chip to
430 * perform the tasks of accessing a serial eeprom, testing termination
431 * strength, and performing cable detection. On the aic7860, most of
432 * these features are handled on chip, but on the aic7855 an attached
433 * aic3800 does the grunt work.
441 bit HAS_BRDCTL 0x10 /* External Board control */
442 bit SEEPROM 0x08 /* External serial eeprom logic */
443 bit EEPROM 0x04 /* Writable external BIOS ROM */
444 bit ROM 0x02 /* Logic for accessing external ROM */
445 bit SSPIOCPS 0x01 /* Termination and cable detection */
449 * SCSI Block Control (p. 3-32)
450 * Controls Bus type and channel selection. In a twin channel configuration
451 * addresses 0x00-0x1e are gated to the appropriate channel based on this
452 * register. SELWIDE allows for the coexistence of 8bit and 16bit devices
458 bit DIAGLEDEN 0x80 /* Aic78X0 only */
459 bit DIAGLEDON 0x40 /* Aic78X0 only */
460 bit AUTOFLUSHDIS 0x20
462 bit ENAB40 0x08 /* LVD transceiver active */
463 bit ENAB20 0x04 /* SE/HVD transceiver active */
465 bit XCVR 0x01 /* External transceiver active */
469 * Sequencer Control (p. 3-33)
470 * Error detection mode and speed configuration
486 * Sequencer RAM Data (p. 3-34)
487 * Single byte window into the Scratch Ram area starting at the address
488 * specified by SEQADDR0 and SEQADDR1. To write a full word, simply write
489 * four bytes in succession. The SEQADDRs will increment after the most
490 * significant byte is written
498 * Sequencer Address Registers (p. 3-35)
499 * Only the first bit of SEQADDR1 holds addressing information
509 mask SEQADDR1_MASK 0x01
514 * We cheat by passing arguments in the Accumulator up to the kernel driver
579 * Board Control (p. 3-43)
588 register DSCOMMAND0 {
595 bit INTSCBRAMSEL 0x08
602 * On the aic78X0 chips, Board Control is replaced by the DSCommand
608 bit CACHETHEN 0x80 /* Cache Threshold enable */
609 bit DPARCKEN 0x40 /* Data Parity Check Enable */
610 bit MPARCKEN 0x20 /* Memory Parity Check Enable */
611 bit EXTREQLCK 0x10 /* External Request Lock */
615 * Bus On/Off Time (p. 3-44)
625 * Bus Speed (p. 3-45)
633 mask DFTHRSH_100 0xc0
637 * Host Control (p. 3-47) R/W
638 * Overall host control of the device.
653 * Host Address (p. 3-48)
654 * This register contains the address of the byte about
655 * to be transferred across the host bus.
670 * SCB Pointer (p. 3-49)
671 * Gate one of the four SCBs into the SCBARRAY window.
679 * Interrupt Status (p. 3-50)
680 * Status for system interrupts
689 mask BAD_PHASE SEQINT /* unknown scsi bus phase */
690 mask SEND_REJECT 0x10|SEQINT /* sending a message reject */
691 mask NO_IDENT 0x20|SEQINT /* no IDENTIFY after reconnect*/
692 mask NO_MATCH 0x30|SEQINT /* no cmd match for reconnect */
693 mask EXTENDED_MSG 0x40|SEQINT /* Extended message received */
694 mask ABORT_REQUESTED 0x50|SEQINT /* Reconect of aborted SCB */
695 mask REJECT_MSG 0x60|SEQINT /* Reject message received */
696 mask BAD_STATUS 0x70|SEQINT /* Bad status from target */
697 mask RESIDUAL 0x80|SEQINT /* Residual byte count != 0 */
698 mask AWAITING_MSG 0xa0|SEQINT /*
699 * Kernel requested to specify
700 * a message to this target
701 * (command was null), so tell
702 * it that it can fill the
705 mask TRACEPOINT 0xb0|SEQINT
706 mask TRACEPOINT2 0xc0|SEQINT
707 mask MSGIN_PHASEMIS 0xd0|SEQINT /*
708 * Target changed phase on us
709 * when we were expecting
710 * another msgin byte.
712 mask DATA_OVERRUN 0xe0|SEQINT /*
713 * Target attempted to write
714 * beyond the bounds of its
718 mask SEQINT_MASK 0xf0|SEQINT /* SEQINT Status Codes */
719 mask INT_PEND (BRKADRINT|SEQINT|SCSIINT|CMDCMPLT)
723 * Hard Error (p. 3-53)
724 * Reporting of catastrophic errors. You usually cannot recover from
725 * these without a full board reset.
730 bit CIOPARERR 0x80 /* Ultra2 only */
731 bit PCIERRSTAT 0x40 /* PCI only */
732 bit MPARERR 0x20 /* PCI only */
733 bit DPARERR 0x10 /* PCI only */
737 bit DSCTMOUT 0x02 /* Ultra3 only */
742 * Clear Interrupt Status (p. 3-52)
747 bit CLRPARERR 0x10 /* PCI only */
748 bit CLRBRKADRINT 0x08
757 bit PRELOADEN 0x80 /* aic7890 only */
772 bit PRELOAD_AVAIL 0x80
787 * SCB Auto Increment (p. 3-59)
788 * Byte offset into the SCB Array and an optional bit to allow auto
789 * incrementing of the address during download and upload operations
795 mask SCBCNT_MASK 0x1f
799 * Queue In FIFO (p. 3-60)
800 * Input queue for queued SCBs (commands that the seqencer has yet to start)
808 * Queue In Count (p. 3-60)
809 * Number of queued SCBs
817 * SCSIDATL IMAGE Register (p. 5-104)
818 * Write to this register also go to SCSIDATL but this register will preserve
819 * the data for later reading as long as the SCSIDATL_IMGEN bit in the
820 * OPTIONMODE register is set.
822 register SCSIDATL_IMG {
828 * Queue Out FIFO (p. 3-61)
829 * Queue of SCBs that have completed and await the host
837 * CRC Control 1 Register (p. 5-105)
838 * Control bits for the Ultra 160/m CRC facilities
840 register CRCCONTROL1 {
843 bit CRCONSEEN 0x80 /* CRC ON Single Edge ENable */
844 bit CRCVALCHKEN 0x40 /* CRC Value Check Enable */
845 bit CRCENDCHKEN 0x20 /* CRC End Check Enable */
847 bit TARGCRCENDEN 0x08 /* Enable End CRC transfer when target */
848 bit TARGCRCCNTEN 0x04 /* Enable CRC transfer when target */
852 * Queue Out Count (p. 3-61)
853 * Number of queued SCBs in the Out FIFO
861 * SCSI Phase Register (p. 5-106)
885 * SCB Definition (p. 5-4)
894 bit DISCONNECTED 0x04
895 mask SCB_TAG_TYPE 0x03
923 * Really only 3 bytes, but padded to make
924 * the kernel's job easier.
948 const SG_SIZEOF 0x08 /* sizeof(struct ahc_dma) */
950 /* --------------------- AHA-2840-only definitions -------------------- */
952 register SEECTL_2840 {
960 register STATUS_2840 {
969 /* --------------------- AIC-7870-only definitions -------------------- */
971 register DSPCISTATUS {
973 mask DFTHRSH_100 0xc0
1008 bit ARRDONE 0x40 /* SCB Array prefetch done */
1015 register CCSCBADDR {
1027 register HNSCB_QOFF {
1031 register HESCB_QOFF {
1035 register SNSCB_QOFF {
1039 register SESCB_QOFF {
1043 register SDSCB_QOFF {
1047 register QOFF_CTLSTA {
1049 bit ESTABLISH_SCB_AVAIL 0x80
1051 bit SNSCB_ROLLOVER 0x20
1052 bit SDSCB_ROLLOVER 0x10
1053 bit SESCB_ROLLOVER 0x08
1055 mask SCB_QSIZE_256 0x06
1058 register DFF_THRSH {
1060 mask WR_DFTHRSH 0x70
1061 mask RD_DFTHRSH 0x07
1062 mask RD_DFTHRSH_MIN 0x00
1063 mask RD_DFTHRSH_25 0x01
1064 mask RD_DFTHRSH_50 0x02
1065 mask RD_DFTHRSH_63 0x03
1066 mask RD_DFTHRSH_75 0x04
1067 mask RD_DFTHRSH_85 0x05
1068 mask RD_DFTHRSH_90 0x06
1069 mask RD_DFTHRSH_MAX 0x07
1070 mask WR_DFTHRSH_MIN 0x00
1071 mask WR_DFTHRSH_25 0x10
1072 mask WR_DFTHRSH_50 0x20
1073 mask WR_DFTHRSH_63 0x30
1074 mask WR_DFTHRSH_75 0x40
1075 mask WR_DFTHRSH_85 0x50
1076 mask WR_DFTHRSH_90 0x60
1077 mask WR_DFTHRSH_MAX 0x70
1080 register SG_CACHEPTR {
1083 mask SG_USER_DATA 0xfc
1085 bit LAST_SEG_DONE 0x01
1098 /* 7890 Definitions */
1102 bit BRDRW_ULTRA2 0x02
1103 bit BRDSTB_ULTRA2 0x01
1107 * Serial EEPROM Control (p. 4-92 in 7870 Databook)
1108 * Controls the reading and writing of an external serial 1-bit
1109 * EEPROM Device. In order to access the serial EEPROM, you must
1110 * first set the SEEMS bit that generates a request to the memory
1111 * port for access to the serial EEPROM device. When the memory
1112 * port is not busy servicing another request, it reconfigures
1113 * to allow access to the serial EEPROM. When this happens, SEERDY
1114 * gets set high to verify that the memory port access has been
1117 * After successful arbitration for the memory port, the SEECS bit of
1118 * the SEECTL register is connected to the chip select. The SEECK,
1119 * SEEDO, and SEEDI are connected to the clock, data out, and data in
1120 * lines respectively. The SEERDY bit of SEECTL is useful in that it
1121 * gives us an 800 nsec timer. After a write to the SEECTL register,
1122 * the SEERDY goes high 800 nsec later. The one exception to this is
1123 * when we first request access to the memory port. The SEERDY goes
1124 * high to signify that access has been granted and, for this case, has
1125 * no implied timing.
1127 * See 93cx6.c for detailed information on the protocol necessary to
1128 * read the serial EEPROM.
1141 /* ---------------------- Scratch RAM Offsets ------------------------- */
1142 /* These offsets are either to values that are initialized by the board's
1143 * BIOS or are specified by the sequencer code.
1145 * The host adapter card (at least the BIOS) uses 20-2f for SCSI
1146 * device information, 32-33 and 5a-5f as well. As it turns out, the
1147 * BIOS trashes 20-2f, writing the synchronous negotiation results
1148 * on top of the BIOS values, so we re-use those for our per-target
1149 * scratchspace (actually a value that can be copied directly into
1150 * SCSIRATE). The kernel driver will enable synchronous negotiation
1151 * for all targets that have a value other than 0 in the lower four
1152 * bits of the target scratch space. This should work regardless of
1153 * whether the bios has been installed.
1160 * 1 byte per target starting at this address for configuration values
1166 * Bit vector of targets that have ULTRA enabled.
1172 * Bit vector of targets that have disconnection disabled.
1178 * Single byte buffer used to designate the type or message
1179 * to send to a target.
1184 /* Parameters for DMA Logic */
1200 bit IDENTIFY_SEEN 0x80
1201 bit SCBPTR_VALID 0x20
1208 * Temporary storage for the
1209 * target/channel/lun of a
1210 * reconnecting target
1215 /* Working value of the number of SG segments left */
1219 /* Working value of SG pointer */
1224 * The last bus phase as seen by the sequencer.
1231 mask PHASE_MASK CDI|IOI|MSGI
1235 mask P_MESGOUT CDI|MSGI
1236 mask P_STATUS CDI|IOI
1237 mask P_MESGIN CDI|IOI|MSGI
1241 * head of list of SCBs awaiting
1248 * head of list of SCBs that are
1249 * disconnected. Used for SCB
1256 * head of list of SCBs that are
1257 * not in use. Used for SCB paging.
1263 * Address of the hardware scb array in the host.
1269 * Address of the 256 byte array storing the SCBID of outstanding
1270 * untagged SCBs indexed by TCL.
1276 * Address of the array of command descriptors used to store
1277 * information about incoming selections.
1292 * Offset into the command descriptor array for the next
1293 * available desciptor to use.
1295 TMODE_CMDADDR_NEXT {
1301 mask SEND_SENSE 0x40
1303 mask MSGOUT_PHASEMIS 0x10
1312 * Snapshot of MSG_OUT taken after each message is sent.
1319 * Number of times we have filled the CCSGRAM with prefetched
1328 * These are reserved registers in the card's scratch ram. Some of
1329 * the values are specified in the AHA2742 technical reference manual
1330 * and are initialized by the BIOS at boot time.
1337 mask HSCSIID 0x07 /* our SCSI ID */
1338 mask HWSCSIID 0x0f /* our SCSI ID if Wide Bus */
1348 mask BIOSDISABLED 0x30
1349 bit CHANNEL_B_PRIMARY 0x08
1352 * Per target SCSI offset values for Ultra2 controllers.
1360 const SCB_LIST_NULL 0xff
1362 const CCSGADDR_MAX 0x80
1363 const CCSGRAM_MAXSEGS 16
1365 /* Offsets into the SCBID array where different data is stored */
1366 const UNTAGGEDSCB_OFFSET 0
1367 const QOUTFIFO_OFFSET 1
1368 const QINFIFO_OFFSET 2
1370 /* WDTR Message values */
1371 const BUS_8_BIT 0x00
1372 const BUS_16_BIT 0x01
1373 const BUS_32_BIT 0x02
1375 /* Offset maximums */
1376 const MAX_OFFSET_8BIT 0x0f
1377 const MAX_OFFSET_16BIT 0x08
1378 const MAX_OFFSET_ULTRA2 0x7f
1381 /* Target mode command processing constants */
1382 const CMD_GROUP_CODE_SHIFT 0x05
1383 const CMD_GROUP0_BYTE_DELTA -4
1384 const CMD_GROUP2_BYTE_DELTA -6
1385 const CMD_GROUP4_BYTE_DELTA 4
1386 const CMD_GROUP5_BYTE_DELTA 11
1389 * Downloaded (kernel inserted) constants
1393 * Number of command descriptors in the command descriptor array.
1395 const TMODE_NUMCMDS download