ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / linux / isicom.h
1 #ifndef _LINUX_ISICOM_H
2 #define _LINUX_ISICOM_H
3
4 /*#define               ISICOM_DEBUG*/
5 /*#define               ISICOM_DEBUG_DTR_RTS*/
6
7
8 /*
9  *      Firmware Loader definitions ...
10  */
11  
12 #define         __MultiTech             ('M'<<8)
13 #define         MIOCTL_LOAD_FIRMWARE    (__MultiTech | 0x01)
14 #define         MIOCTL_READ_FIRMWARE    (__MultiTech | 0x02)
15 #define         MIOCTL_XFER_CTRL        (__MultiTech | 0x03)
16 #define         MIOCTL_RESET_CARD       (__MultiTech | 0x04)
17
18 #define         DATA_SIZE       16
19
20 typedef struct  {
21                 unsigned short  exec_segment;
22                 unsigned short  exec_addr;
23 }       exec_record;
24
25 typedef struct  {
26                 int             board;          /* Board to load */
27                 unsigned short  addr;
28                 unsigned short  count;
29 }       bin_header;
30
31 typedef struct  {
32                 int             board;          /* Board to load */
33                 unsigned short  addr;
34                 unsigned short  count;
35                 unsigned short  segment;
36                 unsigned char   bin_data[DATA_SIZE];
37 }       bin_frame;
38
39 #ifdef __KERNEL__
40
41 #define         YES     1
42 #define         NO      0
43
44 #define         ISILOAD_MISC_MINOR      155     /* /dev/isctl */
45 #define         ISILOAD_NAME            "ISILoad"
46
47 /*      
48  *  ISICOM Driver definitions ...
49  *
50  */
51
52 #define         ISICOM_NAME     "ISICom"
53
54 /*
55  *      PCI definitions
56  */
57
58  #define        DEVID_COUNT     9
59  #define        VENDOR_ID       0x10b5
60
61 /*
62  *      These are now officially allocated numbers
63  */
64
65 #define         ISICOM_NMAJOR   112     /* normal  */
66 #define         ISICOM_CMAJOR   113     /* callout */
67 #define         ISICOM_MAGIC    (('M' << 8) | 'T')
68
69 #define         WAKEUP_CHARS    256     /* hard coded for now   */ 
70 #define         TX_SIZE         254 
71  
72 #define         BOARD_COUNT     4
73 #define         PORT_COUNT      (BOARD_COUNT*16)
74
75 #define         SERIAL_TYPE_NORMAL      1
76
77 /*   character sizes  */
78
79 #define         ISICOM_CS5              0x0000
80 #define         ISICOM_CS6              0x0001
81 #define         ISICOM_CS7              0x0002
82 #define         ISICOM_CS8              0x0003
83
84 /* stop bits */
85
86 #define         ISICOM_1SB              0x0000
87 #define         ISICOM_2SB              0x0004
88
89 /* parity */
90
91 #define         ISICOM_NOPAR            0x0000
92 #define         ISICOM_ODPAR            0x0008
93 #define         ISICOM_EVPAR            0x0018
94
95 /* flow control */
96
97 #define         ISICOM_CTSRTS           0x03
98 #define         ISICOM_INITIATE_XONXOFF 0x04
99 #define         ISICOM_RESPOND_XONXOFF  0x08
100
101 #define InterruptTheCard(base) (outw(0,(base)+0xc)) 
102 #define ClearInterrupt(base) (inw((base)+0x0a)) 
103
104 #define BOARD(line)  (((line) >> 4) & 0x3)
105 #define MIN(a, b) ( (a) < (b) ? (a) : (b) )
106
107         /*      isi kill queue bitmap   */
108         
109 #define         ISICOM_KILLTX           0x01
110 #define         ISICOM_KILLRX           0x02
111
112         /* isi_board status bitmap */
113         
114 #define         FIRMWARE_LOADED         0x0001
115 #define         BOARD_ACTIVE            0x0002
116
117         /* isi_port status bitmap  */
118
119 #define         ISI_CTS                 0x1000
120 #define         ISI_DSR                 0x2000
121 #define         ISI_RI                  0x4000
122 #define         ISI_DCD                 0x8000
123 #define         ISI_DTR                 0x0100
124 #define         ISI_RTS                 0x0200
125
126
127 #define         ISI_TXOK                0x0001 
128  
129 struct  isi_board {
130         unsigned short          base;
131         unsigned char           irq;
132         unsigned char           port_count;
133         unsigned short          status;
134         unsigned short          port_status; /* each bit represents a single port */
135         unsigned short          shift_count;
136         struct isi_port         * ports;
137         signed char             count;
138         unsigned char           isa;
139 };
140
141 struct  isi_port {
142         unsigned short          magic;
143         unsigned int            flags;
144         int                     count;
145         int                     blocked_open;
146         int                     close_delay;
147         unsigned short          channel;
148         unsigned short          status;
149         unsigned short          closing_wait;
150         struct isi_board        * card;
151         struct tty_struct       * tty;
152         wait_queue_head_t       close_wait;
153         wait_queue_head_t       open_wait;
154         struct work_struct      hangup_tq;
155         struct work_struct      bh_tqueue;
156         unsigned char           * xmit_buf;
157         int                     xmit_head;
158         int                     xmit_tail;
159         int                     xmit_cnt;
160 };
161
162
163 /*
164  *  ISI Card specific ops ...
165  */
166  
167 static inline void raise_dtr(struct isi_port * port)
168 {
169         struct isi_board * card = port->card;
170         unsigned short base = card->base;
171         unsigned char channel = port->channel;
172         short wait=400;
173         while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
174         if (wait <= 0) {
175                 printk(KERN_WARNING "ISICOM: Card found busy in raise_dtr.\n");
176                 return;
177         }
178 #ifdef ISICOM_DEBUG_DTR_RTS     
179         printk(KERN_DEBUG "ISICOM: raise_dtr.\n");
180 #endif  
181         outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
182         outw(0x0504, base);
183         InterruptTheCard(base);
184         port->status |= ISI_DTR;
185 }
186
187 static inline void drop_dtr(struct isi_port * port)
188 {       
189         struct isi_board * card = port->card;
190         unsigned short base = card->base;
191         unsigned char channel = port->channel;
192         short wait=400;
193         while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
194         if (wait <= 0) {
195                 printk(KERN_WARNING "ISICOM: Card found busy in drop_dtr.\n");
196                 return;
197         }
198 #ifdef ISICOM_DEBUG_DTR_RTS     
199         printk(KERN_DEBUG "ISICOM: drop_dtr.\n");
200 #endif  
201         outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
202         outw(0x0404, base);
203         InterruptTheCard(base); 
204         port->status &= ~ISI_DTR;
205 }
206 static inline void raise_rts(struct isi_port * port)
207 {
208         struct isi_board * card = port->card;
209         unsigned short base = card->base;
210         unsigned char channel = port->channel;
211         short wait=400;
212         while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
213         if (wait <= 0) {
214                 printk(KERN_WARNING "ISICOM: Card found busy in raise_rts.\n");
215                 return;
216         }
217 #ifdef ISICOM_DEBUG_DTR_RTS     
218         printk(KERN_DEBUG "ISICOM: raise_rts.\n");
219 #endif  
220         outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
221         outw(0x0a04, base);
222         InterruptTheCard(base); 
223         port->status |= ISI_RTS;
224 }
225 static inline void drop_rts(struct isi_port * port)
226 {
227         struct isi_board * card = port->card;
228         unsigned short base = card->base;
229         unsigned char channel = port->channel;
230         short wait=400;
231         while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
232         if (wait <= 0) {
233                 printk(KERN_WARNING "ISICOM: Card found busy in drop_rts.\n");
234                 return;
235         }
236 #ifdef ISICOM_DEBUG_DTR_RTS     
237         printk(KERN_DEBUG "ISICOM: drop_rts.\n");
238 #endif  
239         outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
240         outw(0x0804, base);
241         InterruptTheCard(base); 
242         port->status &= ~ISI_RTS;
243 }
244 static inline void raise_dtr_rts(struct isi_port * port)
245 {
246         struct isi_board * card = port->card;
247         unsigned short base = card->base;
248         unsigned char channel = port->channel;
249         short wait=400;
250         while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
251         if (wait <= 0) {
252                 printk(KERN_WARNING "ISICOM: Card found busy in raise_dtr_rts.\n");
253                 return;
254         }
255 #ifdef ISICOM_DEBUG_DTR_RTS     
256         printk(KERN_DEBUG "ISICOM: raise_dtr_rts.\n");
257 #endif  
258         outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
259         outw(0x0f04, base);
260         InterruptTheCard(base);
261         port->status |= (ISI_DTR | ISI_RTS);
262 }
263 static inline void drop_dtr_rts(struct isi_port * port)
264 {
265         struct isi_board * card = port->card;
266         unsigned short base = card->base;
267         unsigned char channel = port->channel;
268         short wait=400;
269         while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
270         if (wait <= 0) {
271                 printk(KERN_WARNING "ISICOM: Card found busy in drop_dtr_rts.\n");
272                 return;
273         }
274 #ifdef ISICOM_DEBUG_DTR_RTS     
275         printk(KERN_DEBUG "ISICOM: drop_dtr_rts.\n");
276 #endif  
277         outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
278         outw(0x0c04, base);
279         InterruptTheCard(base); 
280         port->status &= ~(ISI_RTS | ISI_DTR);
281 }
282
283 static inline void kill_queue(struct isi_port * port, short queue)
284 {
285         struct isi_board * card = port->card;
286         unsigned short base = card->base;
287         unsigned char channel = port->channel;
288         short wait=400;
289         while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
290         if (wait <= 0) {
291                 printk(KERN_WARNING "ISICOM: Card found busy in kill_queue.\n");
292                 return;
293         }
294 #ifdef ISICOM_DEBUG     
295         printk(KERN_DEBUG "ISICOM: kill_queue 0x%x.\n", queue);
296 #endif  
297         outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
298         outw((queue << 8) | 0x06, base);
299         InterruptTheCard(base); 
300 }
301
302 #endif  /*      __KERNEL__      */
303
304 #endif  /*      ISICOM_H        */
305