xref: /freebsd-12.1/sys/dev/nsp/nspreg.h (revision 718cf2cc)
1 /*	$FreeBSD$	*/
2 /*	$NecBSD: nspreg.h,v 1.4.14.3 2001/06/29 06:27:53 honda Exp $	*/
3 /*	$NetBSD$	*/
4 
5 /*-
6  * SPDX-License-Identifier: BSD-3-Clause
7  *
8  * [NetBSD for NEC PC-98 series]
9  *  Copyright (c) 1998
10  *	NetBSD/pc98 porting staff. All rights reserved.
11  *
12  *  Redistribution and use in source and binary forms, with or without
13  *  modification, are permitted provided that the following conditions
14  *  are met:
15  *  1. Redistributions of source code must retain the above copyright
16  *     notice, this list of conditions and the following disclaimer.
17  *  2. Redistributions in binary form must reproduce the above copyright
18  *     notice, this list of conditions and the following disclaimer in the
19  *     documentation and/or other materials provided with the distribution.
20  *  3. The name of the author may not be used to endorse or promote products
21  *     derived from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 #ifndef	_NSPREG_H_
37 #define	_NSPREG_H_
38 
39 /* base registers */
40 #define	nsp_irqcr	0
41 #define	IRQCR_RESCL	0x01
42 #define	IRQCR_PHCL	0x02
43 #define	IRQCR_TIMERCL	0x04
44 #define	IRQCR_FIFOCL	0x08
45 #define	IRQCR_SCSIIDIS	0x10
46 #define	IRQCR_EXTIDIS	0x20
47 #define	IRQCR_TIMERIDIS	0x40
48 #define	IRQCR_FIFOIDIS	0x80
49 #define	IRQCR_ALLMASK	0xff
50 #define	IRQCR_IRQDIS	0xf0
51 
52 #define	nsp_irqsr	0
53 #define	IRQSR_SCSI	0x01
54 #define	IRQSR_EXT	0x02
55 #define	IRQSR_TIMER	0x04
56 #define	IRQSR_FIFO	0x08
57 #define	IRQSR_MASK	0x0f
58 
59 #define	nsp_ifselr	1
60 #define	IFSELR_IFSEL	0x01
61 #define	IFSELR_REGSEL	0x04
62 
63 #define	nsp_fifosr	1
64 #define	FIFOSR_CHIPREVM	0x0f
65 #define	FIFOSR_CHIPIDM	0x70
66 #define	FIFOSR_FULLEMP	0x80
67 
68 #define	nsp_idxr	2
69 #define	nsp_datar	3
70 #define	nsp_fifodr	4
71 
72 /* indexed registers */
73 #define	NSPR_EXTBUSC	0x10
74 
75 #define	NSPR_CLKDIVR	0x11
76 #define	CLKDIVR_40M	0x02
77 #define	CLKDIVR_20M	0x01
78 
79 #define	NSPR_TERMPWRC	0x13
80 #define	TERMPWRC_POWON	0x01
81 
82 #define	NSPR_SCIENR	0x15
83 #define	SCIENR_SCCHG	0x01
84 #define	SCIENR_RESEL	0x10
85 #define	SCIENR_FIFO	0x20
86 #define	SCIENR_RST	0x40
87 
88 #define	NSPR_IRQPHS	0x16
89 #define	IRQPHS_LMSG	0x01
90 #define	IRQPHS_LIO	0x02
91 #define	IRQPHS_LCD	0x04
92 #define	IRQPHS_LBF	0x08
93 #define	IRQPHS_PCHG	0x10
94 #define	IRQPHS_RSEL	0x20
95 #define	IRQPHS_FIFO	0x40
96 #define	IRQPHS_RST	0x80
97 #define	IRQPHS_PHMASK   (IRQPHS_LCD | IRQPHS_LMSG | IRQPHS_LIO)
98 
99 #define	NSPR_TIMERCNT	0x17
100 
101 #define NSPR_SCBUSCR	0x18
102 #define	SCBUSCR_SEL	0x01
103 #define	SCBUSCR_RST	0x02
104 #define	SCBUSCR_DOUT	0x04
105 #define	SCBUSCR_ATN	0x08
106 #define	SCBUSCR_ACK	0x10
107 #define	SCBUSCR_BSY	0x20
108 #define	SCBUSCR_ADIR	0x40
109 #define	SCBUSCR_ACKEN	0x80
110 
111 #define	NSPR_SCBUSMON	0x19
112 #define	SCBUSMON_MSG	0x01
113 #define	SCBUSMON_IO	0x02
114 #define	SCBUSMON_CD	0x04
115 #define	SCBUSMON_BSY	0x08
116 #define	SCBUSMON_ACK	0x10
117 #define	SCBUSMON_REQ	0x20
118 #define	SCBUSMON_SEL	0x40
119 #define SCBUSMON_ATN	0x80
120 
121 #define	NSPR_SETARBIT	0x1A
122 
123 #define	NSPR_ARBITS	0x1A
124 #define	ARBITS_EXEC	0x01
125 #define	ARBITS_CLR	0x02
126 #define	ARBITS_WIN	0x02
127 #define	ARBITS_FAIL	0x04
128 #define	ARBITS_RESEL	0x08
129 
130 #define	NSPR_PARITYR	0x1B	/* (W/R) */
131 #define	PARITYR_ENABLE	0x01
132 #define	PARITYR_CLEAR	0x02
133 #define	PARITYR_PE	0x02
134 
135 #define	NSPR_CMDCR	0x1C	/* (W) */
136 #define	CMDCR_PTCLR	0x01
137 #define	CMDCR_EXEC	0x02
138 
139 #define	NSPR_RESELR	0x1C	/* (R) */
140 #define	NSPR_CMDDR	0x1D	/* (W/R) */
141 
142 #define	NSPR_PTCLRR	0x1E	/* (W) */
143 #define	PTCLRR_PT	0x01
144 #define	PTCLRR_ACK	0x02
145 #define	PTCLRR_REQ	0x04
146 #define	PTCLRR_HOST	0x08
147 #define	PTCLRR_RSS	0x30
148 #define	PTCLRR_RSS_ACK	0x00
149 #define	PTCLRR_RSS_REQ	0x10
150 #define	PTCLRR_RSS_HOST	0x20
151 
152 #define	NSPR_XFERCR	0x1E	/* (R) */
153 
154 #define	NSPR_XFERMR	0x20
155 #define	XFERMR_MEM8	0x01
156 #define	XFERMR_MEM32	0x02
157 #define	XFERMR_ADR24	0x04
158 #define	XFERMR_ADR32	0x08
159 #define	XFERMR_IO8	0x10
160 #define	XFERMR_IO32	0x20
161 #define	XFERMR_XEN	0x40
162 #define	XFERMR_FIFOEN	0x80
163 
164 #define	NSPR_SYNCR	0x21
165 #define	SYNCR_OFFM	0x0f
166 #define	SYNCR_PERM	0xf0
167 #define	SYNCR_PERS	4
168 
169 #define	NSPR_DATA	0x22
170 #define	NSPR_DATAACK	0x23
171 #define	NSPR_OCR	0x26
172 #define	OCR_ROMEN	0x01
173 #define	OCR_TERMPWROUT	0x02
174 #define	OCR_TERMPWRS	0x04
175 
176 #define NSPR_ACKWIDTH	0x27
177 
178 /* SCBUSMON phase defs */
179 #define	SCBUSMON_FREE	0
180 #define	SCBUSMON_CMD \
181 	(SCBUSMON_BSY | SCBUSMON_CD | SCBUSMON_REQ)
182 #define	SCBUSMON_MSGIN \
183 	(SCBUSMON_BSY | SCBUSMON_MSG | SCBUSMON_IO | SCBUSMON_CD | SCBUSMON_REQ)
184 #define	SCBUSMON_MSGOUT \
185 	(SCBUSMON_BSY | SCBUSMON_MSG | SCBUSMON_CD | SCBUSMON_REQ)
186 #define	SCBUSMON_DATAIN \
187 	(SCBUSMON_BSY | SCBUSMON_IO | SCBUSMON_REQ)
188 #define	SCBUSMON_DATAOUT \
189 	(SCBUSMON_BSY | SCBUSMON_REQ)
190 #define	SCBUSMON_STATUS \
191 	(SCBUSMON_BSY | SCBUSMON_IO | SCBUSMON_CD | SCBUSMON_REQ)
192 #define	SCBUSMON_RESELECT \
193 	(SCBUSMON_SEL | SCBUSMON_IO)
194 #define	SCBUSMON_PHMASK \
195 	(SCBUSMON_SEL | SCBUSMON_CD | SCBUSMON_MSG | SCBUSMON_IO)
196 
197 /* Data phase */
198 #define	NSP_IS_PHASE_DATA(ph) \
199 	((((ph) & SCBUSMON_PHMASK) & ~SCBUSMON_IO) == 0)
200 #define	NSP_IS_IRQPHS_DATA(ph) \
201 	((((ph) & IRQPHS_PHMASK) & ~SCBUSMON_IO) == 0)
202 
203 /* SCSI phase */
204 #define	PHASE_CMD	(SCBUSMON_CMD & SCBUSMON_PHMASK)
205 #define	PHASE_DATAIN	(SCBUSMON_DATAIN & SCBUSMON_PHMASK)
206 #define	PHASE_DATAOUT	(SCBUSMON_DATAOUT & SCBUSMON_PHMASK)
207 #define	PHASE_STATUS	(SCBUSMON_STATUS & SCBUSMON_PHMASK)
208 #define	PHASE_MSGIN	(SCBUSMON_MSGIN & SCBUSMON_PHMASK)
209 #define	PHASE_MSGOUT	(SCBUSMON_MSGOUT & SCBUSMON_PHMASK)
210 #define	PHASE_SEL	(SCBUSMON_SEL | SCBUSMON_IO)
211 
212 #define	IRQPHS_CMD	(IRQPHS_LCD)
213 #define	IRQPHS_DATAIN	(IRQPHS_LIO)
214 #define	IRQPHS_DATAOUT	(0)
215 #define	IRQPHS_STATUS	(IRQPHS_LCD | IRQPHS_LIO)
216 #define	IRQPHS_MSGIN	(IRQPHS_LCD | IRQPHS_LMSG | IRQPHS_LIO)
217 #define	IRQPHS_MSGOUT	(IRQPHS_LCD | IRQPHS_LMSG)
218 
219 /* Size */
220 #define	NSP_MEMSIZE	NBPG
221 #define	NSP_IOSIZE	16
222 #define	NSP_BUFFER_SIZE	512
223 #endif	/* !_NSPREG_H_ */
224