Merge branch 'vendor/OPENSSL'
[dragonfly.git] / sys / dev / serial / stl / sc26198.h
1 /*****************************************************************************/
2
3 /*
4  * sc26198.h  -- SC26198 UART hardware info.
5  *
6  * Copyright (c) 1995-1998 Greg Ungerer (gerg@stallion.oz.au).
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *      This product includes software developed by Greg Ungerer.
20  * 4. Neither the name of the author nor the names of any co-contributors
21  *    may be used to endorse or promote products derived from this software
22  *    without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  *
36  * $FreeBSD: src/sys/i386/isa/ic/sc26198.h,v 1.1.2.1 2001/08/30 12:29:55 murray Exp $
37  */
38
39 /*****************************************************************************/
40 #ifndef _SC26198_H
41 #define _SC26198_H
42 /*****************************************************************************/
43
44 /*
45  *      Define the number of async ports per sc26198 uart device.
46  */
47 #define SC26198_PORTS           8
48
49 /*
50  *      Baud rate timing clocks. All derived from a master 14.7456 MHz clock.
51  */
52 #define SC26198_MASTERCLOCK     14745600L
53 #define SC26198_DCLK            (SC26198_MASTERCLOCK)
54 #define SC26198_CCLK            (SC26198_MASTERCLOCK / 2)
55 #define SC26198_BCLK            (SC26198_MASTERCLOCK / 4)
56
57 /*
58  *      Define internal FIFO sizes for the 26198 ports.
59  */
60 #define SC26198_TXFIFOSIZE      16
61 #define SC26198_RXFIFOSIZE      16
62
63 /*****************************************************************************/
64
65 /*
66  *      Global register definitions. These registers are global to each 26198
67  *      device, not specific ports on it.
68  */
69 #define TSTR            0x0d
70 #define GCCR            0x0f
71 #define ICR             0x1b
72 #define WDTRCR          0x1d
73 #define IVR             0x1f
74 #define BRGTRUA         0x84
75 #define GPOSR           0x87
76 #define GPOC            0x8b
77 #define UCIR            0x8c
78 #define CIR             0x8c
79 #define BRGTRUB         0x8d
80 #define GRXFIFO         0x8e
81 #define GTXFIFO         0x8e
82 #define GCCR2           0x8f
83 #define BRGTRLA         0x94
84 #define GPOR            0x97
85 #define GPOD            0x9b
86 #define BRGTCR          0x9c
87 #define GICR            0x9c
88 #define BRGTRLB         0x9d
89 #define GIBCR           0x9d
90 #define GITR            0x9f
91
92 /*
93  *      Per port channel registers. These are the register offsets within
94  *      the port address space, so need to have the port address (0 to 7)
95  *      inserted in bit positions 4:6.
96  */
97 #define MR0             0x00
98 #define MR1             0x01
99 #define IOPCR           0x02
100 #define BCRBRK          0x03
101 #define BCRCOS          0x04
102 #define BCRX            0x06
103 #define BCRA            0x07
104 #define XONCR           0x08
105 #define XOFFCR          0x09
106 #define ARCR            0x0a
107 #define RXCSR           0x0c
108 #define TXCSR           0x0e
109 #define MR2             0x80
110 #define SR              0x81
111 #define SCCR            0x81
112 #define ISR             0x82
113 #define IMR             0x82
114 #define TXFIFO          0x83
115 #define RXFIFO          0x83
116 #define IPR             0x84
117 #define IOPIOR          0x85
118 #define XISR            0x86
119
120 /*
121  *      For any given port calculate the address to use to access a specified
122  *      register. This is only used for unusual access...
123  */
124 #define SC26198_PORTREG(port,reg)       ((((port) & 0x07) << 4) | (reg))
125
126 /*****************************************************************************/
127
128 /*
129  *      Global configuration control register bit definitions.
130  */
131 #define GCCR_NOACK              0x00
132 #define GCCR_IVRACK             0x02
133 #define GCCR_IVRCHANACK         0x04
134 #define GCCR_IVRTYPCHANACK      0x06
135 #define GCCR_ASYNCCYCLE         0x00
136 #define GCCR_SYNCCYCLE          0x40
137
138 /*****************************************************************************/
139
140 /*
141  *      Mode register 0 bit definitions.
142  */
143 #define MR0_ADDRNONE            0x00
144 #define MR0_AUTOWAKE            0x01
145 #define MR0_AUTODOZE            0x02
146 #define MR0_AUTOWAKEDOZE        0x03
147 #define MR0_SWFNONE             0x00
148 #define MR0_SWFTX               0x04
149 #define MR0_SWFRX               0x08
150 #define MR0_SWFRXTX             0x0c
151 #define MR0_TXMASK              0x30
152 #define MR0_TXEMPTY             0x00
153 #define MR0_TXHIGH              0x10
154 #define MR0_TXHALF              0x20
155 #define MR0_TXRDY               0x00
156 #define MR0_ADDRNT              0x00
157 #define MR0_ADDRT               0x40
158 #define MR0_SWFNT               0x00
159 #define MR0_SWFT                0x80
160
161 /*
162  *      Mode register 1 bit definitions.
163  */
164 #define MR1_CS5                 0x00
165 #define MR1_CS6                 0x01
166 #define MR1_CS7                 0x02
167 #define MR1_CS8                 0x03
168 #define MR1_PAREVEN             0x00
169 #define MR1_PARODD              0x04
170 #define MR1_PARENB              0x00
171 #define MR1_PARFORCE            0x08
172 #define MR1_PARNONE             0x10
173 #define MR1_PARSPECIAL          0x18
174 #define MR1_ERRCHAR             0x00
175 #define MR1_ERRBLOCK            0x20
176 #define MR1_ISRUNMASKED         0x00
177 #define MR1_ISRMASKED           0x40
178 #define MR1_AUTORTS             0x80
179
180 /*
181  *      Mode register 2 bit definitions.
182  */
183 #define MR2_STOP1               0x00
184 #define MR2_STOP15              0x01
185 #define MR2_STOP2               0x02
186 #define MR2_STOP916             0x03
187 #define MR2_RXFIFORDY           0x00
188 #define MR2_RXFIFOHALF          0x04
189 #define MR2_RXFIFOHIGH          0x08
190 #define MR2_RXFIFOFULL          0x0c
191 #define MR2_AUTOCTS             0x10
192 #define MR2_TXRTS               0x20
193 #define MR2_MODENORM            0x00
194 #define MR2_MODEAUTOECHO        0x40
195 #define MR2_MODELOOP            0x80
196 #define MR2_MODEREMECHO         0xc0
197
198 /*****************************************************************************/
199
200 /*
201  *      Baud Rate Generator (BRG) selector values.
202  */
203 #define BRG_50                  0x00
204 #define BRG_75                  0x01
205 #define BRG_150                 0x02
206 #define BRG_200                 0x03
207 #define BRG_300                 0x04
208 #define BRG_450                 0x05
209 #define BRG_600                 0x06
210 #define BRG_900                 0x07
211 #define BRG_1200                0x08
212 #define BRG_1800                0x09
213 #define BRG_2400                0x0a
214 #define BRG_3600                0x0b
215 #define BRG_4800                0x0c
216 #define BRG_7200                0x0d
217 #define BRG_9600                0x0e
218 #define BRG_14400               0x0f
219 #define BRG_19200               0x10
220 #define BRG_28200               0x11
221 #define BRG_38400               0x12
222 #define BRG_57600               0x13
223 #define BRG_115200              0x14
224 #define BRG_230400              0x15
225 #define BRG_GIN0                0x16
226 #define BRG_GIN1                0x17
227 #define BRG_CT0                 0x18
228 #define BRG_CT1                 0x19
229 #define BRG_RX2TX316            0x1b
230 #define BRG_RX2TX31             0x1c
231
232 /*****************************************************************************/
233
234 /*
235  *      Command register command definitions.
236  */
237 #define CR_NULL                 0x04
238 #define CR_ADDRNORMAL           0x0c
239 #define CR_RXRESET              0x14
240 #define CR_TXRESET              0x1c
241 #define CR_CLEARRXERR           0x24
242 #define CR_BREAKRESET           0x2c
243 #define CR_TXSTARTBREAK         0x34
244 #define CR_TXSTOPBREAK          0x3c
245 #define CR_RTSON                0x44
246 #define CR_RTSOFF               0x4c
247 #define CR_ADDRINIT             0x5c
248 #define CR_RXERRBLOCK           0x6c
249 #define CR_TXSENDXON            0x84
250 #define CR_TXSENDXOFF           0x8c
251 #define CR_GANGXONSET           0x94
252 #define CR_GANGXOFFSET          0x9c
253 #define CR_GANGXONINIT          0xa4
254 #define CR_GANGXOFFINIT         0xac
255 #define CR_HOSTXON              0xb4
256 #define CR_HOSTXOFF             0xbc
257 #define CR_CANCELXOFF           0xc4
258 #define CR_ADDRRESET            0xdc
259 #define CR_RESETALLPORTS        0xf4
260 #define CR_RESETALL             0xfc
261
262 #define CR_RXENABLE             0x01
263 #define CR_TXENABLE             0x02
264
265 /*****************************************************************************/
266
267 /*
268  *      Channel status register.
269  */
270 #define SR_RXRDY                0x01
271 #define SR_RXFULL               0x02
272 #define SR_TXRDY                0x04
273 #define SR_TXEMPTY              0x08
274 #define SR_RXOVERRUN            0x10
275 #define SR_RXPARITY             0x20
276 #define SR_RXFRAMING            0x40
277 #define SR_RXBREAK              0x80
278
279 #define SR_RXERRS               (SR_RXPARITY | SR_RXFRAMING | SR_RXOVERRUN)
280
281 /*****************************************************************************/
282
283 /*
284  *      Interrupt status register and interrupt mask register bit definitions.
285  */
286 #define IR_TXRDY                0x01
287 #define IR_RXRDY                0x02
288 #define IR_RXBREAK              0x04
289 #define IR_XONXOFF              0x10
290 #define IR_ADDRRECOG            0x20
291 #define IR_RXWATCHDOG           0x40
292 #define IR_IOPORT               0x80
293
294 /*****************************************************************************/
295
296 /*
297  *      Interrupt vector register field definitions.
298  */
299 #define IVR_CHANMASK            0x07
300 #define IVR_TYPEMASK            0x18
301 #define IVR_CONSTMASK           0xc0
302
303 #define IVR_RXDATA              0x10
304 #define IVR_RXBADDATA           0x18
305 #define IVR_TXDATA              0x08
306 #define IVR_OTHER               0x00
307
308 /*****************************************************************************/
309
310 /*
311  *      BRG timer control register bit definitions.
312  */
313 #define BRGCTCR_DISABCLK0       0x00
314 #define BRGCTCR_ENABCLK0        0x08
315 #define BRGCTCR_DISABCLK1       0x00
316 #define BRGCTCR_ENABCLK1        0x80
317
318 #define BRGCTCR_0SCLK16         0x00
319 #define BRGCTCR_0SCLK32         0x01
320 #define BRGCTCR_0SCLK64         0x02
321 #define BRGCTCR_0SCLK128        0x03
322 #define BRGCTCR_0X1             0x04
323 #define BRGCTCR_0X12            0x05
324 #define BRGCTCR_0IO1A           0x06
325 #define BRGCTCR_0GIN0           0x07
326
327 #define BRGCTCR_1SCLK16         0x00
328 #define BRGCTCR_1SCLK32         0x10
329 #define BRGCTCR_1SCLK64         0x20
330 #define BRGCTCR_1SCLK128        0x30
331 #define BRGCTCR_1X1             0x40
332 #define BRGCTCR_1X12            0x50
333 #define BRGCTCR_1IO1B           0x60
334 #define BRGCTCR_1GIN1           0x70
335
336 /*****************************************************************************/
337
338 /*
339  *      Watch dog timer enable register.
340  */
341 #define WDTRCR_ENABALL          0xff
342
343 /*****************************************************************************/
344
345 /*
346  *      XON/XOFF interrupt status register.
347  */
348 #define XISR_TXCHARMASK         0x03
349 #define XISR_TXCHARNORMAL       0x00
350 #define XISR_TXWAIT             0x01
351 #define XISR_TXXOFFPEND         0x02
352 #define XISR_TXXONPEND          0x03
353
354 #define XISR_TXFLOWMASK         0x0c
355 #define XISR_TXNORMAL           0x00
356 #define XISR_TXSTOPPEND         0x04
357 #define XISR_TXSTARTED          0x08
358 #define XISR_TXSTOPPED          0x0c
359
360 #define XISR_RXFLOWMASK         0x30
361 #define XISR_RXFLOWNONE         0x00
362 #define XISR_RXXONSENT          0x10
363 #define XISR_RXXOFFSENT         0x20
364
365 #define XISR_RXXONGOT           0x40
366 #define XISR_RXXOFFGOT          0x80
367
368 /*****************************************************************************/
369
370 /*
371  *      Current interrupt register.
372  */
373 #define CIR_TYPEMASK            0xc0
374 #define CIR_TYPEOTHER           0x00
375 #define CIR_TYPETX              0x40
376 #define CIR_TYPERXGOOD          0x80
377 #define CIR_TYPERXBAD           0xc0
378
379 #define CIR_RXDATA              0x80
380 #define CIR_RXBADDATA           0x40
381 #define CIR_TXDATA              0x40
382
383 #define CIR_CHANMASK            0x07
384 #define CIR_CNTMASK             0x38
385
386 #define CIR_SUBTYPEMASK         0x38
387 #define CIR_SUBNONE             0x00
388 #define CIR_SUBCOS              0x08
389 #define CIR_SUBADDR             0x10
390 #define CIR_SUBXONXOFF          0x18
391 #define CIR_SUBBREAK            0x28
392
393 /*****************************************************************************/
394
395 /*
396  *      Global interrupting channel register.
397  */
398 #define GICR_CHANMASK           0x07
399
400 /*****************************************************************************/
401
402 /*
403  *      Global interrupting byte count register.
404  */
405 #define GICR_COUNTMASK          0x0f
406
407 /*****************************************************************************/
408
409 /*
410  *      Global interrupting type register.
411  */
412 #define GITR_RXMASK             0xc0
413 #define GITR_RXNONE             0x00
414 #define GITR_RXBADDATA          0x80
415 #define GITR_RXGOODDATA         0xc0
416 #define GITR_TXDATA             0x20
417
418 #define GITR_SUBTYPEMASK        0x07
419 #define GITR_SUBNONE            0x00
420 #define GITR_SUBCOS             0x01
421 #define GITR_SUBADDR            0x02
422 #define GITR_SUBXONXOFF         0x03
423 #define GITR_SUBBREAK           0x05
424
425 /*****************************************************************************/
426
427 /*
428  *      Input port change register.
429  */
430 #define IPR_CTS                 0x01
431 #define IPR_DTR                 0x02
432 #define IPR_RTS                 0x04
433 #define IPR_DCD                 0x08
434 #define IPR_CTSCHANGE           0x10
435 #define IPR_DTRCHANGE           0x20
436 #define IPR_RTSCHANGE           0x40
437 #define IPR_DCDCHANGE           0x80
438
439 #define IPR_CHANGEMASK          0xf0
440
441 /*****************************************************************************/
442
443 /*
444  *      IO port interrupt and output register.
445  */
446 #define IOPR_CTS                0x01
447 #define IOPR_DTR                0x02
448 #define IOPR_RTS                0x04
449 #define IOPR_DCD                0x08
450 #define IOPR_CTSCOS             0x10
451 #define IOPR_DTRCOS             0x20
452 #define IOPR_RTSCOS             0x40
453 #define IOPR_DCDCOS             0x80
454
455 /*****************************************************************************/
456
457 /*
458  *      IO port configuration register.
459  */
460 #define IOPCR_SETCTS            0x00
461 #define IOPCR_SETDTR            0x04
462 #define IOPCR_SETRTS            0x10
463 #define IOPCR_SETDCD            0x00
464
465 #define IOPCR_SETSIGS           (IOPCR_SETRTS | IOPCR_SETRTS | IOPCR_SETDTR | IOPCR_SETDCD)
466
467 /*****************************************************************************/
468
469 /*
470  *      General purpose output select register.
471  */
472 #define GPORS_TXC1XA            0x08
473 #define GPORS_TXC16XA           0x09
474 #define GPORS_RXC16XA           0x0a
475 #define GPORS_TXC16XB           0x0b
476 #define GPORS_GPOR3             0x0c
477 #define GPORS_GPOR2             0x0d
478 #define GPORS_GPOR1             0x0e
479 #define GPORS_GPOR0             0x0f
480
481 /*****************************************************************************/
482
483 /*
484  *      General purpose output register.
485  */
486 #define GPOR_0                  0x01
487 #define GPOR_1                  0x02
488 #define GPOR_2                  0x04
489 #define GPOR_3                  0x08
490
491 /*****************************************************************************/
492
493 /*
494  *      General purpose output clock register.
495  */
496 #define GPORC_0NONE             0x00
497 #define GPORC_0GIN0             0x01
498 #define GPORC_0GIN1             0x02
499 #define GPORC_0IO3A             0x02
500
501 #define GPORC_1NONE             0x00
502 #define GPORC_1GIN0             0x04
503 #define GPORC_1GIN1             0x08
504 #define GPORC_1IO3C             0x0c
505
506 #define GPORC_2NONE             0x00
507 #define GPORC_2GIN0             0x10
508 #define GPORC_2GIN1             0x20
509 #define GPORC_2IO3E             0x20
510
511 #define GPORC_3NONE             0x00
512 #define GPORC_3GIN0             0x40
513 #define GPORC_3GIN1             0x80
514 #define GPORC_3IO3G             0xc0
515
516 /*****************************************************************************/
517
518 /*
519  *      General purpose output data register.
520  */
521 #define GPOD_0MASK              0x03
522 #define GPOD_0SET1              0x00
523 #define GPOD_0SET0              0x01
524 #define GPOD_0SETR0             0x02
525 #define GPOD_0SETIO3B           0x03
526
527 #define GPOD_1MASK              0x0c
528 #define GPOD_1SET1              0x00
529 #define GPOD_1SET0              0x04
530 #define GPOD_1SETR0             0x08
531 #define GPOD_1SETIO3D           0x0c
532
533 #define GPOD_2MASK              0x30
534 #define GPOD_2SET1              0x00
535 #define GPOD_2SET0              0x10
536 #define GPOD_2SETR0             0x20
537 #define GPOD_2SETIO3F           0x30
538
539 #define GPOD_3MASK              0xc0
540 #define GPOD_3SET1              0x00
541 #define GPOD_3SET0              0x40
542 #define GPOD_3SETR0             0x80
543 #define GPOD_3SETIO3H           0xc0
544
545 /*****************************************************************************/
546 #endif