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 General 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 WIDE_RESIDUE 0x50|SEQINT /* need kernel to back up */
695 /* the SG array for us */
696 mask REJECT_MSG 0x60|SEQINT /* Reject message received */
697 mask BAD_STATUS 0x70|SEQINT /* Bad status from target */
698 mask RESIDUAL 0x80|SEQINT /* Residual byte count != 0 */
699 mask AWAITING_MSG 0xa0|SEQINT /*
700 * Kernel requested to specify
701 * a message to this target
702 * (command was null), so tell
703 * it that it can fill the
706 mask SEQ_SG_FIXUP 0xb0|SEQINT /* need help with fixing up
707 * the sg array pointer after
708 * a phasemis with no valid
709 * sg elements in the shadow
712 mask TRACEPOINT2 0xc0|SEQINT
713 mask MSGIN_PHASEMIS 0xd0|SEQINT /*
714 * Target changed phase on us
715 * when we were expecting
716 * another msgin byte.
718 mask DATA_OVERRUN 0xe0|SEQINT /*
719 * Target attempted to write
720 * beyond the bounds of its
724 mask SEQINT_MASK 0xf0|SEQINT /* SEQINT Status Codes */
725 mask INT_PEND (BRKADRINT|SEQINT|SCSIINT|CMDCMPLT)
729 * Hard Error (p. 3-53)
730 * Reporting of catastrophic errors. You usually cannot recover from
731 * these without a full board reset.
736 bit CIOPARERR 0x80 /* Ultra2 only */
737 bit PCIERRSTAT 0x40 /* PCI only */
738 bit MPARERR 0x20 /* PCI only */
739 bit DPARERR 0x10 /* PCI only */
743 bit DSCTMOUT 0x02 /* Ultra3 only */
748 * Clear Interrupt Status (p. 3-52)
753 bit CLRPARERR 0x10 /* PCI only */
754 bit CLRBRKADRINT 0x08
763 bit PRELOADEN 0x80 /* aic7890 only */
778 bit PRELOAD_AVAIL 0x80
793 * SCB Auto Increment (p. 3-59)
794 * Byte offset into the SCB Array and an optional bit to allow auto
795 * incrementing of the address during download and upload operations
801 mask SCBCNT_MASK 0x1f
805 * Queue In FIFO (p. 3-60)
806 * Input queue for queued SCBs (commands that the seqencer has yet to start)
814 * Queue In Count (p. 3-60)
815 * Number of queued SCBs
823 * SCSIDATL IMAGE Register (p. 5-104)
824 * Write to this register also go to SCSIDATL but this register will preserve
825 * the data for later reading as long as the SCSIDATL_IMGEN bit in the
826 * OPTIONMODE register is set.
828 register SCSIDATL_IMG {
834 * Queue Out FIFO (p. 3-61)
835 * Queue of SCBs that have completed and await the host
843 * CRC Control 1 Register (p. 5-105)
844 * Control bits for the Ultra 160/m CRC facilities
846 register CRCCONTROL1 {
849 bit CRCONSEEN 0x80 /* CRC ON Single Edge ENable */
850 bit CRCVALCHKEN 0x40 /* CRC Value Check Enable */
851 bit CRCENDCHKEN 0x20 /* CRC End Check Enable */
853 bit TARGCRCENDEN 0x08 /* Enable End CRC transfer when target */
854 bit TARGCRCCNTEN 0x04 /* Enable CRC transfer when target */
858 * Queue Out Count (p. 3-61)
859 * Number of queued SCBs in the Out FIFO
867 * SCSI Phase Register (p. 5-106)
891 * SCB Definition (p. 5-4)
900 bit DISCONNECTED 0x04
901 mask SCB_TAG_TYPE 0x03
929 * Really only 3 bytes, but padded to make
930 * the kernel's job easier.
954 const SG_SIZEOF 0x08 /* sizeof(struct ahc_dma) */
956 /* --------------------- AHA-2840-only definitions -------------------- */
958 register SEECTL_2840 {
966 register STATUS_2840 {
975 /* --------------------- AIC-7870-only definitions -------------------- */
977 register DSPCISTATUS {
979 mask DFTHRSH_100 0xc0
1014 bit ARRDONE 0x40 /* SCB Array prefetch done */
1021 register CCSCBADDR {
1033 register HNSCB_QOFF {
1037 register HESCB_QOFF {
1041 register SNSCB_QOFF {
1045 register SESCB_QOFF {
1049 register SDSCB_QOFF {
1053 register QOFF_CTLSTA {
1055 bit ESTABLISH_SCB_AVAIL 0x80
1057 bit SNSCB_ROLLOVER 0x20
1058 bit SDSCB_ROLLOVER 0x10
1059 bit SESCB_ROLLOVER 0x08
1061 mask SCB_QSIZE_256 0x06
1064 register DFF_THRSH {
1066 mask WR_DFTHRSH 0x70
1067 mask RD_DFTHRSH 0x07
1068 mask RD_DFTHRSH_MIN 0x00
1069 mask RD_DFTHRSH_25 0x01
1070 mask RD_DFTHRSH_50 0x02
1071 mask RD_DFTHRSH_63 0x03
1072 mask RD_DFTHRSH_75 0x04
1073 mask RD_DFTHRSH_85 0x05
1074 mask RD_DFTHRSH_90 0x06
1075 mask RD_DFTHRSH_MAX 0x07
1076 mask WR_DFTHRSH_MIN 0x00
1077 mask WR_DFTHRSH_25 0x10
1078 mask WR_DFTHRSH_50 0x20
1079 mask WR_DFTHRSH_63 0x30
1080 mask WR_DFTHRSH_75 0x40
1081 mask WR_DFTHRSH_85 0x50
1082 mask WR_DFTHRSH_90 0x60
1083 mask WR_DFTHRSH_MAX 0x70
1086 register SG_CACHEPTR {
1089 mask SG_USER_DATA 0xfc
1091 bit LAST_SEG_DONE 0x01
1104 /* 7890 Definitions */
1108 bit BRDRW_ULTRA2 0x02
1109 bit BRDSTB_ULTRA2 0x01
1113 * Serial EEPROM Control (p. 4-92 in 7870 Databook)
1114 * Controls the reading and writing of an external serial 1-bit
1115 * EEPROM Device. In order to access the serial EEPROM, you must
1116 * first set the SEEMS bit that generates a request to the memory
1117 * port for access to the serial EEPROM device. When the memory
1118 * port is not busy servicing another request, it reconfigures
1119 * to allow access to the serial EEPROM. When this happens, SEERDY
1120 * gets set high to verify that the memory port access has been
1123 * After successful arbitration for the memory port, the SEECS bit of
1124 * the SEECTL register is connected to the chip select. The SEECK,
1125 * SEEDO, and SEEDI are connected to the clock, data out, and data in
1126 * lines respectively. The SEERDY bit of SEECTL is useful in that it
1127 * gives us an 800 nsec timer. After a write to the SEECTL register,
1128 * the SEERDY goes high 800 nsec later. The one exception to this is
1129 * when we first request access to the memory port. The SEERDY goes
1130 * high to signify that access has been granted and, for this case, has
1131 * no implied timing.
1133 * See 93cx6.c for detailed information on the protocol necessary to
1134 * read the serial EEPROM.
1147 /* ---------------------- Scratch RAM Offsets ------------------------- */
1148 /* These offsets are either to values that are initialized by the board's
1149 * BIOS or are specified by the sequencer code.
1151 * The host adapter card (at least the BIOS) uses 20-2f for SCSI
1152 * device information, 32-33 and 5a-5f as well. As it turns out, the
1153 * BIOS trashes 20-2f, writing the synchronous negotiation results
1154 * on top of the BIOS values, so we re-use those for our per-target
1155 * scratchspace (actually a value that can be copied directly into
1156 * SCSIRATE). The kernel driver will enable synchronous negotiation
1157 * for all targets that have a value other than 0 in the lower four
1158 * bits of the target scratch space. This should work regardless of
1159 * whether the bios has been installed.
1166 * 1 byte per target starting at this address for configuration values
1172 * Bit vector of targets that have ULTRA enabled.
1178 * Bit vector of targets that have disconnection disabled.
1184 * Single byte buffer used to designate the type or message
1185 * to send to a target.
1190 /* Parameters for DMA Logic */
1206 bit IDENTIFY_SEEN 0x80
1207 bit SCBPTR_VALID 0x20
1214 * Temporary storage for the
1215 * target/channel/lun of a
1216 * reconnecting target
1221 /* Working value of the number of SG segments left */
1225 /* Working value of SG pointer */
1230 * The last bus phase as seen by the sequencer.
1237 mask PHASE_MASK CDI|IOI|MSGI
1241 mask P_MESGOUT CDI|MSGI
1242 mask P_STATUS CDI|IOI
1243 mask P_MESGIN CDI|IOI|MSGI
1247 * head of list of SCBs awaiting
1254 * head of list of SCBs that are
1255 * disconnected. Used for SCB
1262 * head of list of SCBs that are
1263 * not in use. Used for SCB paging.
1269 * Address of the hardware scb array in the host.
1275 * Address of the 256 byte array storing the SCBID of outstanding
1276 * untagged SCBs indexed by TCL.
1282 * Address of the array of command descriptors used to store
1283 * information about incoming selections.
1298 * Offset into the command descriptor array for the next
1299 * available desciptor to use.
1301 TMODE_CMDADDR_NEXT {
1307 mask SEND_SENSE 0x40
1309 mask MSGOUT_PHASEMIS 0x10
1318 * Snapshot of MSG_OUT taken after each message is sent.
1325 * Number of times we have filled the CCSGRAM with prefetched
1334 * These are reserved registers in the card's scratch ram. Some of
1335 * the values are specified in the AHA2742 technical reference manual
1336 * and are initialized by the BIOS at boot time.
1343 mask HSCSIID 0x07 /* our SCSI ID */
1344 mask HWSCSIID 0x0f /* our SCSI ID if Wide Bus */
1354 mask BIOSDISABLED 0x30
1355 bit CHANNEL_B_PRIMARY 0x08
1358 * Per target SCSI offset values for Ultra2 controllers.
1366 const SCB_LIST_NULL 0xff
1368 const CCSGADDR_MAX 0x80
1369 const CCSGRAM_MAXSEGS 16
1371 /* Offsets into the SCBID array where different data is stored */
1372 const UNTAGGEDSCB_OFFSET 0
1373 const QOUTFIFO_OFFSET 1
1374 const QINFIFO_OFFSET 2
1376 /* WDTR Message values */
1377 const BUS_8_BIT 0x00
1378 const BUS_16_BIT 0x01
1379 const BUS_32_BIT 0x02
1381 /* Offset maximums */
1382 const MAX_OFFSET_8BIT 0x0f
1383 const MAX_OFFSET_16BIT 0x08
1384 const MAX_OFFSET_ULTRA2 0x7f
1387 /* Target mode command processing constants */
1388 const CMD_GROUP_CODE_SHIFT 0x05
1389 const CMD_GROUP0_BYTE_DELTA -4
1390 const CMD_GROUP2_BYTE_DELTA -6
1391 const CMD_GROUP4_BYTE_DELTA 4
1392 const CMD_GROUP5_BYTE_DELTA 11
1395 * Downloaded (kernel inserted) constants
1399 * Number of command descriptors in the command descriptor array.
1401 const TMODE_NUMCMDS download