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