1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 #ifdef MAGMA_DEBUG
36 #define dprintf(x) printf x
37 #else
38 #define dprintf(x)
39 #endif
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58 #define MAGMA_MAX_CARDS 4
59 #define MAGMA_MAX_TTY 16
60 #define MAGMA_MAX_BPP 2
61 #define MAGMA_MAX_CD1400 4
62 #define MAGMA_MAX_CD1190 2
63
64 #define MAGMA_CARD(x) ((minor(x) >> 6) & 0x03)
65 #define MAGMA_PORT(x) (minor(x) & 0x0f)
66
67 #define MTTY_DIALOUT(x) (minor(x) & 0x10)
68
69
70
71
72 struct magma_board_info {
73 const char *mb_sbusname;
74 const char *mb_name;
75 const char *mb_realname;
76 int mb_nser;
77 int mb_npar;
78 int mb_ncd1400;
79 int mb_svcackr;
80 int mb_svcackt;
81 int mb_svcackm;
82 int mb_cd1400[MAGMA_MAX_CD1400];
83 int mb_ncd1190;
84 int mb_cd1190[MAGMA_MAX_CD1190];
85 };
86
87
88
89
90 struct cd1400 {
91 bus_space_handle_t cd_regh;
92 bus_space_tag_t cd_regt;
93 int cd_chiprev;
94 int cd_clock;
95 int cd_parmode;
96 };
97
98
99
100
101 struct cd1190 {
102 bus_space_handle_t cd_regh;
103 bus_space_tag_t cd_regt;
104 int cd_chiprev;
105 };
106
107
108 struct magma_softc {
109 struct device ms_dev;
110
111 bus_space_tag_t sc_bustag;
112 bus_space_handle_t sc_iohandle;
113 void *sc_ih;
114 void *sc_sih;
115
116
117 int ms_ncd1400;
118 struct cd1400 ms_cd1400[MAGMA_MAX_CD1400];
119 bus_space_handle_t sc_svcackrh;
120 bus_space_handle_t sc_svcackth;
121 bus_space_handle_t sc_svcackmh;
122
123
124
125 int ms_ncd1190;
126 struct cd1190 ms_cd1190[MAGMA_MAX_CD1190];
127
128 const struct magma_board_info *ms_board;
129
130 struct mtty_softc *ms_mtty;
131 struct mbpp_softc *ms_mbpp;
132
133 struct intrhand ms_hardint;
134 struct intrhand ms_softint;
135 };
136
137 #define MTTY_RBUF_SIZE (2 * 512)
138 #define MTTY_RX_FIFO_THRESHOLD 6
139 #define MTTY_RX_DTR_THRESHOLD 9
140
141 struct mtty_port {
142 struct cd1400 *mp_cd1400;
143 int mp_channel;
144 struct tty *mp_tty;
145
146 int mp_openflags;
147 int mp_flags;
148 int mp_carrier;
149
150 u_char *mp_rbuf;
151 u_char *mp_rend;
152 u_char *mp_rget;
153 u_char *mp_rput;
154
155 u_char *mp_txp;
156 int mp_txc;
157 };
158
159 #define MTTYF_CARRIER_CHANGED (1<<0)
160 #define MTTYF_SET_BREAK (1<<1)
161 #define MTTYF_CLR_BREAK (1<<2)
162 #define MTTYF_DONE (1<<3)
163 #define MTTYF_STOP (1<<4)
164 #define MTTYF_RING_OVERFLOW (1<<5)
165
166 struct mtty_softc {
167 struct device ms_dev;
168 int ms_nports;
169 struct mtty_port ms_port[MAGMA_MAX_TTY];
170 };
171
172 #define MBPP_RX_FIFO_THRESHOLD 25
173
174 struct mbpp_port {
175 struct cd1400 *mp_cd1400;
176 struct cd1190 *mp_cd1190;
177
178 int mp_flags;
179
180 struct bpp_param mp_param;
181 #define mp_burst mp_param.bp_burst
182 #define mp_timeout mp_param.bp_timeout
183 #define mp_delay mp_param.bp_delay
184
185 u_char *mp_ptr;
186 int mp_cnt;
187
188 struct timeout mp_timeout_tmo;
189 struct timeout mp_start_tmo;
190 };
191
192 #define MBPPF_OPEN (1<<0)
193 #define MBPPF_TIMEOUT (1<<1)
194 #define MBPPF_UIO (1<<2)
195 #define MBPPF_DELAY (1<<3)
196 #define MBPPF_WAKEUP (1<<4)
197
198 struct mbpp_softc {
199 struct device ms_dev;
200 int ms_nports;
201 struct mbpp_port ms_port[MAGMA_MAX_BPP];
202 };
203
204
205
206 int cd1400_compute_baud(speed_t, int, int *, int *);
207 __inline void cd1400_write_ccr(struct cd1400 *, u_char);
208 __inline u_char cd1400_read_reg(struct cd1400 *, int);
209 __inline void cd1400_write_reg(struct cd1400 *, int, u_char);
210 void cd1400_enable_transmitter(struct cd1400 *, int);
211
212 int magma_match(struct device *, void *, void *);
213 void magma_attach(struct device *, struct device *, void *);
214 int magma_hard(void *);
215 void magma_soft(void *);
216
217 int mtty_match(struct device *, void *, void *);
218 void mtty_attach(struct device *, struct device *, void *);
219 int mtty_modem_control(struct mtty_port *, int, int);
220 int mtty_param(struct tty *, struct termios *);
221 void mtty_start(struct tty *);
222
223 int mbpp_match(struct device *, void *, void *);
224 void mbpp_attach(struct device *, struct device *, void *);
225 int mbpp_rw(dev_t, struct uio *);
226 void mbpp_timeout(void *);
227 void mbpp_start(void *);
228 int mbpp_send(struct mbpp_port *, caddr_t, int);
229 int mbpp_recv(struct mbpp_port *, caddr_t, int);
230 int mbpp_hztoms(int);
231 int mbpp_mstohz(int);
232
233 #define CD1400_REGMAPSIZE 0x80
234 #define CD1190_REGMAPSIZE 0x20