xref: /netbsd-src/sys/dev/mscp/mscpreg.h (revision 95e1ffb15694e54f29f8baaa4232152b703c2a5a)
1*95e1ffb1Schristos /*	$NetBSD: mscpreg.h,v 1.7 2005/12/11 12:22:47 christos Exp $	*/
214ef5695Sragge /*
314ef5695Sragge  * Copyright (c) 1988 Regents of the University of California.
414ef5695Sragge  * All rights reserved.
514ef5695Sragge  *
614ef5695Sragge  * This code is derived from software contributed to Berkeley by
714ef5695Sragge  * Chris Torek.
814ef5695Sragge  *
914ef5695Sragge  * Redistribution and use in source and binary forms, with or without
1014ef5695Sragge  * modification, are permitted provided that the following conditions
1114ef5695Sragge  * are met:
1214ef5695Sragge  * 1. Redistributions of source code must retain the above copyright
1314ef5695Sragge  *    notice, this list of conditions and the following disclaimer.
1414ef5695Sragge  * 2. Redistributions in binary form must reproduce the above copyright
1514ef5695Sragge  *    notice, this list of conditions and the following disclaimer in the
1614ef5695Sragge  *    documentation and/or other materials provided with the distribution.
17aad01611Sagc  * 3. Neither the name of the University nor the names of its contributors
18aad01611Sagc  *    may be used to endorse or promote products derived from this software
19aad01611Sagc  *    without specific prior written permission.
20aad01611Sagc  *
21aad01611Sagc  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22aad01611Sagc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23aad01611Sagc  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24aad01611Sagc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25aad01611Sagc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26aad01611Sagc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27aad01611Sagc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28aad01611Sagc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29aad01611Sagc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30aad01611Sagc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31aad01611Sagc  * SUCH DAMAGE.
32aad01611Sagc  *
33aad01611Sagc  *	@(#)udareg.h	7.3 (Berkeley) 5/8/91
34aad01611Sagc  */
35aad01611Sagc 
36aad01611Sagc /*
37aad01611Sagc  * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
38aad01611Sagc  *
39aad01611Sagc  * This code is derived from software contributed to Berkeley by
40aad01611Sagc  * Chris Torek.
41aad01611Sagc  *
42aad01611Sagc  * Redistribution and use in source and binary forms, with or without
43aad01611Sagc  * modification, are permitted provided that the following conditions
44aad01611Sagc  * are met:
45aad01611Sagc  * 1. Redistributions of source code must retain the above copyright
46aad01611Sagc  *    notice, this list of conditions and the following disclaimer.
47aad01611Sagc  * 2. Redistributions in binary form must reproduce the above copyright
48aad01611Sagc  *    notice, this list of conditions and the following disclaimer in the
49aad01611Sagc  *    documentation and/or other materials provided with the distribution.
5014ef5695Sragge  * 3. All advertising materials mentioning features or use of this software
5114ef5695Sragge  *    must display the following acknowledgement:
5214ef5695Sragge  *	This product includes software developed by the University of
5314ef5695Sragge  *	California, Berkeley and its contributors.
5414ef5695Sragge  * 4. Neither the name of the University nor the names of its contributors
5514ef5695Sragge  *    may be used to endorse or promote products derived from this software
5614ef5695Sragge  *    without specific prior written permission.
5714ef5695Sragge  *
5814ef5695Sragge  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
5914ef5695Sragge  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
6014ef5695Sragge  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
6114ef5695Sragge  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
6214ef5695Sragge  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6314ef5695Sragge  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
6414ef5695Sragge  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
6514ef5695Sragge  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
6614ef5695Sragge  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6714ef5695Sragge  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6814ef5695Sragge  * SUCH DAMAGE.
6914ef5695Sragge  *
7014ef5695Sragge  *	@(#)udareg.h	7.3 (Berkeley) 5/8/91
7114ef5695Sragge  */
7214ef5695Sragge 
7314ef5695Sragge /*
7414ef5695Sragge  * NRSPL2 and NCMDL2 control the number of response and command
7514ef5695Sragge  * packets respectively.  They may be any value from 0 to 7, though
7614ef5695Sragge  * setting them higher than 5 is unlikely to be of any value.
7714ef5695Sragge  * If you get warnings about your command ring being too small,
7814ef5695Sragge  * try increasing the values by one.
7914ef5695Sragge  */
8014ef5695Sragge #ifndef NRSP
8114ef5695Sragge #define NRSPL2	5
8214ef5695Sragge #define NCMDL2	5
8314ef5695Sragge #define NRSP	(1 << NRSPL2)
8414ef5695Sragge #define NCMD	(1 << NCMDL2)
8514ef5695Sragge #endif
8614ef5695Sragge 
8714ef5695Sragge /*
8814ef5695Sragge  * Communication area definition. This seems to be the same for
8914ef5695Sragge  * all types of MSCP controllers.
9014ef5695Sragge  */
9114ef5695Sragge 
9214ef5695Sragge struct mscp_ca {
9314ef5695Sragge 	short	ca_xxx1;	/* unused */
9414ef5695Sragge 	char	ca_xxx2;	/* unused */
9514ef5695Sragge 	char	ca_bdp;		/* BDP to purge */
9614ef5695Sragge 	short	ca_cmdint;	/* command ring transition flag */
9714ef5695Sragge 	short	ca_rspint;	/* response ring transition flag */
9814ef5695Sragge 	long	ca_rspdsc[NRSP];/* response descriptors */
9914ef5695Sragge 	long	ca_cmddsc[NCMD];/* command descriptors */
10014ef5695Sragge };
10114ef5695Sragge 
10214ef5695Sragge /*
10314ef5695Sragge  * Simplified routines (e.g., uddump) reprogram the UDA50 for one command
10414ef5695Sragge  * and one response at a time; uda1ca is like udaca except that it provides
10514ef5695Sragge  * exactly one command and response descriptor.
10614ef5695Sragge  */
10714ef5695Sragge struct mscp_1ca {
10814ef5695Sragge 	short	ca_xxx1;
10914ef5695Sragge 	char	ca_xxx2;
11014ef5695Sragge 	char	ca_bdp;
11114ef5695Sragge 	short	ca_cmdint;
11214ef5695Sragge 	short	ca_rspint;
11314ef5695Sragge 	long	ca_rspdsc;
11414ef5695Sragge 	long	ca_cmddsc;
11514ef5695Sragge };
11614ef5695Sragge 
11714ef5695Sragge /*
11814ef5695Sragge  * Combined communications area and MSCP packet pools, per controller.
11914ef5695Sragge  * NRSP and NCMD must be defined before this struct is used.
12014ef5695Sragge  */
12114ef5695Sragge 
12214ef5695Sragge struct	mscp_pack {
12314ef5695Sragge 	struct	mscp_ca mp_ca;		/* communications area */
12414ef5695Sragge 	struct	mscp mp_rsp[NRSP];	/* response packets */
12514ef5695Sragge 	struct	mscp mp_cmd[NCMD];	/* command packets */
12614ef5695Sragge };
12714ef5695Sragge 
12814ef5695Sragge /*
12914ef5695Sragge  * Bits in UDA status register during initialisation
13014ef5695Sragge  */
13114ef5695Sragge #define MP_ERR		0x8000	/* error */
13214ef5695Sragge #define MP_STEP4	0x4000	/* step 4 has started */
13314ef5695Sragge #define MP_STEP3	0x2000	/* step 3 has started */
13414ef5695Sragge #define MP_STEP2	0x1000	/* step 2 has started */
13514ef5695Sragge #define MP_STEP1	0x0800	/* step 1 has started */
13614ef5695Sragge #define MP_NV		0x0400	/* no host settable interrupt vector */
13714ef5695Sragge #define MP_QB		0x0200	/* controller supports Q22 bus */
13814ef5695Sragge #define MP_DI		0x0100	/* controller implements diagnostics */
13914ef5695Sragge #define MP_IE		0x0080	/* interrupt enable */
14014ef5695Sragge #define MP_NCNRMASK	0x003f	/* in STEP1, bits 0-2=NCMDL2, 3-5=NRSPL2 */
14114ef5695Sragge #define MP_IVECMASK	0x007f	/* in STEP2, bits 0-6 are interruptvec / 4 */
14214ef5695Sragge #define MP_PI		0x0001	/* host requests adapter purge interrupts */
14314ef5695Sragge #define MP_GO		0x0001	/* Go command to ctlr */
14414ef5695Sragge 
14514ef5695Sragge #define ALLSTEPS	(MP_ERR | MP_STEP4 | MP_STEP3 | MP_STEP2 | MP_STEP1)
14614ef5695Sragge 
14714ef5695Sragge #define STEP0MASK	(ALLSTEPS | MP_NV)
14814ef5695Sragge 
14914ef5695Sragge #define STEP1MASK	(ALLSTEPS | MP_IE | MP_NCNRMASK)
15014ef5695Sragge #define STEP1GOOD	(MP_STEP2 | MP_IE | (NCMDL2 << 3) | NRSPL2)
15114ef5695Sragge 
15214ef5695Sragge #define STEP2MASK	(ALLSTEPS | MP_IE | MP_IVECMASK)
15314ef5695Sragge #define STEP2GOOD(iv)	(MP_STEP3 | MP_IE | (iv))
15414ef5695Sragge 
15514ef5695Sragge #define STEP3MASK	ALLSTEPS
15614ef5695Sragge #define STEP3GOOD	MP_STEP4
15714ef5695Sragge 
158