1 /* $NetBSD: magmareg.h,v 1.7 2003/02/22 05:11:16 tsutsui Exp $ */
2 /* magmareg.h
3 *
4 * Copyright (c) 1998 Iain Hibbert
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Iain Hibbert
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
34 #ifdef MAGMA_DEBUG
35 #define dprintf(x) printf x
36 #else
37 #define dprintf(x)
38 #endif
39
40 /* The mapping of minor device number -> card and port is done as
41 * follows by default:
42 *
43 * +---+---+---+---+---+---+---+---+
44 * | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
45 * +---+---+---+---+---+---+---+---+
46 * | | | | | | | |
47 * | | | | +---+---+---+---> port number
48 * | | | |
49 * | | | +-------------------> dialout (on tty ports)
50 * | | |
51 * | | +-----------------------> unused
52 * | |
53 * +---+---------------------------> card number
54 *
55 */
56
57 #define MAGMA_MAX_CARDS 4
58 #define MAGMA_MAX_TTY 16
59 #define MAGMA_MAX_BPP 2
60 #define MAGMA_MAX_CD1400 4
61 #define MAGMA_MAX_CD1190 2
62
63 #define MAGMA_CARD(x) ((minor(x) >> 6) & 0x03)
64 #define MAGMA_PORT(x) (minor(x) & 0x0f)
65
66 #define MTTY_DIALOUT(x) (minor(x) & 0x10)
67
68 /*
69 * Supported Card Types
70 */
71 struct magma_board_info {
72 const char *mb_sbusname; /* sbus_attach_args.sa_name */
73 const char *mb_name; /* cardname to match against */
74 const char *mb_realname; /* english card name */
75 int mb_nser; /* number of serial ports */
76 int mb_npar; /* number of parallel ports */
77 int mb_ncd1400; /* number of CD1400 chips */
78 int mb_svcackr; /* svcackr offset */
79 int mb_svcackt; /* svcackt offset */
80 int mb_svcackm; /* svcackm offset */
81 int mb_cd1400[MAGMA_MAX_CD1400];/* cd1400 chip register offsets */
82 int mb_ncd1190; /* number of CD1190 chips */
83 int mb_cd1190[MAGMA_MAX_CD1190];/* cd1190 chip register offsets */
84 };
85
86 /*
87 * cd1400 chip data
88 */
89 struct cd1400 {
90 __volatile u_char *cd_reg; /* chip registers */
91 int cd_chiprev; /* chip revision */
92 int cd_clock; /* clock speed in MHz */
93 int cd_parmode; /* parallel mode operation */
94 };
95
96 /*
97 * cd1190 chip data
98 */
99 struct cd1190 {
100 __volatile u_char *cd_reg; /* chip registers */
101 int cd_chiprev; /* chip revision */
102 };
103
104 /* software state for each card */
105 struct magma_softc {
106 struct device ms_dev; /* required. must be first in softc */
107 struct sbusdev ms_sd; /* sbus device */
108 struct evcnt ms_intrcnt; /* statistics */
109
110 /* cd1400 chip info */
111 int ms_ncd1400;
112 struct cd1400 ms_cd1400[MAGMA_MAX_CD1400];
113 __volatile u_char *ms_svcackr; /* CD1400 service acknowledge receive */
114 __volatile u_char *ms_svcackt; /* CD1400 service acknowledge transmit */
115 __volatile u_char *ms_svcackm; /* CD1400 service acknowledge modem */
116
117 /* cd1190 chip info */
118 int ms_ncd1190;
119 struct cd1190 ms_cd1190[MAGMA_MAX_CD1190];
120
121 struct magma_board_info *ms_board; /* what am I? */
122
123 struct mtty_softc *ms_mtty;
124 struct mbpp_softc *ms_mbpp;
125
126 /* softintr(9) cookie */
127 void *ms_sicookie;
128 };
129
130 #define MTTY_RBUF_SIZE (2 * 512)
131 #define MTTY_RX_FIFO_THRESHOLD 6
132 #define MTTY_RX_DTR_THRESHOLD 9
133
134 struct mtty_port {
135 struct cd1400 *mp_cd1400; /* ptr to chip */
136 int mp_channel; /* and channel */
137 struct tty *mp_tty;
138
139 int mp_openflags; /* default tty flags */
140 int mp_flags; /* port flags */
141 int mp_carrier; /* state of carrier */
142
143 u_char *mp_rbuf; /* ring buffer start */
144 u_char *mp_rend; /* ring buffer end */
145 u_char *mp_rget; /* ring buffer read pointer */
146 u_char *mp_rput; /* ring buffer write pointer */
147
148 u_char *mp_txp; /* transmit character pointer */
149 int mp_txc; /* transmit character counter */
150 };
151
152 #define MTTYF_CARRIER_CHANGED (1<<0)
153 #define MTTYF_SET_BREAK (1<<1)
154 #define MTTYF_CLR_BREAK (1<<2)
155 #define MTTYF_DONE (1<<3)
156 #define MTTYF_STOP (1<<4)
157 #define MTTYF_RING_OVERFLOW (1<<5)
158
159 struct mtty_softc {
160 struct device ms_dev; /* device info */
161 int ms_nports; /* tty ports */
162 struct mtty_port ms_port[MAGMA_MAX_TTY];
163 };
164
165 #define MBPP_RX_FIFO_THRESHOLD 25
166
167 struct mbpp_port {
168 struct cd1400 *mp_cd1400; /* for LC2+1Sp card */
169 struct cd1190 *mp_cd1190; /* all the others */
170
171 struct callout mp_timeout_ch;
172 struct callout mp_start_ch;
173
174 int mp_flags;
175
176 struct mbpp_param mp_param;
177 #define mp_burst mp_param.bp_burst
178 #define mp_timeout mp_param.bp_timeout
179 #define mp_delay mp_param.bp_delay
180
181 u_char *mp_ptr; /* pointer to I/O data */
182 int mp_cnt; /* count of I/O chars */
183 };
184
185 #define MBPPF_OPEN (1<<0)
186 #define MBPPF_TIMEOUT (1<<1)
187 #define MBPPF_UIO (1<<2)
188 #define MBPPF_DELAY (1<<3)
189 #define MBPPF_WAKEUP (1<<4)
190
191 struct mbpp_softc {
192 struct device ms_dev; /* device info */
193 int ms_nports; /* parallel ports */
194 struct mbpp_port ms_port[MAGMA_MAX_BPP];
195 };
196
197 /*
198 * useful macros
199 */
200 #define SET(t, f) ((t) |= (f))
201 #define CLR(t, f) ((t) &= ~(f))
202 #define ISSET(t, f) ((t) & (f))
203
204 /* internal function prototypes */
205
206 int cd1400_compute_baud __P((speed_t, int, int *, int *));
207 __inline void cd1400_write_ccr __P((struct cd1400 *, u_char));
208 __inline u_char cd1400_read_reg __P((struct cd1400 *, int));
209 __inline void cd1400_write_reg __P((struct cd1400 *, int, u_char));
210 void cd1400_enable_transmitter __P((struct cd1400 *, int));
211
212 int magma_match __P((struct device *, struct cfdata *, void *));
213 void magma_attach __P((struct device *, struct device *, void *));
214 int magma_hard __P((void *));
215 void magma_soft __P((void *));
216
217 int mtty_match __P((struct device *, struct cfdata *, void *));
218 void mtty_attach __P((struct device *, struct device *, void *));
219 int mtty_modem_control __P((struct mtty_port *, int, int));
220 int mtty_param __P((struct tty *, struct termios *));
221 void mtty_start __P((struct tty *));
222
223 int mbpp_match __P((struct device *, struct cfdata *, void *));
224 void mbpp_attach __P((struct device *, struct device *, void *));
225 void mbpp_timeout __P((void *));
226 void mbpp_start __P((void *));
227 int mbpp_send __P((struct mbpp_port *, caddr_t, int));
228 int mbpp_recv __P((struct mbpp_port *, caddr_t, int));
229 int mbpp_hztoms __P((int));
230 int mbpp_mstohz __P((int));
Cache object: e219d2f14539ec926031ca0b925c0ca0
|