mpt_reg.h revision 156000
1/* $FreeBSD: head/sys/dev/mpt/mpt_reg.h 156000 2006-02-25 07:45:54Z mjacob $ */
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#ifndef _MPT_REG_H_
63#define	_MPT_REG_H_
64
65#define	MPT_OFFSET_DOORBELL	0x00
66#define	MPT_OFFSET_SEQUENCE	0x04
67#define	MPT_OFFSET_DIAGNOSTIC	0x08
68#define	MPT_OFFSET_TEST		0x0C
69#define	MPT_OFFSET_DIAG_DATA	0x10
70#define	MPT_OFFSET_DIAG_ADDR	0x14
71#define	MPT_OFFSET_INTR_STATUS	0x30
72#define	MPT_OFFSET_INTR_MASK	0x34
73#define	MPT_OFFSET_REQUEST_Q	0x40
74#define	MPT_OFFSET_REPLY_Q	0x44
75#define	MPT_OFFSET_HOST_INDEX	0x50
76#define	MPT_OFFSET_FUBAR	0x90
77
78/* Bit Maps for DOORBELL register */
79enum DB_STATE_BITS {
80	MPT_DB_STATE_RESET	= 0x00000000,
81	MPT_DB_STATE_READY	= 0x10000000,
82	MPT_DB_STATE_RUNNING	= 0x20000000,
83	MPT_DB_STATE_FAULT	= 0x40000000,
84	MPT_DB_STATE_MASK	= 0xf0000000
85};
86
87#define	MPT_STATE(v) ((enum DB_STATE_BITS)((v) & MPT_DB_STATE_MASK))
88
89#define	MPT_DB_LENGTH_SHIFT	(16)
90#define	MPT_DB_DATA_MASK	(0xffff)
91
92#define	MPT_DB_DB_USED		0x08000000
93#define	MPT_DB_IS_IN_USE(v) (((v) & MPT_DB_DB_USED) != 0)
94
95/*
96 * "Whom" initializor values
97 */
98#define	MPT_DB_INIT_NOONE	0x00
99#define	MPT_DB_INIT_BIOS	0x01
100#define	MPT_DB_INIT_ROMBIOS	0x02
101#define	MPT_DB_INIT_PCIPEER	0x03
102#define	MPT_DB_INIT_HOST	0x04
103#define	MPT_DB_INIT_MANUFACTURE	0x05
104
105#define	MPT_WHO(v)	\
106	((v & MPI_DOORBELL_WHO_INIT_MASK) >> MPI_DOORBELL_WHO_INIT_SHIFT)
107
108/* Function Maps for DOORBELL register */
109enum DB_FUNCTION_BITS {
110	MPT_FUNC_IOC_RESET	= 0x40000000,
111	MPT_FUNC_UNIT_RESET	= 0x41000000,
112	MPT_FUNC_HANDSHAKE	= 0x42000000,
113	MPT_FUNC_REPLY_REMOVE	= 0x43000000,
114	MPT_FUNC_MASK		= 0xff000000
115};
116
117/* Function Maps for INTERRUPT request register */
118enum _MPT_INTR_REQ_BITS {
119	MPT_INTR_DB_BUSY	= 0x80000000,
120	MPT_INTR_REPLY_READY	= 0x00000008,
121	MPT_INTR_DB_READY	= 0x00000001
122};
123
124#define	MPT_DB_IS_BUSY(v) (((v) & MPT_INTR_DB_BUSY) != 0)
125#define	MPT_DB_INTR(v)    (((v) & MPT_INTR_DB_READY) != 0)
126#define	MPT_REPLY_INTR(v) (((v) & MPT_INTR_REPLY_READY) != 0)
127
128/* Function Maps for INTERRUPT make register */
129enum _MPT_INTR_MASK_BITS {
130	MPT_INTR_REPLY_MASK	= 0x00000008,
131	MPT_INTR_DB_MASK	= 0x00000001
132};
133
134/* Magic addresses in diagnostic memory space */
135#define	MPT_DIAG_IOP_BASE		(0x00000000)
136#define		MPT_DIAG_IOP_SIZE	(0x00002000)
137#define	MPT_DIAG_GPIO			(0x00030010)
138#define	MPT_DIAG_IOPQ_REG_BASE0		(0x00050004)
139#define	MPT_DIAG_IOPQ_REG_BASE1		(0x00051004)
140#define	MPT_DIAG_CTX0_BASE		(0x000E0000)
141#define		MPT_DIAG_CTX0_SIZE	(0x00002000)
142#define	MPT_DIAG_CTX1_BASE		(0x001E0000)
143#define		MPT_DIAG_CTX1_SIZE	(0x00002000)
144#define	MPT_DIAG_FLASH_BASE		(0x00800000)
145#define	MPT_DIAG_RAM_BASE		(0x01000000)
146#define		MPT_DIAG_RAM_SIZE	(0x00400000)
147#define	MPT_DIAG_MEM_CFG_BASE		(0x3F000000)
148#define		MPT_DIAG_MEM_CFG_BADFL	(0x04000000)
149
150/* GPIO bit assignments */
151#define	MPT_DIAG_GPIO_SCL	(0x00010000)
152#define	MPT_DIAG_GPIO_SDA_OUT	(0x00008000)
153#define	MPT_DIAG_GPIO_SDA_IN	(0x00004000)
154
155#define	MPT_REPLY_EMPTY (0xFFFFFFFF)	/* Reply Queue Empty Symbol */
156#endif /* _MPT_REG_H_ */
157