twereg.h revision 1.1 1 1.1 ad /* $NetBSD: twereg.h,v 1.1 2000/10/19 14:11:31 ad Exp $ */
2 1.1 ad
3 1.1 ad /*-
4 1.1 ad * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 1.1 ad * All rights reserved.
6 1.1 ad *
7 1.1 ad * This code is derived from software contributed to The NetBSD Foundation
8 1.1 ad * by Andrew Doran.
9 1.1 ad *
10 1.1 ad * Redistribution and use in source and binary forms, with or without
11 1.1 ad * modification, are permitted provided that the following conditions
12 1.1 ad * are met:
13 1.1 ad * 1. Redistributions of source code must retain the above copyright
14 1.1 ad * notice, this list of conditions and the following disclaimer.
15 1.1 ad * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 ad * notice, this list of conditions and the following disclaimer in the
17 1.1 ad * documentation and/or other materials provided with the distribution.
18 1.1 ad * 3. All advertising materials mentioning features or use of this software
19 1.1 ad * must display the following acknowledgement:
20 1.1 ad * This product includes software developed by the NetBSD
21 1.1 ad * Foundation, Inc. and its contributors.
22 1.1 ad * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 ad * contributors may be used to endorse or promote products derived
24 1.1 ad * from this software without specific prior written permission.
25 1.1 ad *
26 1.1 ad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 ad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 ad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 ad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 ad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 ad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 ad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 ad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 ad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 ad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 ad * POSSIBILITY OF SUCH DAMAGE.
37 1.1 ad */
38 1.1 ad
39 1.1 ad /*-
40 1.1 ad * Copyright (c) 2000 Michael Smith
41 1.1 ad * Copyright (c) 2000 BSDi
42 1.1 ad * All rights reserved.
43 1.1 ad *
44 1.1 ad * Redistribution and use in source and binary forms, with or without
45 1.1 ad * modification, are permitted provided that the following conditions
46 1.1 ad * are met:
47 1.1 ad * 1. Redistributions of source code must retain the above copyright
48 1.1 ad * notice, this list of conditions and the following disclaimer.
49 1.1 ad * 2. Redistributions in binary form must reproduce the above copyright
50 1.1 ad * notice, this list of conditions and the following disclaimer in the
51 1.1 ad * documentation and/or other materials provided with the distribution.
52 1.1 ad *
53 1.1 ad * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
54 1.1 ad * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55 1.1 ad * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56 1.1 ad * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
57 1.1 ad * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 1.1 ad * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 1.1 ad * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 1.1 ad * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 1.1 ad * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 1.1 ad * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 1.1 ad * SUCH DAMAGE.
64 1.1 ad *
65 1.1 ad * from FreeBSD: twereg.h,v 1.1 2000/05/24 23:35:23 msmith Exp
66 1.1 ad */
67 1.1 ad
68 1.1 ad #ifndef _PCI_TWEREG_H_
69 1.1 ad #define _PCI_TWEREG_H_
70 1.1 ad
71 1.1 ad /* Board registers. */
72 1.1 ad #define TWE_REG_CTL 0x00
73 1.1 ad #define TWE_REG_STS 0x04
74 1.1 ad #define TWE_REG_CMD_QUEUE 0x08
75 1.1 ad #define TWE_REG_RESP_QUEUE 0x0c
76 1.1 ad
77 1.1 ad /* Control register bit definitions. */
78 1.1 ad #define TWE_CTL_CLEAR_HOST_INTR 0x00080000
79 1.1 ad #define TWE_CTL_CLEAR_ATTN_INTR 0x00040000
80 1.1 ad #define TWE_CTL_MASK_CMD_INTR 0x00020000
81 1.1 ad #define TWE_CTL_MASK_RESP_INTR 0x00010000
82 1.1 ad #define TWE_CTL_UNMASK_CMD_INTR 0x00008000
83 1.1 ad #define TWE_CTL_UNMASK_RESP_INTR 0x00004000
84 1.1 ad #define TWE_CTL_CLEAR_ERROR_STS 0x00000200
85 1.1 ad #define TWE_CTL_ISSUE_SOFT_RESET 0x00000100
86 1.1 ad #define TWE_CTL_ENABLE_INTRS 0x00000080
87 1.1 ad #define TWE_CTL_DISABLE_INTRS 0x00000040
88 1.1 ad #define TWE_CTL_ISSUE_HOST_INTR 0x00000020
89 1.1 ad
90 1.1 ad /* Status register bit definitions. */
91 1.1 ad #define TWE_STS_MAJOR_VERSION_MASK 0xf0000000
92 1.1 ad #define TWE_STS_MINOR_VERSION_MASK 0x0f000000
93 1.1 ad #define TWE_STS_PCI_PARITY_ERROR 0x00800000
94 1.1 ad #define TWE_STS_QUEUE_ERROR 0x00400000
95 1.1 ad #define TWE_STS_MICROCONTROLLER_ERROR 0x00200000
96 1.1 ad #define TWE_STS_PCI_ABORT 0x00100000
97 1.1 ad #define TWE_STS_HOST_INTR 0x00080000
98 1.1 ad #define TWE_STS_ATTN_INTR 0x00040000
99 1.1 ad #define TWE_STS_CMD_INTR 0x00020000
100 1.1 ad #define TWE_STS_RESP_INTR 0x00010000
101 1.1 ad #define TWE_STS_CMD_QUEUE_FULL 0x00008000
102 1.1 ad #define TWE_STS_RESP_QUEUE_EMPTY 0x00004000
103 1.1 ad #define TWE_STS_MICROCONTROLLER_READY 0x00002000
104 1.1 ad #define TWE_STS_CMD_QUEUE_EMPTY 0x00001000
105 1.1 ad
106 1.1 ad #define TWE_STS_ALL_INTRS 0x000f0000
107 1.1 ad #define TWE_STS_CLEARABLE_BITS 0x00d00000
108 1.1 ad #define TWE_STS_EXPECTED_BITS 0x00002000
109 1.1 ad #define TWE_STS_UNEXPECTED_BITS 0x00f80000
110 1.1 ad
111 1.1 ad /* Command packet opcodes. */
112 1.1 ad #define TWE_OP_NOP 0x00
113 1.1 ad #define TWE_OP_INIT_CONNECTION 0x01
114 1.1 ad #define TWE_OP_READ 0x02
115 1.1 ad #define TWE_OP_WRITE 0x03
116 1.1 ad #define TWE_OP_VERIFY 0x04
117 1.1 ad #define TWE_OP_GET_PARAM 0x12
118 1.1 ad #define TWE_OP_SET_PARAM 0x13
119 1.1 ad #define TWE_OP_SECTOR_INFO 0x1a
120 1.1 ad #define TWE_OP_AEN_LISTEN 0x1c
121 1.1 ad
122 1.1 ad /* Asynchronous event notification (AEN) codes. */
123 1.1 ad #define TWE_AEN_QUEUE_EMPTY 0x0000
124 1.1 ad #define TWE_AEN_SOFT_RESET 0x0001
125 1.1 ad #define TWE_AEN_DEGRADED_MIRROR 0x0002
126 1.1 ad #define TWE_AEN_CONTROLLER_ERROR 0x0003
127 1.1 ad #define TWE_AEN_REBUILD_FAIL 0x0004
128 1.1 ad #define TWE_AEN_REBUILD_DONE 0x0005
129 1.1 ad #define TWE_AEN_TABLE_UNDEFINED 0x0015
130 1.1 ad #define TWE_AEN_QUEUE_FULL 0x00ff
131 1.1 ad
132 1.1 ad /* Response queue entries. Masking and shifting yields request ID. */
133 1.1 ad #define TWE_RESP_MASK 0x00000ff0
134 1.1 ad #define TWE_RESP_SHIFT 4
135 1.1 ad
136 1.1 ad /* Miscellenous constants. */
137 1.1 ad #define TWE_ALIGNMENT 512
138 1.1 ad #define TWE_MAX_UNITS 16
139 1.1 ad #define TWE_INIT_MESSAGE_CREDITS 0x100
140 1.1 ad #define TWE_INIT_CMD_PACKET_SIZE 0x3
141 1.1 ad #define TWE_SG_SIZE 62
142 1.1 ad #define TWE_MAX_CMDS 256
143 1.1 ad #define TWE_Q_START 0
144 1.1 ad #define TWE_UNIT_INFORMATION_TABLE_BASE 0x300
145 1.1 ad #define TWE_IOCTL 0x80
146 1.1 ad #define TWE_MAX_AEN_TRIES 100
147 1.1 ad #define TWE_SECTOR_SIZE 512
148 1.1 ad
149 1.1 ad /* Maximum transfer size. XXX This is an arbitrarily chosen value. */
150 1.1 ad #define TWE_MAX_XFER 1048576
151 1.1 ad
152 1.1 ad /* Scatter/gather block. */
153 1.1 ad struct twe_sgb {
154 1.1 ad u_int32_t tsg_address;
155 1.1 ad u_int32_t tsg_length;
156 1.1 ad } __attribute__ ((packed));
157 1.1 ad
158 1.1 ad /*
159 1.1 ad * Command block. This is 512 (really 508) bytes in size, and must be
160 1.1 ad * aligned on a 512 byte boundary.
161 1.1 ad */
162 1.1 ad struct twe_cmd {
163 1.1 ad u_int8_t tc_opcode; /* high 3 bits is S/G list offset */
164 1.1 ad u_int8_t tc_size;
165 1.1 ad u_int8_t tc_cmdid;
166 1.1 ad u_int8_t tc_unit; /* high nybble is host ID */
167 1.1 ad u_int8_t tc_status;
168 1.1 ad u_int8_t tc_flags;
169 1.1 ad u_int16_t tc_count; /* block & param count, msg credits */
170 1.1 ad union {
171 1.1 ad struct {
172 1.1 ad u_int32_t lba;
173 1.1 ad struct twe_sgb sgl[TWE_SG_SIZE];
174 1.1 ad } io __attribute__ ((packed));
175 1.1 ad struct {
176 1.1 ad struct twe_sgb sgl[TWE_SG_SIZE];
177 1.1 ad } param __attribute__ ((packed));
178 1.1 ad struct {
179 1.1 ad u_int32_t response_queue_pointer;
180 1.1 ad } init_connection __attribute__ ((packed));
181 1.1 ad } tc_args __attribute__ ((packed));
182 1.1 ad int32_t tc_pad;
183 1.1 ad } __attribute__ ((packed));
184 1.1 ad
185 1.1 ad /* Get/set parameter block. */
186 1.1 ad struct twe_param {
187 1.1 ad u_int16_t tp_table_id;
188 1.1 ad u_int8_t tp_param_id;
189 1.1 ad u_int8_t tp_param_size;
190 1.1 ad u_int8_t tp_data[1];
191 1.1 ad } __attribute__ ((packed));
192 1.1 ad
193 1.1 ad #endif /* !_PCI_TWEREG_H_ */
194