xref: /freebsd/sys/dev/mpt/mpt_reg.h (revision 39beb93c3f8bdbf72a61fda42300b5ebed7390c8)
1 /* $FreeBSD$ */
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  * Copyright (c) 2002, 2006 by Matthew Jacob
31  * All rights reserved.
32  *
33  * Redistribution and use in source and binary forms, with or without
34  * modification, are permitted provided that the following conditions are
35  * met:
36  * 1. Redistributions of source code must retain the above copyright
37  *    notice, this list of conditions and the following disclaimer.
38  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
39  *    substantially similar to the "NO WARRANTY" disclaimer below
40  *    ("Disclaimer") and any redistribution must be conditioned upon including
41  *    a substantially similar Disclaimer requirement for further binary
42  *    redistribution.
43  * 3. Neither the names of the above listed copyright holders nor the names
44  *    of any contributors may be used to endorse or promote products derived
45  *    from this software without specific prior written permission.
46  *
47  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
51  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
52  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
53  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
54  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
55  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
56  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
57  * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58  *
59  * Support from Chris Ellsworth in order to make SAS adapters work
60  * is gratefully acknowledged.
61  *
62  * Support from LSI-Logic has also gone a great deal toward making this a
63  * workable subsystem and is gratefully acknowledged.
64  */
65 #ifndef _MPT_REG_H_
66 #define	_MPT_REG_H_
67 
68 #define	MPT_OFFSET_DOORBELL	0x00
69 #define	MPT_OFFSET_SEQUENCE	0x04
70 #define	MPT_OFFSET_DIAGNOSTIC	0x08
71 #define	MPT_OFFSET_TEST		0x0C
72 #define	MPT_OFFSET_DIAG_DATA	0x10
73 #define	MPT_OFFSET_DIAG_ADDR	0x14
74 #define	MPT_OFFSET_INTR_STATUS	0x30
75 #define	MPT_OFFSET_INTR_MASK	0x34
76 #define	MPT_OFFSET_REQUEST_Q	0x40
77 #define	MPT_OFFSET_REPLY_Q	0x44
78 #define	MPT_OFFSET_HOST_INDEX	0x50
79 #define	MPT_OFFSET_FUBAR	0x90
80 
81 /* Bit Maps for DOORBELL register */
82 enum DB_STATE_BITS {
83 	MPT_DB_STATE_RESET	= 0x00000000,
84 	MPT_DB_STATE_READY	= 0x10000000,
85 	MPT_DB_STATE_RUNNING	= 0x20000000,
86 	MPT_DB_STATE_FAULT	= 0x40000000,
87 	MPT_DB_STATE_MASK	= 0xf0000000
88 };
89 
90 #define	MPT_STATE(v) ((enum DB_STATE_BITS)((v) & MPT_DB_STATE_MASK))
91 
92 #define	MPT_DB_LENGTH_SHIFT	(16)
93 #define	MPT_DB_DATA_MASK	(0xffff)
94 
95 #define	MPT_DB_DB_USED		0x08000000
96 #define	MPT_DB_IS_IN_USE(v) (((v) & MPT_DB_DB_USED) != 0)
97 
98 /*
99  * "Whom" initializor values
100  */
101 #define	MPT_DB_INIT_NOONE	0x00
102 #define	MPT_DB_INIT_BIOS	0x01
103 #define	MPT_DB_INIT_ROMBIOS	0x02
104 #define	MPT_DB_INIT_PCIPEER	0x03
105 #define	MPT_DB_INIT_HOST	0x04
106 #define	MPT_DB_INIT_MANUFACTURE	0x05
107 
108 #define	MPT_WHO(v)	\
109 	((v & MPI_DOORBELL_WHO_INIT_MASK) >> MPI_DOORBELL_WHO_INIT_SHIFT)
110 
111 /* Function Maps for DOORBELL register */
112 enum DB_FUNCTION_BITS {
113 	MPT_FUNC_IOC_RESET	= 0x40000000,
114 	MPT_FUNC_UNIT_RESET	= 0x41000000,
115 	MPT_FUNC_HANDSHAKE	= 0x42000000,
116 	MPT_FUNC_REPLY_REMOVE	= 0x43000000,
117 	MPT_FUNC_MASK		= 0xff000000
118 };
119 
120 /* Function Maps for INTERRUPT request register */
121 enum _MPT_INTR_REQ_BITS {
122 	MPT_INTR_DB_BUSY	= 0x80000000,
123 	MPT_INTR_REPLY_READY	= 0x00000008,
124 	MPT_INTR_DB_READY	= 0x00000001
125 };
126 
127 #define	MPT_DB_IS_BUSY(v) (((v) & MPT_INTR_DB_BUSY) != 0)
128 #define	MPT_DB_INTR(v)    (((v) & MPT_INTR_DB_READY) != 0)
129 #define	MPT_REPLY_INTR(v) (((v) & MPT_INTR_REPLY_READY) != 0)
130 
131 /* Function Maps for INTERRUPT mask register */
132 enum _MPT_INTR_MASK_BITS {
133 	MPT_INTR_REPLY_MASK	= 0x00000008,
134 	MPT_INTR_DB_MASK	= 0x00000001
135 };
136 
137 /* Magic addresses in diagnostic memory space */
138 #define	MPT_DIAG_IOP_BASE		(0x00000000)
139 #define		MPT_DIAG_IOP_SIZE	(0x00002000)
140 #define	MPT_DIAG_GPIO			(0x00030010)
141 #define	MPT_DIAG_IOPQ_REG_BASE0		(0x00050004)
142 #define	MPT_DIAG_IOPQ_REG_BASE1		(0x00051004)
143 #define	MPT_DIAG_CTX0_BASE		(0x000E0000)
144 #define		MPT_DIAG_CTX0_SIZE	(0x00002000)
145 #define	MPT_DIAG_CTX1_BASE		(0x001E0000)
146 #define		MPT_DIAG_CTX1_SIZE	(0x00002000)
147 #define	MPT_DIAG_FLASH_BASE		(0x00800000)
148 #define	MPT_DIAG_RAM_BASE		(0x01000000)
149 #define		MPT_DIAG_RAM_SIZE	(0x00400000)
150 #define	MPT_DIAG_MEM_CFG_BASE		(0x3F000000)
151 #define		MPT_DIAG_MEM_CFG_BADFL	(0x04000000)
152 
153 /* GPIO bit assignments */
154 #define	MPT_DIAG_GPIO_SCL	(0x00010000)
155 #define	MPT_DIAG_GPIO_SDA_OUT	(0x00008000)
156 #define	MPT_DIAG_GPIO_SDA_IN	(0x00004000)
157 
158 #define	MPT_REPLY_EMPTY (0xFFFFFFFF)	/* Reply Queue Empty Symbol */
159 #endif /* _MPT_REG_H_ */
160