This source file includes following definitions.
- zs_break
- zs_getspeed
- zs_iflush
- zs_loadchannelregs
- zsc_intr_hard
- zsc_intr_soft
- zsnull_intr
- zsnull_softint
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 #include <sys/param.h>
53 #include <sys/systm.h>
54 #include <sys/proc.h>
55 #include <sys/device.h>
56 #include <sys/conf.h>
57 #include <sys/file.h>
58 #include <sys/ioctl.h>
59 #include <sys/tty.h>
60 #include <sys/time.h>
61 #include <sys/kernel.h>
62 #include <sys/syslog.h>
63
64 #include <dev/ic/z8530reg.h>
65 #include <machine/z8530var.h>
66
67 static void zsnull_intr(struct zs_chanstate *);
68 static void zsnull_softint(struct zs_chanstate *);
69
70 void
71 zs_break(cs, set)
72 struct zs_chanstate *cs;
73 int set;
74 {
75 int s;
76
77 s = splzs();
78 if (set) {
79 cs->cs_preg[5] |= ZSWR5_BREAK;
80 cs->cs_creg[5] |= ZSWR5_BREAK;
81 } else {
82 cs->cs_preg[5] &= ~ZSWR5_BREAK;
83 cs->cs_creg[5] &= ~ZSWR5_BREAK;
84 }
85 zs_write_reg(cs, 5, cs->cs_creg[5]);
86 splx(s);
87 }
88
89
90
91
92
93 int
94 zs_getspeed(cs)
95 struct zs_chanstate *cs;
96 {
97 int tconst;
98
99 tconst = zs_read_reg(cs, 12);
100 tconst |= zs_read_reg(cs, 13) << 8;
101 return (TCONST_TO_BPS(cs->cs_brg_clk, tconst));
102 }
103
104
105
106
107 void
108 zs_iflush(cs)
109 struct zs_chanstate *cs;
110 {
111 u_char c, rr0, rr1;
112
113 for (;;) {
114
115 rr0 = zs_read_csr(cs);
116 if ((rr0 & ZSRR0_RX_READY) == 0)
117 break;
118
119
120
121
122
123 rr1 = zs_read_reg(cs, 1);
124 c = zs_read_data(cs);
125
126 if (rr1 & (ZSRR1_FE | ZSRR1_DO | ZSRR1_PE)) {
127
128 zs_write_csr(cs, ZSWR0_RESET_ERRORS);
129 }
130 }
131 }
132
133
134
135
136
137
138
139
140 void
141 zs_loadchannelregs(cs)
142 struct zs_chanstate *cs;
143 {
144 u_char *reg;
145
146
147 bcopy((caddr_t)cs->cs_preg, (caddr_t)cs->cs_creg, 16);
148 reg = cs->cs_creg;
149
150 zs_write_csr(cs, ZSM_RESET_ERR);
151
152 #if 1
153
154
155
156
157 zs_iflush(cs);
158 #endif
159
160
161 zs_write_reg(cs, 4, reg[4]);
162
163
164 zs_write_reg(cs, 10, reg[10]);
165
166
167 zs_write_reg(cs, 3, reg[3] & ~ZSWR3_RX_ENABLE);
168 zs_write_reg(cs, 5, reg[5] & ~ZSWR5_TX_ENABLE);
169
170
171 zs_write_reg(cs, 1, reg[1]);
172
173 #if 0
174
175
176
177
178
179
180
181
182 zs_write_reg(cs, 2, reg[2]);
183
184 zs_write_reg(cs, 9, reg[9]);
185 #endif
186
187
188 zs_write_reg(cs, 11, reg[11]);
189
190
191 zs_write_reg(cs, 12, reg[12]);
192 zs_write_reg(cs, 13, reg[13]);
193
194
195 zs_write_reg(cs, 14, reg[14]);
196
197
198 zs_write_reg(cs, 15, reg[15]);
199
200
201 zs_write_reg(cs, 3, reg[3]);
202 zs_write_reg(cs, 5, reg[5]);
203 }
204
205
206
207
208
209
210
211
212
213
214
215
216
217 int
218 zsc_intr_hard(arg)
219 void *arg;
220 {
221 register struct zsc_softc *zsc = arg;
222 register struct zs_chanstate *cs_a;
223 register struct zs_chanstate *cs_b;
224 register int rval;
225 register u_char rr3;
226
227 cs_a = &zsc->zsc_cs[0];
228 cs_b = &zsc->zsc_cs[1];
229 rval = 0;
230
231
232 rr3 = zs_read_reg(cs_a, 3);
233
234
235 if (rr3 & ZSRR3_IP_A_RX)
236 (*cs_a->cs_ops->zsop_rxint)(cs_a);
237 if (rr3 & ZSRR3_IP_B_RX)
238 (*cs_b->cs_ops->zsop_rxint)(cs_b);
239
240
241 if (rr3 & ZSRR3_IP_A_STAT)
242 (*cs_a->cs_ops->zsop_stint)(cs_a);
243 if (rr3 & ZSRR3_IP_B_STAT)
244 (*cs_b->cs_ops->zsop_stint)(cs_b);
245
246
247 if (rr3 & ZSRR3_IP_A_TX)
248 (*cs_a->cs_ops->zsop_txint)(cs_a);
249 if (rr3 & ZSRR3_IP_B_TX)
250 (*cs_b->cs_ops->zsop_txint)(cs_b);
251
252
253 if (rr3 & (ZSRR3_IP_A_RX | ZSRR3_IP_A_TX | ZSRR3_IP_A_STAT)) {
254 zs_write_csr(cs_a, ZSWR0_CLR_INTR);
255 rval |= 1;
256 }
257 if (rr3 & (ZSRR3_IP_B_RX | ZSRR3_IP_B_TX | ZSRR3_IP_B_STAT)) {
258 zs_write_csr(cs_b, ZSWR0_CLR_INTR);
259 rval |= 2;
260 }
261
262 if ((cs_a->cs_softreq) || (cs_b->cs_softreq)) {
263
264 zsc_req_softint(zsc);
265 }
266
267 return (rval);
268 }
269
270
271
272
273
274 int
275 zsc_intr_soft(arg)
276 void *arg;
277 {
278 register struct zsc_softc *zsc = arg;
279 register struct zs_chanstate *cs;
280 register int rval, unit;
281
282 rval = 0;
283 for (unit = 0; unit < 2; unit++) {
284 cs = &zsc->zsc_cs[unit];
285
286
287
288
289
290
291 if (cs->cs_softreq) {
292 cs->cs_softreq = 0;
293 (*cs->cs_ops->zsop_softint)(cs);
294 rval = 1;
295 }
296 }
297 return (rval);
298 }
299
300
301 static void
302 zsnull_intr(cs)
303 struct zs_chanstate *cs;
304 {
305 zs_write_reg(cs, 1, 0);
306 zs_write_reg(cs, 15, 0);
307 }
308
309 static void
310 zsnull_softint(cs)
311 struct zs_chanstate *cs;
312 {
313 }
314
315 struct zsops zsops_null = {
316 zsnull_intr,
317 zsnull_intr,
318 zsnull_intr,
319 zsnull_softint,
320 };