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