mpt.h revision 1.5.30.1 1 1.5.30.1 ad /* $NetBSD: mpt.h,v 1.5.30.1 2007/08/20 18:36:47 ad Exp $ */
2 1.1 thorpej
3 1.1 thorpej /*
4 1.1 thorpej * Copyright (c) 2000, 2001 by Greg Ansley
5 1.1 thorpej *
6 1.1 thorpej * Redistribution and use in source and binary forms, with or without
7 1.1 thorpej * modification, are permitted provided that the following conditions
8 1.1 thorpej * are met:
9 1.1 thorpej * 1. Redistributions of source code must retain the above copyright
10 1.1 thorpej * notice immediately at the beginning of the file, without modification,
11 1.1 thorpej * this list of conditions, and the following disclaimer.
12 1.1 thorpej * 2. The name of the author may not be used to endorse or promote products
13 1.1 thorpej * derived from this software without specific prior written permission.
14 1.1 thorpej *
15 1.1 thorpej * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 1.1 thorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 1.1 thorpej * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 1.1 thorpej * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
19 1.1 thorpej * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 1.1 thorpej * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 1.1 thorpej * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 1.1 thorpej * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 1.1 thorpej * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 1.1 thorpej * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 1.1 thorpej * SUCH DAMAGE.
26 1.1 thorpej */
27 1.1 thorpej /*
28 1.1 thorpej * Additional Copyright (c) 2002 by Matthew Jacob under same license.
29 1.1 thorpej */
30 1.1 thorpej
31 1.1 thorpej /*
32 1.1 thorpej * mpt.h:
33 1.1 thorpej *
34 1.1 thorpej * Generic definitions for LSI Fusion adapters.
35 1.3 perry *
36 1.1 thorpej * Adapted from the FreeBSD "mpt" driver by Jason R. Thorpe for
37 1.1 thorpej * Wasabi Systems, Inc.
38 1.1 thorpej */
39 1.1 thorpej
40 1.1 thorpej #ifndef _DEV_IC_MPT_H_
41 1.1 thorpej #define _DEV_IC_MPT_H_
42 1.1 thorpej
43 1.1 thorpej #include <dev/ic/mpt_netbsd.h>
44 1.1 thorpej
45 1.1 thorpej #define MPT_OK (0)
46 1.1 thorpej #define MPT_FAIL (0x10000)
47 1.1 thorpej
48 1.1 thorpej /* Register Offset to chip registers */
49 1.1 thorpej #define MPT_OFFSET_DOORBELL 0x00
50 1.1 thorpej #define MPT_OFFSET_SEQUENCE 0x04
51 1.1 thorpej #define MPT_OFFSET_DIAGNOSTIC 0x08
52 1.1 thorpej #define MPT_OFFSET_TEST 0x0C
53 1.1 thorpej #define MPT_OFFSET_INTR_STATUS 0x30
54 1.1 thorpej #define MPT_OFFSET_INTR_MASK 0x34
55 1.1 thorpej #define MPT_OFFSET_REQUEST_Q 0x40
56 1.1 thorpej #define MPT_OFFSET_REPLY_Q 0x44
57 1.1 thorpej #define MPT_OFFSET_HOST_INDEX 0x50
58 1.1 thorpej #define MPT_OFFSET_FUBAR 0x90
59 1.1 thorpej
60 1.1 thorpej #define MPT_DIAG_SEQUENCE_1 0x04
61 1.1 thorpej #define MPT_DIAG_SEQUENCE_2 0x0b
62 1.1 thorpej #define MPT_DIAG_SEQUENCE_3 0x02
63 1.1 thorpej #define MPT_DIAG_SEQUENCE_4 0x07
64 1.1 thorpej #define MPT_DIAG_SEQUENCE_5 0x0d
65 1.1 thorpej
66 1.1 thorpej /* Bit Maps for DOORBELL register */
67 1.1 thorpej enum DB_STATE_BITS {
68 1.1 thorpej MPT_DB_STATE_RESET = 0x00000000,
69 1.1 thorpej MPT_DB_STATE_READY = 0x10000000,
70 1.1 thorpej MPT_DB_STATE_RUNNING = 0x20000000,
71 1.1 thorpej MPT_DB_STATE_FAULT = 0x40000000,
72 1.1 thorpej MPT_DB_STATE_MASK = 0xf0000000
73 1.1 thorpej };
74 1.1 thorpej
75 1.1 thorpej #define MPT_STATE(v) ((enum DB_STATE_BITS)((v) & MPT_DB_STATE_MASK))
76 1.1 thorpej
77 1.1 thorpej #define MPT_DB_LENGTH_SHIFT (16)
78 1.1 thorpej #define MPT_DB_DATA_MASK (0xffff)
79 1.1 thorpej
80 1.1 thorpej #define MPT_DB_DB_USED 0x08000000
81 1.1 thorpej #define MPT_DB_IS_IN_USE(v) (((v) & MPT_DB_DB_USED) != 0)
82 1.1 thorpej
83 1.1 thorpej /*
84 1.1 thorpej * "Whom" initializor values
85 1.1 thorpej */
86 1.1 thorpej #define MPT_DB_INIT_NOONE 0x00
87 1.1 thorpej #define MPT_DB_INIT_BIOS 0x01
88 1.1 thorpej #define MPT_DB_INIT_ROMBIOS 0x02
89 1.1 thorpej #define MPT_DB_INIT_PCIPEER 0x03
90 1.1 thorpej #define MPT_DB_INIT_HOST 0x04
91 1.1 thorpej #define MPT_DB_INIT_MANUFACTURE 0x05
92 1.1 thorpej
93 1.1 thorpej #define MPT_WHO(v) \
94 1.1 thorpej ((v & MPI_DOORBELL_WHO_INIT_MASK) >> MPI_DOORBELL_WHO_INIT_SHIFT)
95 1.1 thorpej
96 1.1 thorpej /* Function Maps for DOORBELL register */
97 1.1 thorpej enum DB_FUNCTION_BITS {
98 1.1 thorpej MPT_FUNC_IOC_RESET = 0x40000000,
99 1.1 thorpej MPT_FUNC_UNIT_RESET = 0x41000000,
100 1.1 thorpej MPT_FUNC_HANDSHAKE = 0x42000000,
101 1.1 thorpej MPT_FUNC_REPLY_REMOVE = 0x43000000,
102 1.1 thorpej MPT_FUNC_MASK = 0xff000000
103 1.1 thorpej };
104 1.1 thorpej
105 1.1 thorpej /* Function Maps for INTERRUPT request register */
106 1.1 thorpej enum _MPT_INTR_REQ_BITS {
107 1.1 thorpej MPT_INTR_DB_BUSY = 0x80000000,
108 1.1 thorpej MPT_INTR_REPLY_READY = 0x00000008,
109 1.1 thorpej MPT_INTR_DB_READY = 0x00000001
110 1.1 thorpej };
111 1.1 thorpej
112 1.1 thorpej #define MPT_DB_IS_BUSY(v) (((v) & MPT_INTR_DB_BUSY) != 0)
113 1.1 thorpej #define MPT_DB_INTR(v) (((v) & MPT_INTR_DB_READY) != 0)
114 1.1 thorpej #define MPT_REPLY_INTR(v) (((v) & MPT_INTR_REPLY_READY) != 0)
115 1.1 thorpej
116 1.1 thorpej /* Function Maps for INTERRUPT make register */
117 1.1 thorpej enum _MPT_INTR_MASK_BITS {
118 1.1 thorpej MPT_INTR_REPLY_MASK = 0x00000008,
119 1.1 thorpej MPT_INTR_DB_MASK = 0x00000001
120 1.1 thorpej };
121 1.1 thorpej
122 1.1 thorpej /* Function Maps for DIAGNOSTIC make register */
123 1.1 thorpej enum _MPT_DIAG_BITS {
124 1.1 thorpej MPT_DIAG_ENABLED = 0x00000080,
125 1.1 thorpej MPT_DIAG_FLASHBAD = 0x00000040,
126 1.1 thorpej MPT_DIAG_RESET_HIST = 0x00000020,
127 1.1 thorpej MPT_DIAG_TTLI = 0x00000008,
128 1.1 thorpej MPT_DIAG_RESET_IOC = 0x00000004,
129 1.1 thorpej MPT_DIAG_ARM_DISABLE = 0x00000002,
130 1.1 thorpej MPT_DIAG_DME = 0x00000001
131 1.1 thorpej };
132 1.1 thorpej
133 1.1 thorpej /* Magic addresses in diagnostic memory space */
134 1.1 thorpej #define MPT_DIAG_IOP_BASE (0x00000000)
135 1.1 thorpej #define MPT_DIAG_IOP_SIZE (0x00002000)
136 1.1 thorpej #define MPT_DIAG_GPIO (0x00030010)
137 1.1 thorpej #define MPT_DIAG_IOPQ_REG_BASE0 (0x00050004)
138 1.1 thorpej #define MPT_DIAG_IOPQ_REG_BASE1 (0x00051004)
139 1.1 thorpej #define MPT_DIAG_MEM_CFG_BASE (0x00040000)
140 1.1 thorpej #define MPT_DIAG_CTX0_BASE (0x000E0000)
141 1.1 thorpej #define MPT_DIAG_CTX0_SIZE (0x00002000)
142 1.1 thorpej #define MPT_DIAG_CTX1_BASE (0x001E0000)
143 1.1 thorpej #define MPT_DIAG_CTX1_SIZE (0x00002000)
144 1.1 thorpej #define MPT_DIAG_FLASH_BASE (0x00800000)
145 1.1 thorpej #define MPT_DIAG_RAM_BASE (0x01000000)
146 1.1 thorpej #define MPT_DIAG_RAM_SIZE (0x00400000)
147 1.1 thorpej
148 1.1 thorpej /* GPIO bit assignments */
149 1.1 thorpej #define MPT_DIAG_GPIO_SCL (0x00010000)
150 1.1 thorpej #define MPT_DIAG_GPIO_SDA_OUT (0x00008000)
151 1.1 thorpej #define MPT_DIAG_GPIO_SDA_IN (0x00004000)
152 1.1 thorpej
153 1.1 thorpej #define MPT_REPLY_EMPTY (0xffffffff) /* Reply Queue Empty Symbol */
154 1.1 thorpej #define MPT_CONTEXT_REPLY (0x80000000)
155 1.1 thorpej #define MPT_CONTEXT_MASK (~0xE0000000)
156 1.1 thorpej
157 1.1 thorpej #ifdef _KERNEL
158 1.2 itojun int mpt_soft_reset(mpt_softc_t *);
159 1.2 itojun void mpt_hard_reset(mpt_softc_t *);
160 1.2 itojun int mpt_recv_handshake_reply(mpt_softc_t *, size_t, void *);
161 1.2 itojun
162 1.2 itojun void mpt_send_cmd(mpt_softc_t *, request_t *);
163 1.2 itojun void mpt_free_reply(mpt_softc_t *, u_int32_t);
164 1.2 itojun void mpt_enable_ints(mpt_softc_t *);
165 1.2 itojun void mpt_disable_ints(mpt_softc_t *);
166 1.2 itojun u_int32_t mpt_pop_reply_queue(mpt_softc_t *);
167 1.5.30.1 ad int mpt_hw_init(mpt_softc_t *);
168 1.2 itojun int mpt_init(mpt_softc_t *, u_int32_t);
169 1.2 itojun int mpt_reset(mpt_softc_t *);
170 1.2 itojun int mpt_send_handshake_cmd(mpt_softc_t *, size_t, void *);
171 1.2 itojun request_t * mpt_get_request(mpt_softc_t *);
172 1.2 itojun void mpt_free_request(mpt_softc_t *, request_t *);
173 1.2 itojun int mpt_intr(void *);
174 1.2 itojun void mpt_check_doorbell(mpt_softc_t *);
175 1.1 thorpej
176 1.1 thorpej int mpt_read_cfg_page(mpt_softc_t *, int, fCONFIG_PAGE_HEADER *);
177 1.1 thorpej int mpt_write_cfg_page(mpt_softc_t *, int, fCONFIG_PAGE_HEADER *);
178 1.1 thorpej
179 1.1 thorpej /* mpt_debug.c functions */
180 1.2 itojun void mpt_print_reply(void *);
181 1.2 itojun void mpt_print_db(u_int32_t);
182 1.2 itojun void mpt_print_config_reply(void *);
183 1.2 itojun char *mpt_ioc_diag(u_int32_t);
184 1.4 christos const char *mpt_req_state(enum mpt_req_state);
185 1.2 itojun void mpt_print_scsi_io_request(MSG_SCSI_IO_REQUEST *);
186 1.2 itojun void mpt_print_config_request(void *);
187 1.2 itojun void mpt_print_request(void *);
188 1.1 thorpej #endif /* _KERNEL */
189 1.1 thorpej
190 1.1 thorpej #endif /* _DEV_IC_MPT_H_ */
191