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