PM / sleep: Asynchronous threads for suspend_noirq
[linux/fpc-iii.git] / drivers / isdn / act2000 / act2000.h
blob321d437f579e1e044eb09ce2b47ebd51d9582855
1 /* $Id: act2000.h,v 1.8.6.3 2001/09/23 22:24:32 kai Exp $
3 * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000.
5 * Author Fritz Elfert
6 * Copyright by Fritz Elfert <fritz@isdn4linux.de>
8 * This software may be used and distributed according to the terms
9 * of the GNU General Public License, incorporated herein by reference.
11 * Thanks to Friedemann Baitinger and IBM Germany
15 #ifndef act2000_h
16 #define act2000_h
18 #include <linux/compiler.h>
20 #define ACT2000_IOCTL_SETPORT 1
21 #define ACT2000_IOCTL_GETPORT 2
22 #define ACT2000_IOCTL_SETIRQ 3
23 #define ACT2000_IOCTL_GETIRQ 4
24 #define ACT2000_IOCTL_SETBUS 5
25 #define ACT2000_IOCTL_GETBUS 6
26 #define ACT2000_IOCTL_SETPROTO 7
27 #define ACT2000_IOCTL_GETPROTO 8
28 #define ACT2000_IOCTL_SETMSN 9
29 #define ACT2000_IOCTL_GETMSN 10
30 #define ACT2000_IOCTL_LOADBOOT 11
31 #define ACT2000_IOCTL_ADDCARD 12
33 #define ACT2000_IOCTL_TEST 98
34 #define ACT2000_IOCTL_DEBUGVAR 99
36 #define ACT2000_BUS_ISA 1
37 #define ACT2000_BUS_MCA 2
38 #define ACT2000_BUS_PCMCIA 3
40 /* Struct for adding new cards */
41 typedef struct act2000_cdef {
42 int bus;
43 int port;
44 int irq;
45 char id[10];
46 } act2000_cdef;
48 /* Struct for downloading firmware */
49 typedef struct act2000_ddef {
50 int length; /* Length of code */
51 char __user *buffer; /* Ptr. to code */
52 } act2000_ddef;
54 typedef struct act2000_fwid {
55 char isdn[4];
56 char revlen[2];
57 char revision[504];
58 } act2000_fwid;
60 #if defined(__KERNEL__) || defined(__DEBUGVAR__)
62 #ifdef __KERNEL__
63 /* Kernel includes */
65 #include <linux/sched.h>
66 #include <linux/string.h>
67 #include <linux/workqueue.h>
68 #include <linux/interrupt.h>
69 #include <linux/skbuff.h>
70 #include <linux/errno.h>
71 #include <linux/fs.h>
72 #include <linux/major.h>
73 #include <asm/io.h>
74 #include <linux/kernel.h>
75 #include <linux/signal.h>
76 #include <linux/slab.h>
77 #include <linux/mm.h>
78 #include <linux/mman.h>
79 #include <linux/ioport.h>
80 #include <linux/timer.h>
81 #include <linux/wait.h>
82 #include <linux/delay.h>
83 #include <linux/ctype.h>
84 #include <linux/isdnif.h>
86 #endif /* __KERNEL__ */
88 #define ACT2000_PORTLEN 8
90 #define ACT2000_FLAGS_RUNNING 1 /* Cards driver activated */
91 #define ACT2000_FLAGS_PVALID 2 /* Cards port is valid */
92 #define ACT2000_FLAGS_IVALID 4 /* Cards irq is valid */
93 #define ACT2000_FLAGS_LOADED 8 /* Firmware loaded */
95 #define ACT2000_BCH 2 /* # of channels per card */
97 /* D-Channel states */
98 #define ACT2000_STATE_NULL 0
99 #define ACT2000_STATE_ICALL 1
100 #define ACT2000_STATE_OCALL 2
101 #define ACT2000_STATE_IWAIT 3
102 #define ACT2000_STATE_OWAIT 4
103 #define ACT2000_STATE_IBWAIT 5
104 #define ACT2000_STATE_OBWAIT 6
105 #define ACT2000_STATE_BWAIT 7
106 #define ACT2000_STATE_BHWAIT 8
107 #define ACT2000_STATE_BHWAIT2 9
108 #define ACT2000_STATE_DHWAIT 10
109 #define ACT2000_STATE_DHWAIT2 11
110 #define ACT2000_STATE_BSETUP 12
111 #define ACT2000_STATE_ACTIVE 13
113 #define ACT2000_MAX_QUEUED 8000 /* 2 * maxbuff */
115 #define ACT2000_LOCK_TX 0
116 #define ACT2000_LOCK_RX 1
118 typedef struct act2000_chan {
119 unsigned short callref; /* Call Reference */
120 unsigned short fsm_state; /* Current D-Channel state */
121 unsigned short eazmask; /* EAZ-Mask for this Channel */
122 short queued; /* User-Data Bytes in TX queue */
123 unsigned short plci;
124 unsigned short ncci;
125 unsigned char l2prot; /* Layer 2 protocol */
126 unsigned char l3prot; /* Layer 3 protocol */
127 } act2000_chan;
129 typedef struct msn_entry {
130 char eaz;
131 char msn[16];
132 struct msn_entry *next;
133 } msn_entry;
135 typedef struct irq_data_isa {
136 __u8 *rcvptr;
137 __u16 rcvidx;
138 __u16 rcvlen;
139 struct sk_buff *rcvskb;
140 __u8 rcvignore;
141 __u8 rcvhdr[8];
142 } irq_data_isa;
144 typedef union act2000_irq_data {
145 irq_data_isa isa;
146 } act2000_irq_data;
149 * Per card driver data
151 typedef struct act2000_card {
152 unsigned short port; /* Base-port-address */
153 unsigned short irq; /* Interrupt */
154 u_char ptype; /* Protocol type (1TR6 or Euro) */
155 u_char bus; /* Cardtype (ISA, MCA, PCMCIA) */
156 struct act2000_card *next; /* Pointer to next device struct */
157 spinlock_t lock; /* protect critical operations */
158 int myid; /* Driver-Nr. assigned by linklevel */
159 unsigned long flags; /* Statusflags */
160 unsigned long ilock; /* Semaphores for IRQ-Routines */
161 struct sk_buff_head rcvq; /* Receive-Message queue */
162 struct sk_buff_head sndq; /* Send-Message queue */
163 struct sk_buff_head ackq; /* Data-Ack-Message queue */
164 u_char *ack_msg; /* Ptr to User Data in User skb */
165 __u16 need_b3ack; /* Flag: Need ACK for current skb */
166 struct sk_buff *sbuf; /* skb which is currently sent */
167 struct timer_list ptimer; /* Poll timer */
168 struct work_struct snd_tq; /* Task struct for xmit bh */
169 struct work_struct rcv_tq; /* Task struct for rcv bh */
170 struct work_struct poll_tq; /* Task struct for polled rcv bh */
171 msn_entry *msn_list;
172 unsigned short msgnum; /* Message number for sending */
173 spinlock_t mnlock; /* lock for msgnum */
174 act2000_chan bch[ACT2000_BCH]; /* B-Channel status/control */
175 char status_buf[256]; /* Buffer for status messages */
176 char *status_buf_read;
177 char *status_buf_write;
178 char *status_buf_end;
179 act2000_irq_data idat; /* Data used for IRQ handler */
180 isdn_if interface; /* Interface to upper layer */
181 char regname[35]; /* Name used for request_region */
182 } act2000_card;
184 static inline void act2000_schedule_tx(act2000_card *card)
186 schedule_work(&card->snd_tq);
189 static inline void act2000_schedule_rx(act2000_card *card)
191 schedule_work(&card->rcv_tq);
194 static inline void act2000_schedule_poll(act2000_card *card)
196 schedule_work(&card->poll_tq);
199 extern char *act2000_find_eaz(act2000_card *, char);
201 #endif /* defined(__KERNEL__) || defined(__DEBUGVAR__) */
202 #endif /* act2000_h */