xref: /original-bsd/sys/hp300/dev/dcmreg.h (revision 9639f1d4)
1 /*
2  * Copyright (c) 1988 University of Utah.
3  * Copyright (c) 1982, 1986, 1990, 1993
4  *	The Regents of the University of California.  All rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by
7  * the Systems Programming Group of the University of Utah Computer
8  * Science Department.
9  *
10  * %sccs.include.redist.c%
11  *
12  * from: Utah $Hdr: dcmreg.h 1.7 92/01/21$
13  *
14  *	@(#)dcmreg.h	8.1 (Berkeley) 06/10/93
15  */
16 
17 #include <hp/dev/iotypes.h>		/* XXX */
18 
19 struct dcmdevice {	   /* host address, only odd bytes addressed */
20 	u_char	dcm_pad0;
21 	vu_char	dcm_rsid;		/* Reset / ID			0001 */
22 	u_char	dcm_pad1;
23 	vu_char	dcm_ic;			/* Interrupt control register	0003 */
24 	u_char	dcm_pad2;
25 	vu_char	dcm_sem;		/* Semaphore register		0005 */
26 	u_char  dcm_pad3[0x7ffa];	/* Unaddressable	0006-7fff */
27 	u_char	dcm_pad4;
28 	vu_char	dcm_iir;		/* Interrupt ident register	8001 */
29 	u_char	dcm_pad5;
30 	vu_char	dcm_cr;			/* Command register		8003 */
31 	u_char  dcm_pad6[0x3fc];	/* Card scratch		8004-83ff */
32 	struct	dcmrfifo {
33 		u_char	ptr_pad1;
34 		vu_char	data_char;
35 		u_char	ptr_pad2;
36 		vu_char	data_stat;
37 	} dcm_rfifos[4][0x80];		/* Receive queues		8400 */
38 	struct  {
39 		u_char	ptr_pad1;
40 		vu_char	data_data;
41 	} dcm_bmap[0x100];		/* Bitmap table			8c00 */
42 	struct  {
43 		u_char	ptr_pad;
44 		vu_char	ptr;
45 	} dcm_rhead[4];			/* Fifo head - receive		8e00 */
46 	struct  {
47 		u_char  ptr_pad;
48 		vu_char  ptr;
49 	} dcm_rtail[4];			/* Fifo tail - receive		8e08 */
50 	struct  {
51 		u_char	ptr_pad;
52 		vu_char	ptr;
53 	} dcm_thead[4];			/* Fifo head - transmit		8e10 */
54 	struct  {
55 		u_char	ptr_pad;
56 		vu_char	ptr;
57 	} dcm_ttail[4];			/* Fifo tail - transmit		8e18 */
58 	struct  {
59 		u_char	pad1;
60 		vu_char	dcm_conf;
61 		u_char	pad2;
62 		vu_char	dcm_baud;
63 	} dcm_data[4];			/* Configuration registers	8e20 */
64 	struct	modemreg {
65 		u_char	pad0;
66 		vu_char mdmin;		/* Modem in			8e31 */
67 		u_char  pad1;
68 		vu_char mdmout;		/* Modem out			8e33 */
69 		u_char  pad2;
70 		vu_char mdmmsk;		/* Modem mask			8e35 */
71 	} dcm_modem0;
72 	struct  {
73 		u_char pad1;
74 		vu_char dcm_data;
75 	} dcm_cmdtab[4];		/* Command tables		8e36 */
76 	struct  {
77 		u_char pad1;
78 		vu_char dcm_data;
79 	} dcm_icrtab[4];		/* Interrupt data		8e3e */
80 	u_char  dcm_pad10;
81 	vu_char dcm_stcon;		/* Self test condition		8e47 */
82 	struct modemreg dcm_modem1;	/* 638 Modem port1		8e48 */
83 	struct modemreg dcm_modem2;	/* 638 Modem port2		8e4e */
84 	struct modemreg dcm_modem3;	/* 638 Modem port3		8e54 */
85 	u_char	dcm_pad11;
86 	vu_char	dcm_modemchng;		/* 638 Modem change mask	8e5b */
87 	u_char	dcm_pad12;
88 	vu_char	dcm_modemintr;		/* 638 Modem interrupt mask	8e5d */
89 	u_char  dcm_pad13[0x82];	/* Undef Shared Ram	8e5e-8edf */
90 	struct	dcmtfifo {
91 	    u_char  ptr_pad1;
92 	    vu_char  data_char;
93 	} dcm_tfifos[4][0x10];		/* Transmit queues		8ee0 */
94 };
95 
96 /*
97  * Overlay structure for port specific queue "registers".
98  * Starts at offset 0x8E00+(port*2).
99  */
100 struct	dcmpreg {
101 	u_char		pad0;		/* +00 */
102 	vu_char	r_head;			/* +01 */
103 	u_char		pad1[7];	/* +02 */
104 	vu_char	r_tail;			/* +09 */
105 	u_char		pad2[7];	/* +0A */
106 	vu_char	t_head;			/* +11 */
107 	u_char		pad3[7];	/* +12 */
108 	vu_char	t_tail;			/* +19 */
109 };
110 #define	dcm_preg(d, p)	((struct dcmpreg *)((u_int)(d)+0x8e00+(p)*2))
111 
112 /* interface reset/id */
113 #define DCMCON          0x80	/* REMOTE/LOCAL switch, read */
114 #define	DCMID		0x5	/* hardwired card id, read */
115 #define	DCMRS		0x80	/* software reset, write */
116 
117 /* interrupt control */
118 #define	DCMIPL(x)	((((x) >> 4) & 3) + 3)	/* interupt level, read */
119 #define	IC_IR		0x40	/* interupt request, read */
120 #define	IC_IE		0x80	/* interupt enable, write */
121 #define	IC_ID		0x00	/* interupt disable, write */
122 
123 
124 /* Semaphore control */
125 #define	SEM_BSY		0x80	/* read */
126 #define SEM_CLR         0xFF	/* write */
127 #define SEM_LOCK(dcm)	while ((dcm)->dcm_sem & SEM_BSY)
128 #define SEM_UNLOCK(dcm)	(dcm)->dcm_sem = SEM_CLR
129 
130 /* command register */
131 #define	CR_PORT0	0x1
132 #define	CR_PORT1	0x2
133 #define	CR_PORT2	0x4
134 #define	CR_PORT3	0x8
135 #define	CR_MODM		0x10	/* change modem output lines */
136 #define	CR_TIMER	0x20	/* 16ms interrupt timer toggle */
137 #define	CR_SELFT	0x40	/* run self test */
138 #define CR_MASK		0x7f
139 
140 /* interrupt ident register */
141 #define	IIR_PORT0	0x1
142 #define	IIR_PORT1	0x2
143 #define	IIR_PORT2	0x4
144 #define	IIR_PORT3	0x8
145 #define	IIR_SELFT	0x10	/* self test completed */
146 #define	IIR_MODM	0x20	/* change in modem input lines */
147 #define	IIR_TIMEO	0x40	/* Time out */
148 #define IIR_MASK	0x7f
149 
150 /* self test cond reg */
151 #define ST_OK           0xe0
152 
153 /* Line configuration register */
154 #define	LC_PNO		0x00
155 #define	LC_PODD		0x01
156 #define	LC_PEVEN	0x02
157 #define	LC_PMSK		0x03
158 
159 #define	LC_1STOP	0x00
160 #define	LC_1HSTOP	0x04
161 #define	LC_2STOP	0x08
162 #define	LC_STOPMSK	0x0b
163 
164 #define	LC_8BITS	0x30
165 #define	LC_7BITS	0x20
166 #define	LC_6BITS	0x10
167 #define	LC_5BITS	0x00
168 #define	LC_BITMSK	0x30
169 
170 /* baud reg */
171 #define BR_0		0x00
172 #define BR_50		0x01
173 #define BR_75		0x02
174 #define BR_110		0x03
175 #define BR_134  	0x04
176 #define BR_150		0x05
177 #define BR_300		0x06
178 #define BR_600		0x07
179 #define BR_900		0x08
180 #define BR_1200		0x09
181 #define BR_1800		0x0a
182 #define BR_2400		0x0b
183 #define BR_3600		0x0c
184 #define BR_4800		0x0d
185 #define BR_7200		0x0e
186 #define BR_9600		0x0f
187 #define BR_19200	0x10
188 #define BR_38400	0x11
189 
190 /* modem input register */
191 #define	MI_CTS		0x08
192 #define	MI_DM		0x04
193 #define	MI_CD		0x02
194 #define	MI_RI		0x01
195 
196 /* modem output register */
197 #define	MO_SR		0x04
198 #define	MO_DTR		0x02
199 #define	MO_RTS		0x01
200 #define	MO_ON		((MO_DTR) | (MO_RTS))
201 #define	MO_OFF		0x00
202 
203 /* cmd-tab values, write */
204 #define CT_CON		0x1	/* configuration change */
205 #define CT_TX		0x2	/* transmit buffer not empty */
206 #define CT_BRK		0x4	/* toggle BREAK */
207 
208 /* icr-tab values, read */
209 #define IT_TX		0x1	/* transmit buffer empty */
210 #define IT_SPEC		0x2	/* special character received */
211 
212 /* data errors */
213 #define RD_OVF		0x08
214 #define RD_BD		0x10
215 #define RD_PE		0x20
216 #define RD_OE		0x40
217 #define RD_FE		0x80
218 #define RD_MASK		0xf8
219 
220 /* Transmit/Receive masks */
221 #define TX_MASK		0x0f
222 #define RX_MASK		0xff
223 
224 /*
225  * WARNING: Serial console is assumed to be the lowest select-code card
226  * and that card must be logical unit 0 in the kernel.  Also, CONUNIT must
227  * be 1, the port affected by the REMOTE/LOCAL switch.
228  */
229 #define CONUNIT	(1)
230