xref: /netbsd-src/sys/arch/sgimips/dev/scnreg.h (revision b610ccb0d6fb85d0833c5ef7e784b0e8a2d210bb)
1*b610ccb0Srumble /*	$NetBSD: scnreg.h,v 1.1 2009/02/10 06:04:56 rumble Exp $	*/
2*b610ccb0Srumble 
3*b610ccb0Srumble /*
4*b610ccb0Srumble  * Copyright (c) 1996, 1997 Philip L. Budne.
5*b610ccb0Srumble  * Copyright (c) 1993 Philip A. Nelson.
6*b610ccb0Srumble  * All rights reserved.
7*b610ccb0Srumble  *
8*b610ccb0Srumble  * Redistribution and use in source and binary forms, with or without
9*b610ccb0Srumble  * modification, are permitted provided that the following conditions
10*b610ccb0Srumble  * are met:
11*b610ccb0Srumble  * 1. Redistributions of source code must retain the above copyright
12*b610ccb0Srumble  *    notice, this list of conditions and the following disclaimer.
13*b610ccb0Srumble  * 2. Redistributions in binary form must reproduce the above copyright
14*b610ccb0Srumble  *    notice, this list of conditions and the following disclaimer in the
15*b610ccb0Srumble  *    documentation and/or other materials provided with the distribution.
16*b610ccb0Srumble  * 3. All advertising materials mentioning features or use of this software
17*b610ccb0Srumble  *    must display the following acknowledgement:
18*b610ccb0Srumble  *	This product includes software developed by Philip A. Nelson.
19*b610ccb0Srumble  * 4. The name of Philip A. Nelson may not be used to endorse or promote
20*b610ccb0Srumble  *    products derived from this software without specific prior written
21*b610ccb0Srumble  *    permission.
22*b610ccb0Srumble  *
23*b610ccb0Srumble  * THIS SOFTWARE IS PROVIDED BY PHILIP NELSON ``AS IS'' AND ANY EXPRESS OR
24*b610ccb0Srumble  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25*b610ccb0Srumble  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26*b610ccb0Srumble  * IN NO EVENT SHALL PHILIP NELSON BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27*b610ccb0Srumble  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28*b610ccb0Srumble  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29*b610ccb0Srumble  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30*b610ccb0Srumble  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31*b610ccb0Srumble  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32*b610ccb0Srumble  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33*b610ccb0Srumble  *
34*b610ccb0Srumble  *	scnreg.h: definitions for 2681/2692/68681 duart
35*b610ccb0Srumble  */
36*b610ccb0Srumble 
37*b610ccb0Srumble /*
38*b610ccb0Srumble  * register offsets
39*b610ccb0Srumble  */
40*b610ccb0Srumble 
41*b610ccb0Srumble /* per-channel regs (channel B's at SCN_REG(8-11)) */
42*b610ccb0Srumble #define CH_MR	SCN_REG(0)	/* rw mode register */
43*b610ccb0Srumble #define CH_SR	SCN_REG(1)	/* ro status register */
44*b610ccb0Srumble #define CH_CSR	SCN_REG(1)	/* wo clock select reg */
45*b610ccb0Srumble #define CH_CR	SCN_REG(2)	/* wo command reg */
46*b610ccb0Srumble #define CH_DAT	SCN_REG(3)	/* rw data reg */
47*b610ccb0Srumble 
48*b610ccb0Srumble /* duart-wide regs */
49*b610ccb0Srumble #define DU_IPCR	SCN_REG(4)	/* ro input port change reg */
50*b610ccb0Srumble #define DU_ACR	SCN_REG(4)	/* wo aux control reg */
51*b610ccb0Srumble #define DU_ISR	SCN_REG(5)	/* ro interrupt stat reg */
52*b610ccb0Srumble #define DU_IMR	SCN_REG(5)	/* wo interrupt mask reg */
53*b610ccb0Srumble #define DU_CTUR	SCN_REG(6)	/* rw counter timer upper reg */
54*b610ccb0Srumble #define DU_CTLR	SCN_REG(7)	/* rw counter timer lower reg */
55*b610ccb0Srumble 				/* SCN_REG(8-11) channel b (see above) */
56*b610ccb0Srumble 				/* SCN_REG(12): reserved */
57*b610ccb0Srumble #define DU_IP	SCN_REG(13)	/* ro input port */
58*b610ccb0Srumble #define DU_OPCR	SCN_REG(13)	/* wo output port cfg reg */
59*b610ccb0Srumble #define DU_CSTRT SCN_REG(14)	/* ro start C/T cmd */
60*b610ccb0Srumble #define DU_OPSET SCN_REG(14)	/* wo output port set */
61*b610ccb0Srumble #define DU_CSTOP SCN_REG(15)	/* ro stop C/T cmd */
62*b610ccb0Srumble #define DU_OPCLR SCN_REG(15)	/* wo output port reset */
63*b610ccb0Srumble 
64*b610ccb0Srumble /*
65*b610ccb0Srumble  * Data Values
66*b610ccb0Srumble  */
67*b610ccb0Srumble 
68*b610ccb0Srumble /*
69*b610ccb0Srumble  * MR (mode register) -- per channel
70*b610ccb0Srumble  */
71*b610ccb0Srumble 
72*b610ccb0Srumble /* MR0 (scn26c92 only) need to use CR_CMD_MR0 before access */
73*b610ccb0Srumble #define MR0_MODE	0x07	/* extended baud rate mode (MR0A only) */
74*b610ccb0Srumble #define MR0_TXINT	0x30	/* Tx int threshold */
75*b610ccb0Srumble #define MR0_RXINT	0x40	/* Rx int threshold (along with MR1_FFULL) */
76*b610ccb0Srumble #define MR0_RXWD	0x80	/* Rx watchdog (8 byte-times after last rx) */
77*b610ccb0Srumble 
78*b610ccb0Srumble #define MR0_MODE_0	0x00	/* Normal mode */
79*b610ccb0Srumble #define MR0_MODE_1	0x01	/* Extended mode 1 */
80*b610ccb0Srumble #define MR0_MODE_2	0x04	/* Extended mode 2 */
81*b610ccb0Srumble 
82*b610ccb0Srumble #define MR0_TXINT_EMPTY	0x00	/* TxInt when 8 FIFO bytes empty  (default) */
83*b610ccb0Srumble #define MR0_TXINT_4	0x10	/* TxInt when 4 or more FIFO bytes empty */
84*b610ccb0Srumble #define MR0_TXINT_6	0x20	/* TxInt when 6 or more FIFO bytes empty */
85*b610ccb0Srumble #define MR0_TXINT_TXRDY	0x30	/* TxInt when 1 or more FIFO bytes empty */
86*b610ccb0Srumble 
87*b610ccb0Srumble /* MR1 (need to use CR_CMD_MR1 before each access) */
88*b610ccb0Srumble #define MR1_CS5		0x00
89*b610ccb0Srumble #define MR1_CS6		0x01
90*b610ccb0Srumble #define MR1_CS7		0x02
91*b610ccb0Srumble #define MR1_CS8		0x03
92*b610ccb0Srumble 
93*b610ccb0Srumble #define	MR1_PEVEN	0x00
94*b610ccb0Srumble #define MR1_PODD	0x04
95*b610ccb0Srumble #define MR1_PNONE	0x10
96*b610ccb0Srumble 
97*b610ccb0Srumble #define MR1_RXBLK	0x20	/* "block" error mode */
98*b610ccb0Srumble #define MR1_FFULL	0x40	/* wait until FIFO full for rxint (cf MR0) */
99*b610ccb0Srumble #define MR1_RXRTS	0x80	/* auto RTS input flow ctrl */
100*b610ccb0Srumble 
101*b610ccb0Srumble /* MR2 (any access to MR after MR1) */
102*b610ccb0Srumble #define MR2_STOP	0x0f	/* mask for stop bits */
103*b610ccb0Srumble #define MR2_STOP1	0x07
104*b610ccb0Srumble #define MR2_STOP2	0x0f
105*b610ccb0Srumble 
106*b610ccb0Srumble #define MR2_TXCTS	0x10	/* transmitter follows CTS */
107*b610ccb0Srumble #define MR2_TXRTS	0x20	/* RTS follows transmitter */
108*b610ccb0Srumble #define MR2_MODE	0xc0	/* mode mask */
109*b610ccb0Srumble 
110*b610ccb0Srumble /*
111*b610ccb0Srumble  * IP (input port)
112*b610ccb0Srumble  */
113*b610ccb0Srumble #define IP_IP0		0x01
114*b610ccb0Srumble #define IP_IP1		0x02
115*b610ccb0Srumble #define IP_IP2		0x04
116*b610ccb0Srumble #define IP_IP3		0x08
117*b610ccb0Srumble #define IP_IP4		0x10
118*b610ccb0Srumble #define IP_IP5		0x20
119*b610ccb0Srumble #define IP_IP6		0x40
120*b610ccb0Srumble /* D7 is always 1 */
121*b610ccb0Srumble 
122*b610ccb0Srumble /*
123*b610ccb0Srumble  * ACR (Aux Control Register)
124*b610ccb0Srumble  */
125*b610ccb0Srumble 
126*b610ccb0Srumble #define ACR_DELTA_IP0	0x01	/* enable IP0 delta interrupt */
127*b610ccb0Srumble #define ACR_DELTA_IP1	0x02	/* enable IP1 delta interrupt */
128*b610ccb0Srumble #define ACR_DELTA_IP2	0x04	/* enable IP2 delta interrupt */
129*b610ccb0Srumble #define ACR_DELTA_IP3	0x08	/* enable IP3 delta interrupt */
130*b610ccb0Srumble #define ACR_CT		0x70	/* counter/timer mode (ACT_CT_xxx) */
131*b610ccb0Srumble #define ACR_BRG		0x80	/* baud rate generator speed set */
132*b610ccb0Srumble 
133*b610ccb0Srumble /* counter/timer mode */
134*b610ccb0Srumble #define ACR_CT_CEXT	0x00	/* counter: external (IP2) */
135*b610ccb0Srumble #define ACR_CT_CTXA	0x10	/* counter: TxCA x 1 */
136*b610ccb0Srumble #define ACR_CT_CTXB	0x20	/* counter: TxCB x 1 */
137*b610ccb0Srumble #define ACR_CT_CCLK	0x30	/* counter: X1/CLK div 16 */
138*b610ccb0Srumble #define ACR_CT_TEXT1	0x40	/* timer: external (IP2) */
139*b610ccb0Srumble #define ACR_CT_TEXT16	0x50	/* timer: external (IP2) div 16 */
140*b610ccb0Srumble #define ACR_CT_TCLK1	0x60	/* timer: X1/CLK */
141*b610ccb0Srumble #define ACR_CT_TCLK16	0x70	/* timer: X1/CLK div 16 */
142*b610ccb0Srumble 
143*b610ccb0Srumble /*
144*b610ccb0Srumble  * IPCR (Input Port Change Register) -- per channel
145*b610ccb0Srumble  */
146*b610ccb0Srumble #define IPCR_IP0	0x01
147*b610ccb0Srumble #define IPCR_IP1	0x02
148*b610ccb0Srumble #define IPCR_IP2	0x04
149*b610ccb0Srumble #define IPCR_IP3	0x08
150*b610ccb0Srumble #define IPCR_DELTA_IP0	0x10
151*b610ccb0Srumble #define IPCR_DELTA_IP1	0x20
152*b610ccb0Srumble #define IPCR_DELTA_IP2	0x40
153*b610ccb0Srumble #define IPCR_DELTA_IP3	0x80
154*b610ccb0Srumble 
155*b610ccb0Srumble /*
156*b610ccb0Srumble  * output port config register
157*b610ccb0Srumble  * if bit(s) clear OP line follows OP register OPn bit
158*b610ccb0Srumble  */
159*b610ccb0Srumble 
160*b610ccb0Srumble #define OPCR_OP7_TXRDYB	0x80	/* OP7: TxRDYB */
161*b610ccb0Srumble #define OPCR_OP6_TXRDYA	0x40	/* OP6: TxRDYA */
162*b610ccb0Srumble #define OPCR_OP5_RXRDYB	0x20	/* OP5: ch B RxRDY/FFULL */
163*b610ccb0Srumble #define OPCR_OP4_RXRDYA	0x10	/* OP4: ch A RxRDY/FFULL */
164*b610ccb0Srumble 
165*b610ccb0Srumble #define OPCR_OP3	0xC0	/* OP3: mask */
166*b610ccb0Srumble #define OPCR_OP2	0x03	/* OP2: mask */
167*b610ccb0Srumble 
168*b610ccb0Srumble /*
169*b610ccb0Srumble  * output port
170*b610ccb0Srumble  */
171*b610ccb0Srumble #define OP_OP0		0x01
172*b610ccb0Srumble #define OP_OP1		0x02
173*b610ccb0Srumble #define OP_OP2		0x04
174*b610ccb0Srumble #define OP_OP3		0x08
175*b610ccb0Srumble #define OP_OP4		0x10
176*b610ccb0Srumble #define OP_OP5		0x20
177*b610ccb0Srumble #define OP_OP6		0x40
178*b610ccb0Srumble #define OP_OP7		0x80
179*b610ccb0Srumble 
180*b610ccb0Srumble /*
181*b610ccb0Srumble  * CR (command register) -- per channel
182*b610ccb0Srumble  */
183*b610ccb0Srumble 
184*b610ccb0Srumble /* bits (may be or'ed together, with a command) */
185*b610ccb0Srumble #define CR_ENA_RX	0x01
186*b610ccb0Srumble #define CR_DIS_RX	0x02
187*b610ccb0Srumble #define CR_ENA_TX	0x04
188*b610ccb0Srumble #define CR_DIS_TX	0x08
189*b610ccb0Srumble 
190*b610ccb0Srumble /* commands */
191*b610ccb0Srumble #define CR_CMD_NOP	0x00
192*b610ccb0Srumble #define CR_CMD_MR1	0x10
193*b610ccb0Srumble #define CR_CMD_RESET_RX	0x20
194*b610ccb0Srumble #define CR_CMD_RESET_TX	0x30
195*b610ccb0Srumble #define CR_CMD_RESET_ERR 0x40
196*b610ccb0Srumble #define CR_CMD_RESET_BRK 0x50
197*b610ccb0Srumble #define CR_CMD_START_BRK 0x60
198*b610ccb0Srumble #define CR_CMD_STOP_BRK	0x70
199*b610ccb0Srumble 
200*b610ccb0Srumble /* 2692-only commands */
201*b610ccb0Srumble #define CR_CMD_RTS_ON	0x80	/* raise RTS */
202*b610ccb0Srumble #define CR_CMD_RTS_OFF	0x90	/* lower RTS */
203*b610ccb0Srumble #define CR_CMD_TIM_ON	0xa0	/* enable timeout mode */
204*b610ccb0Srumble #define CR_CMD_TIM_OFF	0xc0	/* reset timeout mode */
205*b610ccb0Srumble #define CR_CMD_PDN_ON	0xe0	/* power down mode on */
206*b610ccb0Srumble #define CR_CMD_PDN_RUN	0xf0	/* power down mode off (normal run) */
207*b610ccb0Srumble 
208*b610ccb0Srumble /* 26C92-only commands */
209*b610ccb0Srumble #define CR_CMD_MR0	0xb0	/* MR0 select */
210*b610ccb0Srumble 
211*b610ccb0Srumble 
212*b610ccb0Srumble /*
213*b610ccb0Srumble  * SR (status register) -- per channel
214*b610ccb0Srumble  */
215*b610ccb0Srumble #define SR_RX_RDY	0x01
216*b610ccb0Srumble #define SR_RX_FFULL	0x02	/* rx fifo full */
217*b610ccb0Srumble #define SR_TX_RDY	0x04	/* tx room for more */
218*b610ccb0Srumble #define SR_TX_EMPTY	0x08	/* tx dry */
219*b610ccb0Srumble 
220*b610ccb0Srumble #define SR_OVERRUN	0x10
221*b610ccb0Srumble 
222*b610ccb0Srumble /* bits cleared by reset error (see MR1 error mode bit) */
223*b610ccb0Srumble #define SR_PARITY	0x20	/* received parity error */
224*b610ccb0Srumble #define SR_FRAME	0x40	/* received framing error */
225*b610ccb0Srumble #define SR_BREAK	0x80	/* received break */
226*b610ccb0Srumble 
227*b610ccb0Srumble /*
228*b610ccb0Srumble  * Interrupt Mask Register (IMR) and ISR (Interrupt Status Register)
229*b610ccb0Srumble  */
230*b610ccb0Srumble #define INT_TXA		0x01	/* Tx Ready A */
231*b610ccb0Srumble #define INT_RXA		0x02	/* Rx Ready/FIFO Full A */
232*b610ccb0Srumble #define INT_BRKA	0x04	/* Delta Break A */
233*b610ccb0Srumble #define INT_CTR		0x08	/* counter ready */
234*b610ccb0Srumble #define INT_TXB		0x10	/* Tx Ready B */
235*b610ccb0Srumble #define INT_RXB		0x20	/* Rx Ready/FIFO Full B */
236*b610ccb0Srumble #define INT_BRKB	0x40	/* Delta Break B */
237*b610ccb0Srumble #define INT_IP		0x80	/* input port change */
238