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