1
2
3
4
5 #ifndef _SPARC_SERIAL_H
6 #define _SPARC_SERIAL_H
7
8
9 struct sun_zschannel {
10 volatile unsigned char control;
11 volatile unsigned char pad1;
12 volatile unsigned char data;
13 volatile unsigned char pad2;
14 };
15
16
17
18
19 struct sun_zslayout {
20 struct sun_zschannel channelB;
21 struct sun_zschannel channelA;
22 };
23
24
25
26
27
28 struct l1a_kbd_state {
29 unsigned char kbd_id;
30 unsigned char l1_down;
31 };
32
33 #define NUM_ZSREGS 16
34
35 struct serial_struct {
36 int type;
37 int line;
38 int port;
39 int irq;
40 int flags;
41 int xmit_fifo_size;
42 int custom_divisor;
43 int baud_base;
44 unsigned short close_delay;
45 char reserved_char[2];
46 int hub6;
47 unsigned short closing_wait;
48 unsigned short closing_wait2;
49 int reserved[4];
50 };
51
52
53
54
55
56 #define ZILOG_CLOSING_WAIT_INF 0
57 #define ZILOG_CLOSING_WAIT_NONE 65535
58
59
60
61
62 #define ZILOG_HUP_NOTIFY 0x0001
63
64 #define ZILOG_FOURPORT 0x0002
65 #define ZILOG_SAK 0x0004
66 #define ZILOG_SPLIT_TERMIOS 0x0008
67
68 #define ZILOG_SPD_MASK 0x0030
69 #define ZILOG_SPD_HI 0x0010
70
71 #define ZILOG_SPD_VHI 0x0020
72 #define ZILOG_SPD_CUST 0x0030
73
74 #define ZILOG_SKIP_TEST 0x0040
75 #define ZILOG_AUTO_IRQ 0x0080
76 #define ZILOG_SESSION_LOCKOUT 0x0100
77 #define ZILOG_PGRP_LOCKOUT 0x0200
78 #define ZILOG_CALLOUT_NOHUP 0x0400
79
80 #define ZILOG_FLAGS 0x0FFF
81 #define ZILOG_USR_MASK 0x0430
82
83
84
85 #define ZILOG_INITIALIZED 0x80000000
86 #define ZILOG_CALLOUT_ACTIVE 0x40000000
87 #define ZILOG_NORMAL_ACTIVE 0x20000000
88 #define ZILOG_BOOT_AUTOCONF 0x10000000
89 #define ZILOG_CLOSING 0x08000000
90 #define ZILOG_CTS_FLOW 0x04000000
91 #define ZILOG_CHECK_CD 0x02000000
92
93
94
95 #ifdef __KERNEL__
96
97
98
99
100
101
102
103
104
105 struct sun_serial {
106 struct sun_serial *zs_next;
107 struct sun_zschannel *zs_channel;
108 unsigned char read_reg_zero;
109
110 char soft_carrier;
111 char cons_keyb;
112 char cons_mouse;
113 char break_abort;
114 char kgdb_channel;
115 char is_cons;
116
117
118
119
120
121 unsigned char clk_divisor;
122 int zs_baud;
123
124
125 unsigned char curregs[NUM_ZSREGS];
126
127
128 unsigned char pendregs[NUM_ZSREGS];
129
130 char change_needed;
131
132 int magic;
133 int baud_base;
134 int port;
135 int irq;
136 int flags;
137 int type;
138 struct tty_struct *tty;
139 int read_status_mask;
140 int ignore_status_mask;
141 int timeout;
142 int xmit_fifo_size;
143 int custom_divisor;
144 int x_char;
145 int close_delay;
146 unsigned short closing_wait;
147 unsigned short closing_wait2;
148 unsigned long event;
149 unsigned long last_active;
150 int line;
151 int count;
152 int blocked_open;
153 long session;
154 long pgrp;
155 unsigned char *xmit_buf;
156 int xmit_head;
157 int xmit_tail;
158 int xmit_cnt;
159 struct tq_struct tqueue;
160 struct tq_struct tqueue_hangup;
161 struct termios normal_termios;
162 struct termios callout_termios;
163 struct wait_queue *open_wait;
164 struct wait_queue *close_wait;
165 };
166
167
168 #define SERIAL_MAGIC 0x5301
169
170
171
172
173 #define SERIAL_XMIT_SIZE 4096
174
175
176
177
178
179 #define RS_EVENT_WRITE_WAKEUP 0
180
181 #endif
182
183
184
185
186 #define BRG_TO_BPS(brg, freq) ((freq) / 2 / ((brg) + 2))
187 #define BPS_TO_BRG(bps, freq) ((((freq) + (bps)) / (2 * (bps))) - 2)
188
189
190
191 #define FLAG 0x7e
192
193
194 #define R0 0
195 #define R1 1
196 #define R2 2
197 #define R3 3
198 #define R4 4
199 #define R5 5
200 #define R6 6
201 #define R7 7
202 #define R8 8
203 #define R9 9
204 #define R10 10
205 #define R11 11
206 #define R12 12
207 #define R13 13
208 #define R14 14
209 #define R15 15
210
211 #define NULLCODE 0
212 #define POINT_HIGH 0x8
213 #define RES_EXT_INT 0x10
214 #define SEND_ABORT 0x18
215 #define RES_RxINT_FC 0x20
216 #define RES_Tx_P 0x28
217 #define ERR_RES 0x30
218 #define RES_H_IUS 0x38
219
220 #define RES_Rx_CRC 0x40
221 #define RES_Tx_CRC 0x80
222 #define RES_EOM_L 0xC0
223
224
225
226 #define EXT_INT_ENAB 0x1
227 #define TxINT_ENAB 0x2
228 #define PAR_SPEC 0x4
229
230 #define RxINT_DISAB 0
231 #define RxINT_FCERR 0x8
232 #define INT_ALL_Rx 0x10
233 #define INT_ERR_Rx 0x18
234
235 #define WT_RDY_RT 0x20
236 #define WT_FN_RDYFN 0x40
237 #define WT_RDY_ENAB 0x80
238
239
240
241
242
243 #define RxENABLE 0x1
244 #define SYNC_L_INH 0x2
245 #define ADD_SM 0x4
246 #define RxCRC_ENAB 0x8
247 #define ENT_HM 0x10
248 #define AUTO_ENAB 0x20
249 #define Rx5 0x0
250 #define Rx7 0x40
251 #define Rx6 0x80
252 #define Rx8 0xc0
253
254
255
256 #define PAR_ENA 0x1
257 #define PAR_EVEN 0x2
258
259 #define SYNC_ENAB 0
260 #define SB1 0x4
261 #define SB15 0x8
262 #define SB2 0xc
263
264 #define MONSYNC 0
265 #define BISYNC 0x10
266 #define SDLC 0x20
267 #define EXTSYNC 0x30
268
269 #define X1CLK 0x0
270 #define X16CLK 0x40
271 #define X32CLK 0x80
272 #define X64CLK 0xC0
273
274
275
276 #define TxCRC_ENAB 0x1
277 #define RTS 0x2
278 #define SDLC_CRC 0x4
279 #define TxENAB 0x8
280 #define SND_BRK 0x10
281 #define Tx5 0x0
282 #define Tx7 0x20
283 #define Tx6 0x40
284 #define Tx8 0x60
285 #define DTR 0x80
286
287
288
289
290
291
292
293
294 #define VIS 1
295 #define NV 2
296 #define DLC 4
297 #define MIE 8
298 #define STATHI 0x10
299 #define NORESET 0
300 #define CHRB 0x40
301 #define CHRA 0x80
302 #define FHWRES 0xc0
303
304
305 #define BIT6 1
306 #define LOOPMODE 2
307 #define ABUNDER 4
308 #define MARKIDLE 8
309 #define GAOP 0x10
310 #define NRZ 0
311 #define NRZI 0x20
312 #define FM1 0x40
313 #define FM0 0x60
314 #define CRCPS 0x80
315
316
317 #define TRxCXT 0
318 #define TRxCTC 1
319 #define TRxCBR 2
320 #define TRxCDP 3
321 #define TRxCOI 4
322 #define TCRTxCP 0
323 #define TCTRxCP 8
324 #define TCBR 0x10
325 #define TCDPLL 0x18
326 #define RCRTxCP 0
327 #define RCTRxCP 0x20
328 #define RCBR 0x40
329 #define RCDPLL 0x60
330 #define RTxCX 0x80
331
332
333
334
335
336
337 #define BRENABL 1
338 #define BRSRC 2
339 #define DTRREQ 4
340 #define AUTOECHO 8
341 #define LOOPBAK 0x10
342 #define SEARCH 0x20
343 #define RMC 0x40
344 #define DISDPLL 0x60
345 #define SSBR 0x80
346 #define SSRTxC 0xa0
347 #define SFMM 0xc0
348 #define SNRZI 0xe0
349
350
351 #define ZCIE 2
352 #define DCDIE 8
353 #define SYNCIE 0x10
354 #define CTSIE 0x20
355 #define TxUIE 0x40
356 #define BRKIE 0x80
357
358
359
360 #define Rx_CH_AV 0x1
361 #define ZCOUNT 0x2
362 #define Tx_BUF_EMP 0x4
363 #define DCD 0x8
364 #define SYNC_HUNT 0x10
365 #define CTS 0x20
366 #define TxEOM 0x40
367 #define BRK_ABRT 0x80
368
369
370 #define ALL_SNT 0x1
371
372 #define RES3 0x8
373 #define RES4 0x4
374 #define RES5 0xc
375 #define RES6 0x2
376 #define RES7 0xa
377 #define RES8 0x6
378 #define RES18 0xe
379 #define RES28 0x0
380
381 #define PAR_ERR 0x10
382 #define Rx_OVR 0x20
383 #define CRC_ERR 0x40
384 #define END_FR 0x80
385
386
387
388
389 #define CHBEXT 0x1
390 #define CHBTxIP 0x2
391 #define CHBRxIP 0x4
392 #define CHAEXT 0x8
393 #define CHATxIP 0x10
394 #define CHARxIP 0x20
395
396
397
398
399 #define ONLOOP 2
400 #define LOOPSEND 0x10
401 #define CLK2MIS 0x40
402 #define CLK1MIS 0x80
403
404
405
406
407
408
409
410
411 #define ZS_CLEARERR(channel) (channel->control = ERR_RES)
412 #define ZS_CLEARFIFO(channel) do { volatile unsigned char garbage; \
413 garbage = channel->data; \
414 udelay(2); \
415 garbage = channel->data; \
416 udelay(2); \
417 garbage = channel->data; \
418 udelay(2); } while(0)
419
420 #endif