Import 2.3.18pre1
[davej-history.git] / drivers / net / z85230.h
blob0b4b48748f5ef8202f9cf203426c9bff38ec4198
1 /*
2 * Description of Z8530 Z85C30 and Z85230 communications chips
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 1998 Alan Cox <alan@redhat.com>
6 */
8 #ifndef _Z8530_H
9 #define _Z8530_H
11 /* Conversion routines to/from brg time constants from/to bits
12 * per second.
14 #define BRG_TO_BPS(brg, freq) ((freq) / 2 / ((brg) + 2))
15 #define BPS_TO_BRG(bps, freq) ((((freq) + (bps)) / (2 * (bps))) - 2)
17 /* The Zilog register set */
19 #define FLAG 0x7e
21 /* Write Register 0 */
22 #define R0 0 /* Register selects */
23 #define R1 1
24 #define R2 2
25 #define R3 3
26 #define R4 4
27 #define R5 5
28 #define R6 6
29 #define R7 7
30 #define R8 8
31 #define R9 9
32 #define R10 10
33 #define R11 11
34 #define R12 12
35 #define R13 13
36 #define R14 14
37 #define R15 15
39 #define RPRIME 16 /* Indicate a prime register access on 230 */
41 #define NULLCODE 0 /* Null Code */
42 #define POINT_HIGH 0x8 /* Select upper half of registers */
43 #define RES_EXT_INT 0x10 /* Reset Ext. Status Interrupts */
44 #define SEND_ABORT 0x18 /* HDLC Abort */
45 #define RES_RxINT_FC 0x20 /* Reset RxINT on First Character */
46 #define RES_Tx_P 0x28 /* Reset TxINT Pending */
47 #define ERR_RES 0x30 /* Error Reset */
48 #define RES_H_IUS 0x38 /* Reset highest IUS */
50 #define RES_Rx_CRC 0x40 /* Reset Rx CRC Checker */
51 #define RES_Tx_CRC 0x80 /* Reset Tx CRC Checker */
52 #define RES_EOM_L 0xC0 /* Reset EOM latch */
54 /* Write Register 1 */
56 #define EXT_INT_ENAB 0x1 /* Ext Int Enable */
57 #define TxINT_ENAB 0x2 /* Tx Int Enable */
58 #define PAR_SPEC 0x4 /* Parity is special condition */
60 #define RxINT_DISAB 0 /* Rx Int Disable */
61 #define RxINT_FCERR 0x8 /* Rx Int on First Character Only or Error */
62 #define INT_ALL_Rx 0x10 /* Int on all Rx Characters or error */
63 #define INT_ERR_Rx 0x18 /* Int on error only */
65 #define WT_RDY_RT 0x20 /* Wait/Ready on R/T */
66 #define WT_FN_RDYFN 0x40 /* Wait/FN/Ready FN */
67 #define WT_RDY_ENAB 0x80 /* Wait/Ready Enable */
69 /* Write Register #2 (Interrupt Vector) */
71 /* Write Register 3 */
73 #define RxENABLE 0x1 /* Rx Enable */
74 #define SYNC_L_INH 0x2 /* Sync Character Load Inhibit */
75 #define ADD_SM 0x4 /* Address Search Mode (SDLC) */
76 #define RxCRC_ENAB 0x8 /* Rx CRC Enable */
77 #define ENT_HM 0x10 /* Enter Hunt Mode */
78 #define AUTO_ENAB 0x20 /* Auto Enables */
79 #define Rx5 0x0 /* Rx 5 Bits/Character */
80 #define Rx7 0x40 /* Rx 7 Bits/Character */
81 #define Rx6 0x80 /* Rx 6 Bits/Character */
82 #define Rx8 0xc0 /* Rx 8 Bits/Character */
84 /* Write Register 4 */
86 #define PAR_ENA 0x1 /* Parity Enable */
87 #define PAR_EVEN 0x2 /* Parity Even/Odd* */
89 #define SYNC_ENAB 0 /* Sync Modes Enable */
90 #define SB1 0x4 /* 1 stop bit/char */
91 #define SB15 0x8 /* 1.5 stop bits/char */
92 #define SB2 0xc /* 2 stop bits/char */
94 #define MONSYNC 0 /* 8 Bit Sync character */
95 #define BISYNC 0x10 /* 16 bit sync character */
96 #define SDLC 0x20 /* SDLC Mode (01111110 Sync Flag) */
97 #define EXTSYNC 0x30 /* External Sync Mode */
99 #define X1CLK 0x0 /* x1 clock mode */
100 #define X16CLK 0x40 /* x16 clock mode */
101 #define X32CLK 0x80 /* x32 clock mode */
102 #define X64CLK 0xC0 /* x64 clock mode */
104 /* Write Register 5 */
106 #define TxCRC_ENAB 0x1 /* Tx CRC Enable */
107 #define RTS 0x2 /* RTS */
108 #define SDLC_CRC 0x4 /* SDLC/CRC-16 */
109 #define TxENAB 0x8 /* Tx Enable */
110 #define SND_BRK 0x10 /* Send Break */
111 #define Tx5 0x0 /* Tx 5 bits (or less)/character */
112 #define Tx7 0x20 /* Tx 7 bits/character */
113 #define Tx6 0x40 /* Tx 6 bits/character */
114 #define Tx8 0x60 /* Tx 8 bits/character */
115 #define DTR 0x80 /* DTR */
117 /* Write Register 6 (Sync bits 0-7/SDLC Address Field) */
119 /* Write Register 7 (Sync bits 8-15/SDLC 01111110) */
121 /* Write Register 8 (transmit buffer) */
123 /* Write Register 9 (Master interrupt control) */
124 #define VIS 1 /* Vector Includes Status */
125 #define NV 2 /* No Vector */
126 #define DLC 4 /* Disable Lower Chain */
127 #define MIE 8 /* Master Interrupt Enable */
128 #define STATHI 0x10 /* Status high */
129 #define NORESET 0 /* No reset on write to R9 */
130 #define CHRB 0x40 /* Reset channel B */
131 #define CHRA 0x80 /* Reset channel A */
132 #define FHWRES 0xc0 /* Force hardware reset */
134 /* Write Register 10 (misc control bits) */
135 #define BIT6 1 /* 6 bit/8bit sync */
136 #define LOOPMODE 2 /* SDLC Loop mode */
137 #define ABUNDER 4 /* Abort/flag on SDLC xmit underrun */
138 #define MARKIDLE 8 /* Mark/flag on idle */
139 #define GAOP 0x10 /* Go active on poll */
140 #define NRZ 0 /* NRZ mode */
141 #define NRZI 0x20 /* NRZI mode */
142 #define FM1 0x40 /* FM1 (transition = 1) */
143 #define FM0 0x60 /* FM0 (transition = 0) */
144 #define CRCPS 0x80 /* CRC Preset I/O */
146 /* Write Register 11 (Clock Mode control) */
147 #define TRxCXT 0 /* TRxC = Xtal output */
148 #define TRxCTC 1 /* TRxC = Transmit clock */
149 #define TRxCBR 2 /* TRxC = BR Generator Output */
150 #define TRxCDP 3 /* TRxC = DPLL output */
151 #define TRxCOI 4 /* TRxC O/I */
152 #define TCRTxCP 0 /* Transmit clock = RTxC pin */
153 #define TCTRxCP 8 /* Transmit clock = TRxC pin */
154 #define TCBR 0x10 /* Transmit clock = BR Generator output */
155 #define TCDPLL 0x18 /* Transmit clock = DPLL output */
156 #define RCRTxCP 0 /* Receive clock = RTxC pin */
157 #define RCTRxCP 0x20 /* Receive clock = TRxC pin */
158 #define RCBR 0x40 /* Receive clock = BR Generator output */
159 #define RCDPLL 0x60 /* Receive clock = DPLL output */
160 #define RTxCX 0x80 /* RTxC Xtal/No Xtal */
162 /* Write Register 12 (lower byte of baud rate generator time constant) */
164 /* Write Register 13 (upper byte of baud rate generator time constant) */
166 /* Write Register 14 (Misc control bits) */
167 #define BRENABL 1 /* Baud rate generator enable */
168 #define BRSRC 2 /* Baud rate generator source */
169 #define DTRREQ 4 /* DTR/Request function */
170 #define AUTOECHO 8 /* Auto Echo */
171 #define LOOPBAK 0x10 /* Local loopback */
172 #define SEARCH 0x20 /* Enter search mode */
173 #define RMC 0x40 /* Reset missing clock */
174 #define DISDPLL 0x60 /* Disable DPLL */
175 #define SSBR 0x80 /* Set DPLL source = BR generator */
176 #define SSRTxC 0xa0 /* Set DPLL source = RTxC */
177 #define SFMM 0xc0 /* Set FM mode */
178 #define SNRZI 0xe0 /* Set NRZI mode */
180 /* Write Register 15 (external/status interrupt control) */
181 #define PRIME 1 /* R5' etc register access (Z85C30/230 only) */
182 #define ZCIE 2 /* Zero count IE */
183 #define FIFOE 4 /* Z85230 only */
184 #define DCDIE 8 /* DCD IE */
185 #define SYNCIE 0x10 /* Sync/hunt IE */
186 #define CTSIE 0x20 /* CTS IE */
187 #define TxUIE 0x40 /* Tx Underrun/EOM IE */
188 #define BRKIE 0x80 /* Break/Abort IE */
191 /* Read Register 0 */
192 #define Rx_CH_AV 0x1 /* Rx Character Available */
193 #define ZCOUNT 0x2 /* Zero count */
194 #define Tx_BUF_EMP 0x4 /* Tx Buffer empty */
195 #define DCD 0x8 /* DCD */
196 #define SYNC_HUNT 0x10 /* Sync/hunt */
197 #define CTS 0x20 /* CTS */
198 #define TxEOM 0x40 /* Tx underrun */
199 #define BRK_ABRT 0x80 /* Break/Abort */
201 /* Read Register 1 */
202 #define ALL_SNT 0x1 /* All sent */
203 /* Residue Data for 8 Rx bits/char programmed */
204 #define RES3 0x8 /* 0/3 */
205 #define RES4 0x4 /* 0/4 */
206 #define RES5 0xc /* 0/5 */
207 #define RES6 0x2 /* 0/6 */
208 #define RES7 0xa /* 0/7 */
209 #define RES8 0x6 /* 0/8 */
210 #define RES18 0xe /* 1/8 */
211 #define RES28 0x0 /* 2/8 */
212 /* Special Rx Condition Interrupts */
213 #define PAR_ERR 0x10 /* Parity error */
214 #define Rx_OVR 0x20 /* Rx Overrun Error */
215 #define CRC_ERR 0x40 /* CRC/Framing Error */
216 #define END_FR 0x80 /* End of Frame (SDLC) */
218 /* Read Register 2 (channel b only) - Interrupt vector */
220 /* Read Register 3 (interrupt pending register) ch a only */
221 #define CHBEXT 0x1 /* Channel B Ext/Stat IP */
222 #define CHBTxIP 0x2 /* Channel B Tx IP */
223 #define CHBRxIP 0x4 /* Channel B Rx IP */
224 #define CHAEXT 0x8 /* Channel A Ext/Stat IP */
225 #define CHATxIP 0x10 /* Channel A Tx IP */
226 #define CHARxIP 0x20 /* Channel A Rx IP */
228 /* Read Register 8 (receive data register) */
230 /* Read Register 10 (misc status bits) */
231 #define ONLOOP 2 /* On loop */
232 #define LOOPSEND 0x10 /* Loop sending */
233 #define CLK2MIS 0x40 /* Two clocks missing */
234 #define CLK1MIS 0x80 /* One clock missing */
236 /* Read Register 12 (lower byte of baud rate generator constant) */
238 /* Read Register 13 (upper byte of baud rate generator constant) */
240 /* Read Register 15 (value of WR 15) */
244 * Interrupt handling functions for this SCC
247 struct z8530_channel;
249 struct z8530_irqhandler
251 void (*rx)(struct z8530_channel *);
252 void (*tx)(struct z8530_channel *);
253 void (*status)(struct z8530_channel *);
257 * A channel of the Z8530
260 struct z8530_channel
262 struct z8530_irqhandler *irqs; /* IRQ handlers */
264 * Synchronous
266 u16 count; /* Buyes received */
267 u16 max; /* Most we can receive this frame */
268 u16 mtu; /* MTU of the device */
269 u8 *dptr; /* Pointer into rx buffer */
270 struct sk_buff *skb; /* Buffer dptr points into */
271 struct sk_buff *skb2; /* Pending buffer */
272 u8 status; /* Current DCD */
273 u8 sync; /* Set if in sync mode */
275 u8 regs[32]; /* Register map for the chip */
276 u8 pendregs[32]; /* Pending register values */
278 struct sk_buff *tx_skb; /* Buffer being transmitted */
279 struct sk_buff *tx_next_skb; /* Next transmit buffer */
280 u8 *tx_ptr; /* Byte pointer into the buffer */
281 u8 *tx_next_ptr; /* Next pointer to use */
282 u8 *tx_dma_buf[2]; /* TX flip buffers for DMA */
283 u8 tx_dma_used; /* Flip buffer usage toggler */
284 u16 txcount; /* Count of bytes to transmit */
286 void (*rx_function)(struct z8530_channel *, struct sk_buff *);
289 * Sync DMA
292 u8 rxdma; /* DMA channels */
293 u8 txdma;
294 u8 rxdma_on; /* DMA active if flag set */
295 u8 txdma_on;
296 u8 dma_num; /* Buffer we are DMAing into */
297 u8 dma_ready; /* Is the other buffer free */
298 u8 dma_tx; /* TX is to use DMA */
299 u8 *rx_buf[2]; /* The flip buffers */
302 * System
305 struct z8530_dev *dev; /* Z85230 chip instance we are from */
306 int ctrlio; /* I/O ports */
307 int dataio;
310 * For PC we encode this way.
312 #define Z8530_PORT_SLEEP 0x80000000
313 #define Z8530_PORT_OF(x) ((x)&0xFFFF)
315 u32 rx_overrun; /* Overruns - not done yet */
316 u32 rx_crc_err;
319 * Bound device pointers
322 void *private; /* For our owner */
323 struct net_device *netdevice; /* Network layer device */
324 struct net_device_stats stats; /* Network layer statistics */
327 * Async features
330 struct tty_struct *tty; /* Attached terminal */
331 int line; /* Minor number */
332 struct termios normal_termios; /* Terminal settings */
333 struct termios callout_termios;
334 wait_queue_head_t open_wait; /* Tasks waiting to open */
335 wait_queue_head_t close_wait; /* and for close to end */
336 unsigned long event; /* Pending events */
337 int fdcount; /* # of fd on device */
338 int blocked_open; /* # of blocked opens */
339 long session; /* Session of opening process */
340 long pgrp; /* pgrp of opening process */
341 int x_char; /* XON/XOF char */
342 unsigned char *xmit_buf; /* Transmit pointer */
343 int xmit_head; /* Transmit ring */
344 int xmit_tail;
345 int xmit_cnt;
346 int flags;
347 int timeout;
348 int xmit_fifo_size; /* Transmit FIFO info */
350 int close_delay; /* Do we wait for drain on close ? */
351 unsigned short closing_wait;
353 /* We need to know the current clock divisor
354 * to read the bps rate the chip has currently
355 * loaded.
358 unsigned char clk_divisor; /* May be 1, 16, 32, or 64 */
359 int zs_baud;
361 int magic;
362 int baud_base; /* Baud parameters */
363 int custom_divisor;
366 unsigned char tx_active; /* character is being xmitted */
367 unsigned char tx_stopped; /* output is suspended */
371 * Each Z853x0 device.
374 struct z8530_dev
376 char *name; /* Device instance name */
377 struct z8530_channel chanA; /* SCC channel A */
378 struct z8530_channel chanB; /* SCC channel B */
379 int type;
380 #define Z8530 0 /* NMOS dinosaur */
381 #define Z85C30 1 /* CMOS - better */
382 #define Z85230 2 /* CMOS with real FIFO */
383 int irq; /* Interrupt for the device */
384 int active; /* Soft interrupt enable - the Mac doesn't
385 always have a hard disable on its 8530s... */
390 * Functions
393 extern u8 z8530_dead_port[];
394 extern u8 z8530_hdlc_kilostream_85230[];
395 extern u8 z8530_hdlc_kilostream[];
396 extern void z8530_interrupt(int, void *, struct pt_regs *);
397 extern void z8530_describe(struct z8530_dev *, char *mapping,int io);
398 extern int z8530_init(struct z8530_dev *);
399 extern int z8530_shutdown(struct z8530_dev *);
400 extern int z8530_sync_open(struct net_device *, struct z8530_channel *);
401 extern int z8530_sync_close(struct net_device *, struct z8530_channel *);
402 extern int z8530_sync_dma_open(struct net_device *, struct z8530_channel *);
403 extern int z8530_sync_dma_close(struct net_device *, struct z8530_channel *);
404 extern int z8530_sync_txdma_open(struct net_device *, struct z8530_channel *);
405 extern int z8530_sync_txdma_close(struct net_device *, struct z8530_channel *);
406 extern int z8530_channel_load(struct z8530_channel *, u8 *);
407 extern int z8530_queue_xmit(struct z8530_channel *c, struct sk_buff *skb);
408 extern struct net_device_stats *z8530_get_stats(struct z8530_channel *c);
409 extern void z8530_null_rx(struct z8530_channel *c, struct sk_buff *skb);
413 * Standard interrupt vector sets
416 struct z8530_irqhandler z8530_sync, z8530_async, z8530_nop;
419 * Asynchronous Interfacing
422 #define SERIAL_MAGIC 0x5301
425 * The size of the serial xmit buffer is 1 page, or 4096 bytes
428 #define SERIAL_XMIT_SIZE 4096
429 #define WAKEUP_CHARS 256
432 * Events are used to schedule things to happen at timer-interrupt
433 * time, instead of at rs interrupt time.
435 #define RS_EVENT_WRITE_WAKEUP 0
437 /* Internal flags used only by kernel/chr_drv/serial.c */
438 #define ZILOG_INITIALIZED 0x80000000 /* Serial port was initialized */
439 #define ZILOG_CALLOUT_ACTIVE 0x40000000 /* Call out device is active */
440 #define ZILOG_NORMAL_ACTIVE 0x20000000 /* Normal device is active */
441 #define ZILOG_BOOT_AUTOCONF 0x10000000 /* Autoconfigure port on bootup */
442 #define ZILOG_CLOSING 0x08000000 /* Serial port is closing */
443 #define ZILOG_CTS_FLOW 0x04000000 /* Do CTS flow control */
444 #define ZILOG_CHECK_CD 0x02000000 /* i.e., CLOCAL */
446 #endif /* !(_Z8530_H) */