1
2
3
4
5
6
7
8#ifndef _Z8530_H
9#define _Z8530_H
10
11#include <linux/tty.h>
12#include <linux/interrupt.h>
13
14
15
16
17#define BRG_TO_BPS(brg, freq) ((freq) / 2 / ((brg) + 2))
18#define BPS_TO_BRG(bps, freq) ((((freq) + (bps)) / (2 * (bps))) - 2)
19
20
21
22#define FLAG 0x7e
23
24
25#define R0 0
26#define R1 1
27#define R2 2
28#define R3 3
29#define R4 4
30#define R5 5
31#define R6 6
32#define R7 7
33#define R8 8
34#define R9 9
35#define R10 10
36#define R11 11
37#define R12 12
38#define R13 13
39#define R14 14
40#define R15 15
41
42#define RPRIME 16
43
44#define NULLCODE 0
45#define POINT_HIGH 0x8
46#define RES_EXT_INT 0x10
47#define SEND_ABORT 0x18
48#define RES_RxINT_FC 0x20
49#define RES_Tx_P 0x28
50#define ERR_RES 0x30
51#define RES_H_IUS 0x38
52
53#define RES_Rx_CRC 0x40
54#define RES_Tx_CRC 0x80
55#define RES_EOM_L 0xC0
56
57
58
59#define EXT_INT_ENAB 0x1
60#define TxINT_ENAB 0x2
61#define PAR_SPEC 0x4
62
63#define RxINT_DISAB 0
64#define RxINT_FCERR 0x8
65#define INT_ALL_Rx 0x10
66#define INT_ERR_Rx 0x18
67
68#define WT_RDY_RT 0x20
69#define WT_FN_RDYFN 0x40
70#define WT_RDY_ENAB 0x80
71
72
73
74
75
76#define RxENABLE 0x1
77#define SYNC_L_INH 0x2
78#define ADD_SM 0x4
79#define RxCRC_ENAB 0x8
80#define ENT_HM 0x10
81#define AUTO_ENAB 0x20
82#define Rx5 0x0
83#define Rx7 0x40
84#define Rx6 0x80
85#define Rx8 0xc0
86
87
88
89#define PAR_ENA 0x1
90#define PAR_EVEN 0x2
91
92#define SYNC_ENAB 0
93#define SB1 0x4
94#define SB15 0x8
95#define SB2 0xc
96
97#define MONSYNC 0
98#define BISYNC 0x10
99#define SDLC 0x20
100#define EXTSYNC 0x30
101
102#define X1CLK 0x0
103#define X16CLK 0x40
104#define X32CLK 0x80
105#define X64CLK 0xC0
106
107
108
109#define TxCRC_ENAB 0x1
110#define RTS 0x2
111#define SDLC_CRC 0x4
112#define TxENAB 0x8
113#define SND_BRK 0x10
114#define Tx5 0x0
115#define Tx7 0x20
116#define Tx6 0x40
117#define Tx8 0x60
118#define DTR 0x80
119
120
121
122
123
124
125
126
127#define VIS 1
128#define NV 2
129#define DLC 4
130#define MIE 8
131#define STATHI 0x10
132#define NORESET 0
133#define CHRB 0x40
134#define CHRA 0x80
135#define FHWRES 0xc0
136
137
138#define BIT6 1
139#define LOOPMODE 2
140#define ABUNDER 4
141#define MARKIDLE 8
142#define GAOP 0x10
143#define NRZ 0
144#define NRZI 0x20
145#define FM1 0x40
146#define FM0 0x60
147#define CRCPS 0x80
148
149
150#define TRxCXT 0
151#define TRxCTC 1
152#define TRxCBR 2
153#define TRxCDP 3
154#define TRxCOI 4
155#define TCRTxCP 0
156#define TCTRxCP 8
157#define TCBR 0x10
158#define TCDPLL 0x18
159#define RCRTxCP 0
160#define RCTRxCP 0x20
161#define RCBR 0x40
162#define RCDPLL 0x60
163#define RTxCX 0x80
164
165
166
167
168
169
170#define BRENABL 1
171#define BRSRC 2
172#define DTRREQ 4
173#define AUTOECHO 8
174#define LOOPBAK 0x10
175#define SEARCH 0x20
176#define RMC 0x40
177#define DISDPLL 0x60
178#define SSBR 0x80
179#define SSRTxC 0xa0
180#define SFMM 0xc0
181#define SNRZI 0xe0
182
183
184#define PRIME 1
185#define ZCIE 2
186#define FIFOE 4
187#define DCDIE 8
188#define SYNCIE 0x10
189#define CTSIE 0x20
190#define TxUIE 0x40
191#define BRKIE 0x80
192
193
194
195#define Rx_CH_AV 0x1
196#define ZCOUNT 0x2
197#define Tx_BUF_EMP 0x4
198#define DCD 0x8
199#define SYNC_HUNT 0x10
200#define CTS 0x20
201#define TxEOM 0x40
202#define BRK_ABRT 0x80
203
204
205#define ALL_SNT 0x1
206
207#define RES3 0x8
208#define RES4 0x4
209#define RES5 0xc
210#define RES6 0x2
211#define RES7 0xa
212#define RES8 0x6
213#define RES18 0xe
214#define RES28 0x0
215
216#define PAR_ERR 0x10
217#define Rx_OVR 0x20
218#define CRC_ERR 0x40
219#define END_FR 0x80
220
221
222
223
224#define CHBEXT 0x1
225#define CHBTxIP 0x2
226#define CHBRxIP 0x4
227#define CHAEXT 0x8
228#define CHATxIP 0x10
229#define CHARxIP 0x20
230
231
232
233
234#define ONLOOP 2
235#define LOOPSEND 0x10
236#define CLK2MIS 0x40
237#define CLK1MIS 0x80
238
239
240
241
242
243
244
245
246
247
248
249
250struct z8530_channel;
251
252struct z8530_irqhandler
253{
254 void (*rx)(struct z8530_channel *);
255 void (*tx)(struct z8530_channel *);
256 void (*status)(struct z8530_channel *);
257};
258
259
260
261
262
263struct z8530_channel
264{
265 struct z8530_irqhandler *irqs;
266
267
268
269 u16 count;
270 u16 max;
271 u16 mtu;
272 u8 *dptr;
273 struct sk_buff *skb;
274 struct sk_buff *skb2;
275 u8 status;
276 u8 dcdcheck;
277 u8 sync;
278
279 u8 regs[32];
280 u8 pendregs[32];
281
282 struct sk_buff *tx_skb;
283 struct sk_buff *tx_next_skb;
284 u8 *tx_ptr;
285 u8 *tx_next_ptr;
286 u8 *tx_dma_buf[2];
287 u8 tx_dma_used;
288 u16 txcount;
289
290 void (*rx_function)(struct z8530_channel *, struct sk_buff *);
291
292
293
294
295
296 u8 rxdma;
297 u8 txdma;
298 u8 rxdma_on;
299 u8 txdma_on;
300 u8 dma_num;
301 u8 dma_ready;
302 u8 dma_tx;
303 u8 *rx_buf[2];
304
305
306
307
308
309 struct z8530_dev *dev;
310 unsigned long ctrlio;
311 unsigned long dataio;
312
313
314
315
316#define Z8530_PORT_SLEEP 0x80000000
317#define Z8530_PORT_OF(x) ((x)&0xFFFF)
318
319 u32 rx_overrun;
320 u32 rx_crc_err;
321
322
323
324
325
326 void *private;
327 struct net_device *netdevice;
328
329
330
331
332
333 struct tty_struct *tty;
334 int line;
335 wait_queue_head_t open_wait;
336 wait_queue_head_t close_wait;
337 unsigned long event;
338 int fdcount;
339 int blocked_open;
340 int x_char;
341 unsigned char *xmit_buf;
342 int xmit_head;
343 int xmit_tail;
344 int xmit_cnt;
345 int flags;
346 int timeout;
347 int xmit_fifo_size;
348
349 int close_delay;
350 unsigned short closing_wait;
351
352
353
354
355
356
357 unsigned char clk_divisor;
358 int zs_baud;
359
360 int magic;
361 int baud_base;
362 int custom_divisor;
363
364
365 unsigned char tx_active;
366 unsigned char tx_stopped;
367
368 spinlock_t *lock;
369};
370
371
372
373
374
375struct z8530_dev
376{
377 char *name;
378 struct z8530_channel chanA;
379 struct z8530_channel chanB;
380 int type;
381#define Z8530 0
382#define Z85C30 1
383#define Z85230 2
384 int irq;
385 int active;
386
387 spinlock_t lock;
388};
389
390
391
392
393
394
395extern u8 z8530_dead_port[];
396extern u8 z8530_hdlc_kilostream_85230[];
397extern u8 z8530_hdlc_kilostream[];
398extern irqreturn_t z8530_interrupt(int, void *);
399extern void z8530_describe(struct z8530_dev *, char *mapping, unsigned long io);
400extern int z8530_init(struct z8530_dev *);
401extern int z8530_shutdown(struct z8530_dev *);
402extern int z8530_sync_open(struct net_device *, struct z8530_channel *);
403extern int z8530_sync_close(struct net_device *, struct z8530_channel *);
404extern int z8530_sync_dma_open(struct net_device *, struct z8530_channel *);
405extern int z8530_sync_dma_close(struct net_device *, struct z8530_channel *);
406extern int z8530_sync_txdma_open(struct net_device *, struct z8530_channel *);
407extern int z8530_sync_txdma_close(struct net_device *, struct z8530_channel *);
408extern int z8530_channel_load(struct z8530_channel *, u8 *);
409extern netdev_tx_t z8530_queue_xmit(struct z8530_channel *c,
410 struct sk_buff *skb);
411extern void z8530_null_rx(struct z8530_channel *c, struct sk_buff *skb);
412
413
414
415
416
417
418extern struct z8530_irqhandler z8530_sync, z8530_async, z8530_nop;
419
420
421
422
423
424#define SERIAL_MAGIC 0x5301
425
426
427
428
429
430#define SERIAL_XMIT_SIZE 4096
431#define WAKEUP_CHARS 256
432
433
434
435
436
437#define RS_EVENT_WRITE_WAKEUP 0
438
439
440#define ZILOG_INITIALIZED 0x80000000
441#define ZILOG_CALLOUT_ACTIVE 0x40000000
442#define ZILOG_NORMAL_ACTIVE 0x20000000
443#define ZILOG_BOOT_AUTOCONF 0x10000000
444#define ZILOG_CLOSING 0x08000000
445#define ZILOG_CTS_FLOW 0x04000000
446#define ZILOG_CHECK_CD 0x02000000
447
448#endif
449