Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / arch / sgimips / dev / scnvar.h
blobba4c18ebc0b581c07cb364b1a42929f8d28b032f
1 /* $NetBSD: scnvar.h,v 1.6 2006/05/12 06:05:22 simonb Exp $ */
3 /*
4 * Copyright (c) 1996, 1997 Philip L. Budne.
5 * Copyright (c) 1993 Philip A. Nelson.
6 * All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
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
21 * permission.
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
37 /* Constants. */
38 #ifdef COMDEF_SPEED
39 #undef TTYDEF_SPEED
40 #define TTYDEF_SPEED COMDEF_SPEED /* default baud rate */
41 #endif
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 */
56 /* input port bits */
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 */
83 #define CH_SZ 8
84 #define DUART_SZ 16
85 #define SCN_REG(n) (n << 4) /* 15 byte pad after each reg */
87 /* The DUART description struct; for data common to both channels */
88 struct duart {
89 volatile u_char *base;
90 struct chan {
91 struct scn_softc *sc;
92 struct tty *tty;
93 int32_t ispeed, ospeed;
94 u_char icode, ocode;
95 u_char mr0; /* MR0[7:3] */
96 u_char new_mr1; /* held changes */
97 u_char new_mr2; /* held changes */
98 } chan[2];
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 */
115 struct scn_softc {
116 struct device sc_dev;
117 struct tty *sc_tty;
118 int sc_unit; /* unit number of this line (base 0) */
119 int sc_channel;
120 int sc_isconsole;
121 int sc_iskgdb;
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 */
139 u_char sc_ip_dcd;
140 u_char sc_ip_cts;
142 /* bits in output port registers */
143 u_char sc_op_rts;
144 u_char sc_op_dtr;
146 /* interrupt mask bits */
147 u_char sc_tx_int;
148 u_char sc_rx_int;
150 /* counters */
151 u_long sc_framing_errors;
152 u_long sc_parity_errors;
153 u_long sc_fifo_overruns;
154 u_long sc_breaks;
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 */
159 int sc_rbhiwat;
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 */