1 /* $NetBSD: scnvar.h,v 1.6 2006/05/12 06:05:22 simonb Exp $ */
4 * Copyright (c) 1996, 1997 Philip L. Budne.
5 * Copyright (c) 1993 Philip A. Nelson.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Philip A. Nelson.
19 * 4. The name of Philip A. Nelson may not be used to endorse or promote
20 * products derived from this software without specific prior written
23 * THIS SOFTWARE IS PROVIDED BY PHILIP NELSON ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL PHILIP NELSON BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 * scnvar.h: definitions for pc532 2681/2692/26c96 duart driver
40 #define TTYDEF_SPEED COMDEF_SPEED /* default baud rate */
43 #define SCN_SIZE 0x8 /* address space for port */
45 #define SCN_CONSOLE 0 /* minor number of console */
46 #define SCN_CONSDUART 0
47 #define SCN_CONSCHAN 0
49 /* output port bits */
50 #define OP_RTSA OP_OP0
51 #define OP_RTSB OP_OP1
52 #define OP_DTRA OP_OP2
53 #define OP_DTRB OP_OP3
54 /* OP4-7 not connected */
57 #define IP_CTSA IP_IP0
58 #define IP_CTSB IP_IP1
59 #define IP_DCDB IP_IP2
60 #define IP_DCDA IP_IP3
61 /* IP4-6 not connected */
63 #define ACR_DELTA_CTSA ACR_DELTA_IP0
64 #define ACR_DELTA_CTSB ACR_DELTA_IP1
65 #define ACR_DELTA_DCDB ACR_DELTA_IP2
66 #define ACR_DELTA_DCDA ACR_DELTA_IP3
68 #define IPCR_CTSA IPCR_IP0
69 #define IPCR_CTSB IPCR_IP1
70 #define IPCR_DCDB IPCR_IP2
71 #define IPCR_DCDA IPCR_IP3
72 #define IPCR_DELTA_CTSA IPCR_DELTA_IP0
73 #define IPCR_DELTA_CTSB IPCR_DELTA_IP1
74 #define IPCR_DELTA_DCDB IPCR_DELTA_IP2
75 #define IPCR_DELTA_DCDA IPCR_DELTA_IP3
77 #define SCN_OP_BIS(SC,VAL) ((SC)->sc_duart->base[DU_OPSET] = (VAL))
78 #define SCN_OP_BIC(SC,VAL) ((SC)->sc_duart->base[DU_OPCLR] = (VAL))
80 #define SCN_DCD(SC) (((SC)->sc_duart->base[DU_IP] & (SC)->sc_ip_dcd) == 0)
82 /* pc532 duarts are auto-sized to byte-wide */
85 #define SCN_REG(n) (n << 4) /* 15 byte pad after each reg */
87 /* The DUART description struct; for data common to both channels */
89 volatile u_char
*base
;
93 int32_t ispeed
, ospeed
;
95 u_char mr0
; /* MR0[7:3] */
96 u_char new_mr1
; /* held changes */
97 u_char new_mr2
; /* held changes */
99 enum scntype
{ SCNUNK
, SCN2681
, SCN2692
, SC26C92
} type
;
100 uint16_t counter
; /* C/T generated bps, or zero */
101 uint16_t ocounter
; /* last C/T generated bps, or zero */
102 u_char mode
; /* ACR[7] + MR0[2:0] */
103 u_char acr
; /* ACR[6:0]*/
104 u_char imr
; /* IMR bits */
105 u_char opcr
; /* OPCR bits */
108 #define SCN_RING_BITS 9 /* 512 byte buffers */
109 #define SCN_RING_SIZE (1<<SCN_RING_BITS) /* must be a power of two */
110 #define SCN_RING_MASK (SCN_RING_SIZE-1)
111 #define SCN_RING_THRESH (SCN_RING_SIZE/2)
112 #define SCN_RING_HIWAT (SCN_RING_SIZE - (SCN_RING_SIZE >> 2))
114 /* scn channel state */
116 struct device sc_dev
;
118 int sc_unit
; /* unit number of this line (base 0) */
122 struct duart
*sc_duart
; /* pointer to duart struct */
123 volatile u_char
*sc_chbase
; /* per-channel registers (CH_xxx) */
124 u_char sc_swflags
; /* from config / TIOCxFLAGS */
125 #define SCN_SW_SOFTCAR 0x01
126 #define SCN_SW_CLOCAL 0x02
127 #define SCN_SW_CRTSCTS 0x04
128 #define SCN_SW_MDMBUF 0x08 /* not implemented */
130 /* I wish there was a TS_DIALOUT flag! */
131 u_char sc_dialout
; /* set if open for dialout */
132 #define SCN_DIALOUT(SCN) ((SCN)->sc_dialout)
133 #define SCN_SETDIALOUT(SCN) (SCN)->sc_dialout = 1
134 #define SCN_CLRDIALOUT(SCN) (SCN)->sc_dialout = 0
136 u_char sc_heldchanges
; /* waiting for output done */
138 /* bits in input port register */
142 /* bits in output port registers */
146 /* interrupt mask bits */
151 u_long sc_framing_errors
;
152 u_long sc_parity_errors
;
153 u_long sc_fifo_overruns
;
156 /* ring buffer for rxrdy interrupt */
157 u_int sc_rbget
; /* ring buffer `get' index */
158 volatile u_int sc_rbput
; /* ring buffer `put' index */
160 short sc_rbuf
[SCN_RING_SIZE
]; /* status + data */
161 long sc_fotime
; /* last fifo overrun message */
162 long sc_rotime
; /* last ring overrun message */
163 u_long sc_ring_overruns
; /* number of ring buffer overruns */
164 /* Flags to communicate with scntty_softint() */
165 volatile char sc_rx_blocked
; /* input block at ring */