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