- Kai Germaschewski: ymfpci cleanups and resource leak fixes
[davej-history.git] / include / linux / scc.h
blobfbe1894608584ec61b683d81a4a4d64adde71702
1 /* $Id: scc.h,v 1.29 1997/04/02 14:56:45 jreuter Exp jreuter $ */
3 #ifndef _SCC_H
4 #define _SCC_H
6 #include <linux/config.h>
8 /* selection of hardware types */
10 #define PA0HZP 0x00 /* hardware type for PA0HZP SCC card and compatible */
11 #define EAGLE 0x01 /* hardware type for EAGLE card */
12 #define PC100 0x02 /* hardware type for PC100 card */
13 #define PRIMUS 0x04 /* hardware type for PRIMUS-PC (DG9BL) card */
14 #define DRSI 0x08 /* hardware type for DRSI PC*Packet card */
15 #define BAYCOM 0x10 /* hardware type for BayCom (U)SCC */
17 /* DEV ioctl() commands */
19 enum SCC_ioctl_cmds {
20 SIOCSCCRESERVED = SIOCDEVPRIVATE,
21 SIOCSCCCFG,
22 SIOCSCCINI,
23 SIOCSCCCHANINI,
24 SIOCSCCSMEM,
25 SIOCSCCGKISS,
26 SIOCSCCSKISS,
27 SIOCSCCGSTAT,
28 SIOCSCCCAL
31 /* magic number */
33 #define SCC_MAGIC 0x8530 /* ;-) */
35 /* Device parameter control (from WAMPES) */
37 enum L1_params {
38 PARAM_DATA,
39 PARAM_TXDELAY,
40 PARAM_PERSIST,
41 PARAM_SLOTTIME,
42 PARAM_TXTAIL,
43 PARAM_FULLDUP,
44 PARAM_SOFTDCD, /* was: PARAM_HW */
45 PARAM_MUTE, /* ??? */
46 PARAM_DTR,
47 PARAM_RTS,
48 PARAM_SPEED,
49 PARAM_ENDDELAY, /* ??? */
50 PARAM_GROUP,
51 PARAM_IDLE,
52 PARAM_MIN,
53 PARAM_MAXKEY,
54 PARAM_WAIT,
55 PARAM_MAXDEFER,
56 PARAM_TX,
57 PARAM_HWEVENT = 31,
58 PARAM_RETURN = 255 /* reset kiss mode */
61 /* fulldup parameter */
63 enum FULLDUP_modes {
64 KISS_DUPLEX_HALF, /* normal CSMA operation */
65 KISS_DUPLEX_FULL, /* fullduplex, key down trx after transmission */
66 KISS_DUPLEX_LINK, /* fullduplex, key down trx after 'idletime' sec */
67 KISS_DUPLEX_OPTIMA /* fullduplex, let the protocol layer control the hw */
70 /* misc. parameters */
72 #define TIMER_OFF 65535U /* to switch off timers */
73 #define NO_SUCH_PARAM 65534U /* param not implemented */
75 /* HWEVENT parameter */
77 enum HWEVENT_opts {
78 HWEV_DCD_ON,
79 HWEV_DCD_OFF,
80 HWEV_ALL_SENT
83 /* channel grouping */
85 #define RXGROUP 0100 /* if set, only tx when all channels clear */
86 #define TXGROUP 0200 /* if set, don't transmit simultaneously */
88 /* Tx/Rx clock sources */
90 enum CLOCK_sources {
91 CLK_DPLL, /* normal halfduplex operation */
92 CLK_EXTERNAL, /* external clocking (G3RUH/DF9IC modems) */
93 CLK_DIVIDER, /* Rx = DPLL, Tx = divider (fullduplex with */
94 /* modems without clock regeneration */
95 CLK_BRG /* experimental fullduplex mode with DPLL/BRG for */
96 /* MODEMs without clock recovery */
99 /* Tx state */
101 enum TX_state {
102 TXS_IDLE, /* Transmitter off, no data pending */
103 TXS_BUSY, /* waiting for permission to send / tailtime */
104 TXS_ACTIVE, /* Transmitter on, sending data */
105 TXS_NEWFRAME, /* reset CRC and send (next) frame */
106 TXS_IDLE2, /* Transmitter on, no data pending */
107 TXS_WAIT, /* Waiting for Mintime to expire */
108 TXS_TIMEOUT /* We had a transmission timeout */
111 typedef unsigned long io_port; /* type definition for an 'io port address' */
113 /* SCC statistical information */
115 struct scc_stat {
116 long rxints; /* Receiver interrupts */
117 long txints; /* Transmitter interrupts */
118 long exints; /* External/status interrupts */
119 long spints; /* Special receiver interrupts */
121 long txframes; /* Packets sent */
122 long rxframes; /* Number of Frames Actually Received */
123 long rxerrs; /* CRC Errors */
124 long txerrs; /* KISS errors */
126 unsigned int nospace; /* "Out of buffers" */
127 unsigned int rx_over; /* Receiver Overruns */
128 unsigned int tx_under; /* Transmitter Underruns */
130 unsigned int tx_state; /* Transmitter state */
131 int tx_queued; /* tx frames enqueued */
133 unsigned int maxqueue; /* allocated tx_buffers */
134 unsigned int bufsize; /* used buffersize */
137 struct scc_modem {
138 long speed; /* Line speed, bps */
139 char clocksrc; /* 0 = DPLL, 1 = external, 2 = divider */
140 char nrz; /* NRZ instead of NRZI */
143 struct scc_kiss_cmd {
144 int command; /* one of the KISS-Commands defined above */
145 unsigned param; /* KISS-Param */
148 struct scc_hw_config {
149 io_port data_a; /* data port channel A */
150 io_port ctrl_a; /* control port channel A */
151 io_port data_b; /* data port channel B */
152 io_port ctrl_b; /* control port channel B */
153 io_port vector_latch; /* INTACK-Latch (#) */
154 io_port special; /* special function port */
156 int irq; /* irq */
157 long clock; /* clock */
158 char option; /* command for function port */
160 char brand; /* hardware type */
161 char escc; /* use ext. features of a 8580/85180/85280 */
164 /* (#) only one INTACK latch allowed. */
167 struct scc_mem_config {
168 unsigned int dummy;
169 unsigned int bufsize;
172 struct scc_calibrate {
173 unsigned int time;
174 unsigned char pattern;
177 #ifdef __KERNEL__
179 enum {TX_OFF, TX_ON}; /* command for scc_key_trx() */
181 /* Vector masks in RR2B */
183 #define VECTOR_MASK 0x06
184 #define TXINT 0x00
185 #define EXINT 0x02
186 #define RXINT 0x04
187 #define SPINT 0x06
189 #ifdef CONFIG_SCC_DELAY
190 #define Inb(port) inb_p(port)
191 #define Outb(port, val) outb_p(val, port)
192 #else
193 #define Inb(port) inb(port)
194 #define Outb(port, val) outb(val, port)
195 #endif
197 /* SCC channel control structure for KISS */
199 struct scc_kiss {
200 unsigned char txdelay; /* Transmit Delay 10 ms/cnt */
201 unsigned char persist; /* Persistence (0-255) as a % */
202 unsigned char slottime; /* Delay to wait on persistence hit */
203 unsigned char tailtime; /* Delay after last byte written */
204 unsigned char fulldup; /* Full Duplex mode 0=CSMA 1=DUP 2=ALWAYS KEYED */
205 unsigned char waittime; /* Waittime before any transmit attempt */
206 unsigned int maxkeyup; /* Maximum time to transmit (seconds) */
207 unsigned char mintime; /* Minimal offtime after MAXKEYUP timeout (seconds) */
208 unsigned int idletime; /* Maximum idle time in ALWAYS KEYED mode (seconds) */
209 unsigned int maxdefer; /* Timer for CSMA channel busy limit */
210 unsigned char tx_inhibit; /* Transmit is not allowed when set */
211 unsigned char group; /* Group ID for AX.25 TX interlocking */
212 unsigned char mode; /* 'normal' or 'hwctrl' mode (unused) */
213 unsigned char softdcd; /* Use DPLL instead of DCD pin for carrier detect */
217 /* SCC channel structure */
219 struct scc_channel {
220 int magic; /* magic word */
222 int init; /* channel exists? */
224 struct net_device *dev; /* link to device control structure */
225 struct net_device_stats dev_stat;/* device statistics */
227 char brand; /* manufacturer of the board */
228 long clock; /* used clock */
230 io_port ctrl; /* I/O address of CONTROL register */
231 io_port data; /* I/O address of DATA register */
232 io_port special; /* I/O address of special function port */
233 int irq; /* Number of Interrupt */
235 char option;
236 char enhanced; /* Enhanced SCC support */
238 unsigned char wreg[16]; /* Copy of last written value in WRx */
239 unsigned char status; /* Copy of R0 at last external interrupt */
240 unsigned char dcd; /* DCD status */
242 struct scc_kiss kiss; /* control structure for KISS params */
243 struct scc_stat stat; /* statistical information */
244 struct scc_modem modem; /* modem information */
246 struct sk_buff_head tx_queue; /* next tx buffer */
247 struct sk_buff *rx_buff; /* pointer to frame currently received */
248 struct sk_buff *tx_buff; /* pointer to frame currently transmitted */
250 /* Timer */
252 struct timer_list tx_t; /* tx timer for this channel */
253 struct timer_list tx_wdog; /* tx watchdogs */
256 int scc_init(void);
257 #endif /* defined(__KERNEL__) */
258 #endif /* defined(_SCC_H) */