xref: /dflybsd-src/sys/dev/disk/mpt/mpt_reg.h (revision f582582c11f73cef1733317743aa98045853bc3f)
1*f582582cSSascha Wildner /* $FreeBSD: head/sys/dev/mpt/mpt_reg.h 231518 2012-02-11 12:03:44Z marius $ */
22545bca0SMatthew Dillon /*-
32545bca0SMatthew Dillon  * Generic defines for LSI '909 FC  adapters.
42545bca0SMatthew Dillon  * FreeBSD Version.
52545bca0SMatthew Dillon  *
62545bca0SMatthew Dillon  * Copyright (c)  2000, 2001 by Greg Ansley
72545bca0SMatthew Dillon  *
82545bca0SMatthew Dillon  * Redistribution and use in source and binary forms, with or without
92545bca0SMatthew Dillon  * modification, are permitted provided that the following conditions
102545bca0SMatthew Dillon  * are met:
112545bca0SMatthew Dillon  * 1. Redistributions of source code must retain the above copyright
122545bca0SMatthew Dillon  *    notice immediately at the beginning of the file, without modification,
132545bca0SMatthew Dillon  *    this list of conditions, and the following disclaimer.
142545bca0SMatthew Dillon  * 2. The name of the author may not be used to endorse or promote products
152545bca0SMatthew Dillon  *    derived from this software without specific prior written permission.
162545bca0SMatthew Dillon  *
172545bca0SMatthew Dillon  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
182545bca0SMatthew Dillon  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
192545bca0SMatthew Dillon  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
202545bca0SMatthew Dillon  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
212545bca0SMatthew Dillon  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
222545bca0SMatthew Dillon  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
232545bca0SMatthew Dillon  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
242545bca0SMatthew Dillon  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
252545bca0SMatthew Dillon  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
262545bca0SMatthew Dillon  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
272545bca0SMatthew Dillon  * SUCH DAMAGE.
282545bca0SMatthew Dillon  */
292545bca0SMatthew Dillon /*-
302545bca0SMatthew Dillon  * Copyright (c) 2002, 2006 by Matthew Jacob
312545bca0SMatthew Dillon  * All rights reserved.
322545bca0SMatthew Dillon  *
332545bca0SMatthew Dillon  * Redistribution and use in source and binary forms, with or without
342545bca0SMatthew Dillon  * modification, are permitted provided that the following conditions are
352545bca0SMatthew Dillon  * met:
362545bca0SMatthew Dillon  * 1. Redistributions of source code must retain the above copyright
372545bca0SMatthew Dillon  *    notice, this list of conditions and the following disclaimer.
382545bca0SMatthew Dillon  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
392545bca0SMatthew Dillon  *    substantially similar to the "NO WARRANTY" disclaimer below
402545bca0SMatthew Dillon  *    ("Disclaimer") and any redistribution must be conditioned upon including
412545bca0SMatthew Dillon  *    a substantially similar Disclaimer requirement for further binary
422545bca0SMatthew Dillon  *    redistribution.
432545bca0SMatthew Dillon  * 3. Neither the names of the above listed copyright holders nor the names
442545bca0SMatthew Dillon  *    of any contributors may be used to endorse or promote products derived
452545bca0SMatthew Dillon  *    from this software without specific prior written permission.
462545bca0SMatthew Dillon  *
472545bca0SMatthew Dillon  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
482545bca0SMatthew Dillon  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
492545bca0SMatthew Dillon  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
502545bca0SMatthew Dillon  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
512545bca0SMatthew Dillon  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
522545bca0SMatthew Dillon  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
532545bca0SMatthew Dillon  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
542545bca0SMatthew Dillon  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
552545bca0SMatthew Dillon  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
562545bca0SMatthew Dillon  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
572545bca0SMatthew Dillon  * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
582545bca0SMatthew Dillon  *
592545bca0SMatthew Dillon  * Support from Chris Ellsworth in order to make SAS adapters work
602545bca0SMatthew Dillon  * is gratefully acknowledged.
612545bca0SMatthew Dillon  *
622545bca0SMatthew Dillon  * Support from LSI-Logic has also gone a great deal toward making this a
632545bca0SMatthew Dillon  * workable subsystem and is gratefully acknowledged.
642545bca0SMatthew Dillon  */
652545bca0SMatthew Dillon #ifndef _MPT_REG_H_
662545bca0SMatthew Dillon #define	_MPT_REG_H_
672545bca0SMatthew Dillon 
682545bca0SMatthew Dillon #define	MPT_OFFSET_DOORBELL	0x00
692545bca0SMatthew Dillon #define	MPT_OFFSET_SEQUENCE	0x04
702545bca0SMatthew Dillon #define	MPT_OFFSET_DIAGNOSTIC	0x08
712545bca0SMatthew Dillon #define	MPT_OFFSET_TEST		0x0C
722545bca0SMatthew Dillon #define	MPT_OFFSET_DIAG_DATA	0x10
732545bca0SMatthew Dillon #define	MPT_OFFSET_DIAG_ADDR	0x14
742545bca0SMatthew Dillon #define	MPT_OFFSET_INTR_STATUS	0x30
752545bca0SMatthew Dillon #define	MPT_OFFSET_INTR_MASK	0x34
762545bca0SMatthew Dillon #define	MPT_OFFSET_REQUEST_Q	0x40
772545bca0SMatthew Dillon #define	MPT_OFFSET_REPLY_Q	0x44
782545bca0SMatthew Dillon #define	MPT_OFFSET_HOST_INDEX	0x50
792545bca0SMatthew Dillon #define	MPT_OFFSET_FUBAR	0x90
804c42baf4SSascha Wildner #define	MPT_OFFSET_RESET_1078	0x10fc
812545bca0SMatthew Dillon 
822545bca0SMatthew Dillon /* Bit Maps for DOORBELL register */
832545bca0SMatthew Dillon enum DB_STATE_BITS {
842545bca0SMatthew Dillon 	MPT_DB_STATE_RESET	= 0x00000000,
852545bca0SMatthew Dillon 	MPT_DB_STATE_READY	= 0x10000000,
862545bca0SMatthew Dillon 	MPT_DB_STATE_RUNNING	= 0x20000000,
872545bca0SMatthew Dillon 	MPT_DB_STATE_FAULT	= 0x40000000,
882545bca0SMatthew Dillon 	MPT_DB_STATE_MASK	= 0xf0000000
892545bca0SMatthew Dillon };
902545bca0SMatthew Dillon 
912545bca0SMatthew Dillon #define	MPT_STATE(v) ((enum DB_STATE_BITS)((v) & MPT_DB_STATE_MASK))
922545bca0SMatthew Dillon 
932545bca0SMatthew Dillon #define	MPT_DB_LENGTH_SHIFT	(16)
942545bca0SMatthew Dillon #define	MPT_DB_DATA_MASK	(0xffff)
952545bca0SMatthew Dillon 
962545bca0SMatthew Dillon #define	MPT_DB_DB_USED		0x08000000
972545bca0SMatthew Dillon #define	MPT_DB_IS_IN_USE(v) (((v) & MPT_DB_DB_USED) != 0)
982545bca0SMatthew Dillon 
992545bca0SMatthew Dillon /*
1002545bca0SMatthew Dillon  * "Whom" initializor values
1012545bca0SMatthew Dillon  */
1022545bca0SMatthew Dillon #define	MPT_DB_INIT_NOONE	0x00
1032545bca0SMatthew Dillon #define	MPT_DB_INIT_BIOS	0x01
1042545bca0SMatthew Dillon #define	MPT_DB_INIT_ROMBIOS	0x02
1052545bca0SMatthew Dillon #define	MPT_DB_INIT_PCIPEER	0x03
1062545bca0SMatthew Dillon #define	MPT_DB_INIT_HOST	0x04
1072545bca0SMatthew Dillon #define	MPT_DB_INIT_MANUFACTURE	0x05
1082545bca0SMatthew Dillon 
1092545bca0SMatthew Dillon #define	MPT_WHO(v)	\
1102545bca0SMatthew Dillon 	((v & MPI_DOORBELL_WHO_INIT_MASK) >> MPI_DOORBELL_WHO_INIT_SHIFT)
1112545bca0SMatthew Dillon 
1122545bca0SMatthew Dillon /* Function Maps for DOORBELL register */
1132545bca0SMatthew Dillon enum DB_FUNCTION_BITS {
1142545bca0SMatthew Dillon 	MPT_FUNC_IOC_RESET	= 0x40000000,
1152545bca0SMatthew Dillon 	MPT_FUNC_UNIT_RESET	= 0x41000000,
1162545bca0SMatthew Dillon 	MPT_FUNC_HANDSHAKE	= 0x42000000,
1172545bca0SMatthew Dillon 	MPT_FUNC_REPLY_REMOVE	= 0x43000000,
1182545bca0SMatthew Dillon 	MPT_FUNC_MASK		= 0xff000000
1192545bca0SMatthew Dillon };
1202545bca0SMatthew Dillon 
1212545bca0SMatthew Dillon /* Function Maps for INTERRUPT request register */
1222545bca0SMatthew Dillon enum _MPT_INTR_REQ_BITS {
1232545bca0SMatthew Dillon 	MPT_INTR_DB_BUSY	= 0x80000000,
1242545bca0SMatthew Dillon 	MPT_INTR_REPLY_READY	= 0x00000008,
1252545bca0SMatthew Dillon 	MPT_INTR_DB_READY	= 0x00000001
1262545bca0SMatthew Dillon };
1272545bca0SMatthew Dillon 
1282545bca0SMatthew Dillon #define	MPT_DB_IS_BUSY(v) (((v) & MPT_INTR_DB_BUSY) != 0)
1292545bca0SMatthew Dillon #define	MPT_DB_INTR(v)    (((v) & MPT_INTR_DB_READY) != 0)
1302545bca0SMatthew Dillon #define	MPT_REPLY_INTR(v) (((v) & MPT_INTR_REPLY_READY) != 0)
1312545bca0SMatthew Dillon 
1322545bca0SMatthew Dillon /* Function Maps for INTERRUPT mask register */
1332545bca0SMatthew Dillon enum _MPT_INTR_MASK_BITS {
1342545bca0SMatthew Dillon 	MPT_INTR_REPLY_MASK	= 0x00000008,
1352545bca0SMatthew Dillon 	MPT_INTR_DB_MASK	= 0x00000001
1362545bca0SMatthew Dillon };
1372545bca0SMatthew Dillon 
1382545bca0SMatthew Dillon /* Magic addresses in diagnostic memory space */
1392545bca0SMatthew Dillon #define	MPT_DIAG_IOP_BASE		(0x00000000)
1402545bca0SMatthew Dillon #define		MPT_DIAG_IOP_SIZE	(0x00002000)
1412545bca0SMatthew Dillon #define	MPT_DIAG_GPIO			(0x00030010)
1422545bca0SMatthew Dillon #define	MPT_DIAG_IOPQ_REG_BASE0		(0x00050004)
1432545bca0SMatthew Dillon #define	MPT_DIAG_IOPQ_REG_BASE1		(0x00051004)
1442545bca0SMatthew Dillon #define	MPT_DIAG_CTX0_BASE		(0x000E0000)
1452545bca0SMatthew Dillon #define		MPT_DIAG_CTX0_SIZE	(0x00002000)
1462545bca0SMatthew Dillon #define	MPT_DIAG_CTX1_BASE		(0x001E0000)
1472545bca0SMatthew Dillon #define		MPT_DIAG_CTX1_SIZE	(0x00002000)
1482545bca0SMatthew Dillon #define	MPT_DIAG_FLASH_BASE		(0x00800000)
1492545bca0SMatthew Dillon #define	MPT_DIAG_RAM_BASE		(0x01000000)
1502545bca0SMatthew Dillon #define		MPT_DIAG_RAM_SIZE	(0x00400000)
1512545bca0SMatthew Dillon #define	MPT_DIAG_MEM_CFG_BASE		(0x3F000000)
1522545bca0SMatthew Dillon #define		MPT_DIAG_MEM_CFG_BADFL	(0x04000000)
1532545bca0SMatthew Dillon 
1542545bca0SMatthew Dillon /* GPIO bit assignments */
1552545bca0SMatthew Dillon #define	MPT_DIAG_GPIO_SCL	(0x00010000)
1562545bca0SMatthew Dillon #define	MPT_DIAG_GPIO_SDA_OUT	(0x00008000)
1572545bca0SMatthew Dillon #define	MPT_DIAG_GPIO_SDA_IN	(0x00004000)
1582545bca0SMatthew Dillon 
1592545bca0SMatthew Dillon #define	MPT_REPLY_EMPTY (0xFFFFFFFF)	/* Reply Queue Empty Symbol */
1602545bca0SMatthew Dillon #endif /* _MPT_REG_H_ */
161