1 /* $FreeBSD: src/sys/dev/mpt/mpt.h,v 1.2.2.2 2002/09/01 23:08:06 mjacob Exp $ */
2 /* $DragonFly: src/sys/dev/disk/mpt/mpt.h,v 1.3 2003/08/07 21:16:53 dillon Exp $ */
4 * Generic defines for LSI '909 FC adapters.
7 * Copyright (c) 2000, 2001 by Greg Ansley
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice immediately at the beginning of the file, without modification,
14 * this list of conditions, and the following disclaimer.
15 * 2. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * Additional Copyright (c) 2002 by Matthew Jacob under same license.
36 #include "mpt_freebsd.h"
38 #define MPT_FAIL (0x10000)
40 /* Register Offset to chip registers */
41 #define MPT_OFFSET_DOORBELL 0x00
42 #define MPT_OFFSET_SEQUENCE 0x04
43 #define MPT_OFFSET_DIAGNOSTIC 0x08
44 #define MPT_OFFSET_TEST 0x0C
45 #define MPT_OFFSET_INTR_STATUS 0x30
46 #define MPT_OFFSET_INTR_MASK 0x34
47 #define MPT_OFFSET_REQUEST_Q 0x40
48 #define MPT_OFFSET_REPLY_Q 0x44
49 #define MPT_OFFSET_HOST_INDEX 0x50
50 #define MPT_OFFSET_FUBAR 0x90
52 #define MPT_DIAG_SEQUENCE_1 0x04
53 #define MPT_DIAG_SEQUENCE_2 0x0b
54 #define MPT_DIAG_SEQUENCE_3 0x02
55 #define MPT_DIAG_SEQUENCE_4 0x07
56 #define MPT_DIAG_SEQUENCE_5 0x0d
58 /* Bit Maps for DOORBELL register */
60 MPT_DB_STATE_RESET = 0x00000000,
61 MPT_DB_STATE_READY = 0x10000000,
62 MPT_DB_STATE_RUNNING = 0x20000000,
63 MPT_DB_STATE_FAULT = 0x40000000,
64 MPT_DB_STATE_MASK = 0xf0000000
67 #define MPT_STATE(v) ((enum DB_STATE_BITS)((v) & MPT_DB_STATE_MASK))
69 #define MPT_DB_LENGTH_SHIFT (16)
70 #define MPT_DB_DATA_MASK (0xffff)
72 #define MPT_DB_DB_USED 0x08000000
73 #define MPT_DB_IS_IN_USE(v) (((v) & MPT_DB_DB_USED) != 0)
76 * "Whom" initializor values
78 #define MPT_DB_INIT_NOONE 0x00
79 #define MPT_DB_INIT_BIOS 0x01
80 #define MPT_DB_INIT_ROMBIOS 0x02
81 #define MPT_DB_INIT_PCIPEER 0x03
82 #define MPT_DB_INIT_HOST 0x04
83 #define MPT_DB_INIT_MANUFACTURE 0x05
86 ((v & MPI_DOORBELL_WHO_INIT_MASK) >> MPI_DOORBELL_WHO_INIT_SHIFT)
88 /* Function Maps for DOORBELL register */
89 enum DB_FUNCTION_BITS {
90 MPT_FUNC_IOC_RESET = 0x40000000,
91 MPT_FUNC_UNIT_RESET = 0x41000000,
92 MPT_FUNC_HANDSHAKE = 0x42000000,
93 MPT_FUNC_REPLY_REMOVE = 0x43000000,
94 MPT_FUNC_MASK = 0xff000000
97 /* Function Maps for INTERRUPT request register */
98 enum _MPT_INTR_REQ_BITS {
99 MPT_INTR_DB_BUSY = 0x80000000,
100 MPT_INTR_REPLY_READY = 0x00000008,
101 MPT_INTR_DB_READY = 0x00000001
104 #define MPT_DB_IS_BUSY(v) (((v) & MPT_INTR_DB_BUSY) != 0)
105 #define MPT_DB_INTR(v) (((v) & MPT_INTR_DB_READY) != 0)
106 #define MPT_REPLY_INTR(v) (((v) & MPT_INTR_REPLY_READY) != 0)
108 /* Function Maps for INTERRUPT make register */
109 enum _MPT_INTR_MASK_BITS {
110 MPT_INTR_REPLY_MASK = 0x00000008,
111 MPT_INTR_DB_MASK = 0x00000001
114 /* Function Maps for DIAGNOSTIC make register */
115 enum _MPT_DIAG_BITS {
116 MPT_DIAG_ENABLED = 0x00000080,
117 MPT_DIAG_FLASHBAD = 0x00000040,
118 MPT_DIAG_RESET_HIST = 0x00000020,
119 MPT_DIAG_TTLI = 0x00000008,
120 MPT_DIAG_RESET_IOC = 0x00000004,
121 MPT_DIAG_ARM_DISABLE = 0x00000002,
122 MPT_DIAG_DME = 0x00000001
125 /* Magic addresses in diagnostic memory space */
126 #define MPT_DIAG_IOP_BASE (0x00000000)
127 #define MPT_DIAG_IOP_SIZE (0x00002000)
128 #define MPT_DIAG_GPIO (0x00030010)
129 #define MPT_DIAG_IOPQ_REG_BASE0 (0x00050004)
130 #define MPT_DIAG_IOPQ_REG_BASE1 (0x00051004)
131 #define MPT_DIAG_MEM_CFG_BASE (0x00040000)
132 #define MPT_DIAG_CTX0_BASE (0x000E0000)
133 #define MPT_DIAG_CTX0_SIZE (0x00002000)
134 #define MPT_DIAG_CTX1_BASE (0x001E0000)
135 #define MPT_DIAG_CTX1_SIZE (0x00002000)
136 #define MPT_DIAG_FLASH_BASE (0x00800000)
137 #define MPT_DIAG_RAM_BASE (0x01000000)
138 #define MPT_DIAG_RAM_SIZE (0x00400000)
140 /* GPIO bit assignments */
141 #define MPT_DIAG_GPIO_SCL (0x00010000)
142 #define MPT_DIAG_GPIO_SDA_OUT (0x00008000)
143 #define MPT_DIAG_GPIO_SDA_IN (0x00004000)
145 #define MPT_REPLY_EMPTY (0xffffffff) /* Reply Queue Empty Symbol */
146 #define MPT_CONTEXT_REPLY (0x80000000)
147 #define MPT_CONTEXT_MASK (~0xE0000000)
150 int mpt_soft_reset(mpt_softc_t *mpt);
151 void mpt_hard_reset(mpt_softc_t *mpt);
152 int mpt_recv_handshake_reply(mpt_softc_t *mpt, size_t reply_len, void *reply);
154 void mpt_send_cmd(mpt_softc_t *mpt, request_t *req);
155 void mpt_free_reply(mpt_softc_t *mpt, u_int32_t ptr);
156 void mpt_enable_ints(mpt_softc_t *mpt);
157 void mpt_disable_ints(mpt_softc_t *mpt);
158 u_int32_t mpt_pop_reply_queue(mpt_softc_t *mpt);
159 int mpt_init(mpt_softc_t *mpt, u_int32_t who);
160 int mpt_reset(mpt_softc_t *mpt);
161 int mpt_send_handshake_cmd(mpt_softc_t *mpt, size_t len, void *cmd);
162 request_t * mpt_get_request(mpt_softc_t *mpt);
163 void mpt_free_request(mpt_softc_t *mpt, request_t *req);
164 int mpt_intr(void *dummy);
165 void mpt_check_doorbell(mpt_softc_t * mpt);
167 int mpt_read_cfg_page(mpt_softc_t *, int, fCONFIG_PAGE_HEADER *);
168 int mpt_write_cfg_page(mpt_softc_t *, int, fCONFIG_PAGE_HEADER *);
170 /* mpt_debug.c functions */
171 void mpt_print_reply(void *vmsg);
172 void mpt_print_db(u_int32_t mb);
173 void mpt_print_config_reply(void *vmsg);
174 char *mpt_ioc_diag(u_int32_t diag);
175 char *mpt_req_state(enum mpt_req_state state);
176 void mpt_print_scsi_io_request(MSG_SCSI_IO_REQUEST *msg);
177 void mpt_print_config_request(void *vmsg);
178 void mpt_print_request(void *vmsg);