ahbreg.h revision 1.19 1 1.19 andvar /* $NetBSD: ahbreg.h,v 1.19 2022/02/23 21:54:40 andvar Exp $ */
2 1.3 thorpej
3 1.3 thorpej /*-
4 1.5 thorpej * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
5 1.3 thorpej * All rights reserved.
6 1.3 thorpej *
7 1.3 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.9 mycroft * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
9 1.9 mycroft * Simulation Facility, NASA Ames Research Center.
10 1.3 thorpej *
11 1.3 thorpej * Redistribution and use in source and binary forms, with or without
12 1.3 thorpej * modification, are permitted provided that the following conditions
13 1.3 thorpej * are met:
14 1.3 thorpej * 1. Redistributions of source code must retain the above copyright
15 1.3 thorpej * notice, this list of conditions and the following disclaimer.
16 1.3 thorpej * 2. Redistributions in binary form must reproduce the above copyright
17 1.3 thorpej * notice, this list of conditions and the following disclaimer in the
18 1.3 thorpej * documentation and/or other materials provided with the distribution.
19 1.3 thorpej *
20 1.3 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 1.3 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 1.3 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 1.3 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 1.3 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 1.3 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 1.3 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 1.3 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 1.3 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 1.3 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 1.3 thorpej * POSSIBILITY OF SUCH DAMAGE.
31 1.2 mycroft */
32 1.2 mycroft
33 1.2 mycroft /*
34 1.2 mycroft * Originally written by Julian Elischer (julian (at) tfs.com)
35 1.2 mycroft * for TRW Financial Systems for use under the MACH(2.5) operating system.
36 1.2 mycroft *
37 1.2 mycroft * TRW Financial Systems, in accordance with their agreement with Carnegie
38 1.2 mycroft * Mellon University, makes this software available to CMU to distribute
39 1.2 mycroft * or use in any manner that they see fit as long as this message is kept with
40 1.2 mycroft * the software. For this reason TFS also grants any other persons or
41 1.2 mycroft * organisations permission to use or modify this software.
42 1.2 mycroft *
43 1.2 mycroft * TFS supplies this software to be publicly redistributed
44 1.2 mycroft * on the understanding that TFS is not responsible for the correct
45 1.2 mycroft * functioning of this software in any circumstances.
46 1.2 mycroft */
47 1.2 mycroft
48 1.1 mycroft /*
49 1.6 thorpej * Offset of AHA1740 registers, relative from slot base.
50 1.1 mycroft */
51 1.8 mycroft #define AHB_EISA_SLOT_OFFSET 0x0c80
52 1.8 mycroft #define AHB_EISA_IOSIZE 0x0080
53 1.6 thorpej
54 1.6 thorpej /*
55 1.6 thorpej * AHA1740 EISA board mode registers (relative to port offset)
56 1.6 thorpej */
57 1.7 mycroft #define PORTADDR 0x40
58 1.1 mycroft #define PORTADDR_ENHANCED 0x80
59 1.7 mycroft #define BIOSADDR 0x41
60 1.7 mycroft #define INTDEF 0x42
61 1.7 mycroft #define SCSIDEF 0x43
62 1.7 mycroft #define BUSDEF 0x44
63 1.1 mycroft /**** bit definitions for INTDEF ****/
64 1.1 mycroft #define INT9 0x00
65 1.1 mycroft #define INT10 0x01
66 1.1 mycroft #define INT11 0x02
67 1.1 mycroft #define INT12 0x03
68 1.1 mycroft #define INT14 0x05
69 1.1 mycroft #define INT15 0x06
70 1.17 thorpej #define INTHIGH 0x08 /* interrupt signal is active-high */
71 1.1 mycroft #define INTEN 0x10
72 1.1 mycroft /**** bit definitions for SCSIDEF ****/
73 1.1 mycroft #define HSCSIID 0x0F /* our SCSI ID */
74 1.1 mycroft #define RSTPWR 0x10 /* reset scsi bus on power up or reset */
75 1.1 mycroft /**** bit definitions for BUSDEF ****/
76 1.19 andvar #define B0uS 0x00 /* give up bus immediately */
77 1.1 mycroft #define B4uS 0x01 /* delay 4uSec. */
78 1.1 mycroft #define B8uS 0x02
79 1.1 mycroft
80 1.1 mycroft /*
81 1.6 thorpej * AHA1740 ENHANCED mode mailbox control regs (relative to port offset)
82 1.1 mycroft */
83 1.7 mycroft #define MBOXOUT0 0x50
84 1.7 mycroft #define MBOXOUT1 0x51
85 1.7 mycroft #define MBOXOUT2 0x52
86 1.7 mycroft #define MBOXOUT3 0x53
87 1.7 mycroft
88 1.7 mycroft #define ATTN 0x54
89 1.7 mycroft #define G2CNTRL 0x55
90 1.7 mycroft #define G2INTST 0x56
91 1.7 mycroft #define G2STAT 0x57
92 1.7 mycroft
93 1.7 mycroft #define MBOXIN0 0x58
94 1.7 mycroft #define MBOXIN1 0x59
95 1.7 mycroft #define MBOXIN2 0x5A
96 1.7 mycroft #define MBOXIN3 0x5B
97 1.1 mycroft
98 1.7 mycroft #define G2STAT2 0x5C
99 1.1 mycroft
100 1.1 mycroft /*
101 1.1 mycroft * Bit definitions for the 5 control/status registers
102 1.1 mycroft */
103 1.1 mycroft #define ATTN_TARGET 0x0F
104 1.1 mycroft #define ATTN_OPCODE 0xF0
105 1.1 mycroft #define OP_IMMED 0x10
106 1.1 mycroft #define AHB_TARG_RESET 0x80
107 1.1 mycroft #define OP_START_ECB 0x40
108 1.1 mycroft #define OP_ABORT_ECB 0x50
109 1.1 mycroft
110 1.1 mycroft #define G2CNTRL_SET_HOST_READY 0x20
111 1.1 mycroft #define G2CNTRL_CLEAR_EISA_INT 0x40
112 1.1 mycroft #define G2CNTRL_HARD_RESET 0x80
113 1.1 mycroft
114 1.1 mycroft #define G2INTST_TARGET 0x0F
115 1.1 mycroft #define G2INTST_INT_STAT 0xF0
116 1.1 mycroft #define AHB_ECB_OK 0x10
117 1.1 mycroft #define AHB_ECB_RECOVERED 0x50
118 1.1 mycroft #define AHB_HW_ERR 0x70
119 1.1 mycroft #define AHB_IMMED_OK 0xA0
120 1.1 mycroft #define AHB_ECB_ERR 0xC0
121 1.1 mycroft #define AHB_ASN 0xD0 /* for target mode */
122 1.1 mycroft #define AHB_IMMED_ERR 0xE0
123 1.1 mycroft
124 1.1 mycroft #define G2STAT_BUSY 0x01
125 1.1 mycroft #define G2STAT_INT_PEND 0x02
126 1.1 mycroft #define G2STAT_MBOX_EMPTY 0x04
127 1.1 mycroft
128 1.1 mycroft #define G2STAT2_HOST_READY 0x01
129 1.1 mycroft
130 1.11 wiz #define AHB_NSEG 33 /* number of DMA segments supported */
131 1.1 mycroft
132 1.1 mycroft struct ahb_dma_seg {
133 1.18 thorpej uint32_t seg_addr;
134 1.18 thorpej uint32_t seg_len;
135 1.1 mycroft };
136 1.1 mycroft
137 1.1 mycroft struct ahb_ecb_status {
138 1.18 thorpej uint16_t status;
139 1.1 mycroft #define ST_DON 0x0001
140 1.1 mycroft #define ST_DU 0x0002
141 1.1 mycroft #define ST_QF 0x0008
142 1.1 mycroft #define ST_SC 0x0010
143 1.1 mycroft #define ST_DO 0x0020
144 1.1 mycroft #define ST_CH 0x0040
145 1.1 mycroft #define ST_INT 0x0080
146 1.1 mycroft #define ST_ASA 0x0100
147 1.1 mycroft #define ST_SNS 0x0200
148 1.1 mycroft #define ST_INI 0x0800
149 1.1 mycroft #define ST_ME 0x1000
150 1.1 mycroft #define ST_ECA 0x4000
151 1.18 thorpej uint8_t host_stat;
152 1.1 mycroft #define HS_OK 0x00
153 1.1 mycroft #define HS_CMD_ABORTED_HOST 0x04
154 1.1 mycroft #define HS_CMD_ABORTED_ADAPTER 0x05
155 1.1 mycroft #define HS_TIMED_OUT 0x11
156 1.1 mycroft #define HS_HARDWARE_ERR 0x20
157 1.1 mycroft #define HS_SCSI_RESET_ADAPTER 0x22
158 1.1 mycroft #define HS_SCSI_RESET_INCOMING 0x23
159 1.18 thorpej uint8_t target_stat;
160 1.18 thorpej uint32_t resid_count;
161 1.18 thorpej uint32_t resid_addr;
162 1.18 thorpej uint16_t addit_status;
163 1.18 thorpej uint8_t sense_len;
164 1.18 thorpej uint8_t unused[9];
165 1.18 thorpej uint8_t cdb[6];
166 1.1 mycroft };
167 1.1 mycroft
168 1.1 mycroft struct ahb_ecb {
169 1.18 thorpej uint8_t opcode;
170 1.1 mycroft #define ECB_SCSI_OP 0x01
171 1.18 thorpej uint8_t:4;
172 1.18 thorpej uint8_t options:3;
173 1.18 thorpej uint8_t:1;
174 1.18 thorpej uint16_t opt1;
175 1.1 mycroft #define ECB_CNE 0x0001
176 1.1 mycroft #define ECB_DI 0x0080
177 1.1 mycroft #define ECB_SES 0x0400
178 1.1 mycroft #define ECB_S_G 0x1000
179 1.1 mycroft #define ECB_DSB 0x4000
180 1.1 mycroft #define ECB_ARS 0x8000
181 1.18 thorpej uint16_t opt2;
182 1.1 mycroft #define ECB_LUN 0x0007
183 1.1 mycroft #define ECB_TAG 0x0008
184 1.1 mycroft #define ECB_TT 0x0030
185 1.1 mycroft #define ECB_ND 0x0040
186 1.1 mycroft #define ECB_DAT 0x0100
187 1.1 mycroft #define ECB_DIR 0x0200
188 1.1 mycroft #define ECB_ST 0x0400
189 1.1 mycroft #define ECB_CHK 0x0800
190 1.1 mycroft #define ECB_REC 0x4000
191 1.1 mycroft #define ECB_NRB 0x8000
192 1.18 thorpej uint16_t unused1;
193 1.18 thorpej uint32_t data_addr;
194 1.18 thorpej uint32_t data_length;
195 1.18 thorpej uint32_t status;
196 1.18 thorpej uint32_t link_addr;
197 1.18 thorpej uint16_t unused2;
198 1.18 thorpej uint16_t unused3;
199 1.18 thorpej uint32_t sense_ptr;
200 1.18 thorpej uint8_t req_sense_length;
201 1.18 thorpej uint8_t scsi_cmd_length;
202 1.18 thorpej uint16_t cksum;
203 1.18 thorpej uint8_t scsi_cmd[12];
204 1.1 mycroft
205 1.13 thorpej /*-----------------end of hardware supported fields----------------*/
206 1.13 thorpej
207 1.1 mycroft struct ahb_dma_seg ahb_dma[AHB_NSEG];
208 1.1 mycroft struct ahb_ecb_status ecb_status;
209 1.14 thorpej struct scsi_sense_data ecb_sense;
210 1.13 thorpej
211 1.1 mycroft TAILQ_ENTRY(ahb_ecb) chain;
212 1.1 mycroft struct ahb_ecb *nexthash;
213 1.18 thorpej uint32_t ecb_dma_addr;
214 1.4 bouyer struct scsipi_xfer *xs; /* the scsipi_xfer for this cmd */
215 1.1 mycroft int flags;
216 1.1 mycroft #define ECB_ALLOC 0x01
217 1.1 mycroft #define ECB_ABORT 0x02
218 1.1 mycroft #define ECB_IMMED 0x04
219 1.1 mycroft #define ECB_IMMED_FAIL 0x08
220 1.1 mycroft int timeout;
221 1.3 thorpej
222 1.3 thorpej /*
223 1.3 thorpej * This DMA map maps the buffer involved in the transfer.
224 1.3 thorpej * Its contents are loaded into "ahb_dma" above.
225 1.3 thorpej */
226 1.3 thorpej bus_dmamap_t dmamap_xfer;
227 1.1 mycroft };
228