MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / include / linux / isicom.h
blobf9974634b833fb1f323d75689caa05094e99da32
1 #ifndef _LINUX_ISICOM_H
2 #define _LINUX_ISICOM_H
4 /*#define ISICOM_DEBUG*/
5 /*#define ISICOM_DEBUG_DTR_RTS*/
8 /*
9 * Firmware Loader definitions ...
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)
18 #define DATA_SIZE 16
20 typedef struct {
21 unsigned short exec_segment;
22 unsigned short exec_addr;
23 } exec_record;
25 typedef struct {
26 int board; /* Board to load */
27 unsigned short addr;
28 unsigned short count;
29 } bin_header;
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;
39 #ifdef __KERNEL__
41 #define YES 1
42 #define NO 0
44 #define ISILOAD_MISC_MINOR 155 /* /dev/isctl */
45 #define ISILOAD_NAME "ISILoad"
47 /*
48 * ISICOM Driver definitions ...
52 #define ISICOM_NAME "ISICom"
55 * PCI definitions
58 #define DEVID_COUNT 9
59 #define VENDOR_ID 0x10b5
62 * These are now officially allocated numbers
65 #define ISICOM_NMAJOR 112 /* normal */
66 #define ISICOM_CMAJOR 113 /* callout */
67 #define ISICOM_MAGIC (('M' << 8) | 'T')
69 #define WAKEUP_CHARS 256 /* hard coded for now */
70 #define TX_SIZE 254
72 #define BOARD_COUNT 4
73 #define PORT_COUNT (BOARD_COUNT*16)
75 #define SERIAL_TYPE_NORMAL 1
77 /* character sizes */
79 #define ISICOM_CS5 0x0000
80 #define ISICOM_CS6 0x0001
81 #define ISICOM_CS7 0x0002
82 #define ISICOM_CS8 0x0003
84 /* stop bits */
86 #define ISICOM_1SB 0x0000
87 #define ISICOM_2SB 0x0004
89 /* parity */
91 #define ISICOM_NOPAR 0x0000
92 #define ISICOM_ODPAR 0x0008
93 #define ISICOM_EVPAR 0x0018
95 /* flow control */
97 #define ISICOM_CTSRTS 0x03
98 #define ISICOM_INITIATE_XONXOFF 0x04
99 #define ISICOM_RESPOND_XONXOFF 0x08
101 #define InterruptTheCard(base) (outw(0,(base)+0xc))
102 #define ClearInterrupt(base) (inw((base)+0x0a))
104 #define BOARD(line) (((line) >> 4) & 0x3)
106 /* isi kill queue bitmap */
108 #define ISICOM_KILLTX 0x01
109 #define ISICOM_KILLRX 0x02
111 /* isi_board status bitmap */
113 #define FIRMWARE_LOADED 0x0001
114 #define BOARD_ACTIVE 0x0002
116 /* isi_port status bitmap */
118 #define ISI_CTS 0x1000
119 #define ISI_DSR 0x2000
120 #define ISI_RI 0x4000
121 #define ISI_DCD 0x8000
122 #define ISI_DTR 0x0100
123 #define ISI_RTS 0x0200
126 #define ISI_TXOK 0x0001
128 struct isi_board {
129 unsigned short base;
130 unsigned char irq;
131 unsigned char port_count;
132 unsigned short status;
133 unsigned short port_status; /* each bit represents a single port */
134 unsigned short shift_count;
135 struct isi_port * ports;
136 signed char count;
137 unsigned char isa;
140 struct isi_port {
141 unsigned short magic;
142 unsigned int flags;
143 int count;
144 int blocked_open;
145 int close_delay;
146 unsigned short channel;
147 unsigned short status;
148 unsigned short closing_wait;
149 struct isi_board * card;
150 struct tty_struct * tty;
151 wait_queue_head_t close_wait;
152 wait_queue_head_t open_wait;
153 struct work_struct hangup_tq;
154 struct work_struct bh_tqueue;
155 unsigned char * xmit_buf;
156 int xmit_head;
157 int xmit_tail;
158 int xmit_cnt;
163 * ISI Card specific ops ...
166 static inline void raise_dtr(struct isi_port * port)
168 struct isi_board * card = port->card;
169 unsigned short base = card->base;
170 unsigned char channel = port->channel;
171 short wait=400;
172 while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
173 if (wait <= 0) {
174 printk(KERN_WARNING "ISICOM: Card found busy in raise_dtr.\n");
175 return;
177 #ifdef ISICOM_DEBUG_DTR_RTS
178 printk(KERN_DEBUG "ISICOM: raise_dtr.\n");
179 #endif
180 outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
181 outw(0x0504, base);
182 InterruptTheCard(base);
183 port->status |= ISI_DTR;
186 static inline void drop_dtr(struct isi_port * port)
188 struct isi_board * card = port->card;
189 unsigned short base = card->base;
190 unsigned char channel = port->channel;
191 short wait=400;
192 while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
193 if (wait <= 0) {
194 printk(KERN_WARNING "ISICOM: Card found busy in drop_dtr.\n");
195 return;
197 #ifdef ISICOM_DEBUG_DTR_RTS
198 printk(KERN_DEBUG "ISICOM: drop_dtr.\n");
199 #endif
200 outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
201 outw(0x0404, base);
202 InterruptTheCard(base);
203 port->status &= ~ISI_DTR;
205 static inline void raise_rts(struct isi_port * port)
207 struct isi_board * card = port->card;
208 unsigned short base = card->base;
209 unsigned char channel = port->channel;
210 short wait=400;
211 while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
212 if (wait <= 0) {
213 printk(KERN_WARNING "ISICOM: Card found busy in raise_rts.\n");
214 return;
216 #ifdef ISICOM_DEBUG_DTR_RTS
217 printk(KERN_DEBUG "ISICOM: raise_rts.\n");
218 #endif
219 outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
220 outw(0x0a04, base);
221 InterruptTheCard(base);
222 port->status |= ISI_RTS;
224 static inline void drop_rts(struct isi_port * port)
226 struct isi_board * card = port->card;
227 unsigned short base = card->base;
228 unsigned char channel = port->channel;
229 short wait=400;
230 while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
231 if (wait <= 0) {
232 printk(KERN_WARNING "ISICOM: Card found busy in drop_rts.\n");
233 return;
235 #ifdef ISICOM_DEBUG_DTR_RTS
236 printk(KERN_DEBUG "ISICOM: drop_rts.\n");
237 #endif
238 outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
239 outw(0x0804, base);
240 InterruptTheCard(base);
241 port->status &= ~ISI_RTS;
243 static inline void raise_dtr_rts(struct isi_port * port)
245 struct isi_board * card = port->card;
246 unsigned short base = card->base;
247 unsigned char channel = port->channel;
248 short wait=400;
249 while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
250 if (wait <= 0) {
251 printk(KERN_WARNING "ISICOM: Card found busy in raise_dtr_rts.\n");
252 return;
254 #ifdef ISICOM_DEBUG_DTR_RTS
255 printk(KERN_DEBUG "ISICOM: raise_dtr_rts.\n");
256 #endif
257 outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
258 outw(0x0f04, base);
259 InterruptTheCard(base);
260 port->status |= (ISI_DTR | ISI_RTS);
262 static inline void drop_dtr_rts(struct isi_port * port)
264 struct isi_board * card = port->card;
265 unsigned short base = card->base;
266 unsigned char channel = port->channel;
267 short wait=400;
268 while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
269 if (wait <= 0) {
270 printk(KERN_WARNING "ISICOM: Card found busy in drop_dtr_rts.\n");
271 return;
273 #ifdef ISICOM_DEBUG_DTR_RTS
274 printk(KERN_DEBUG "ISICOM: drop_dtr_rts.\n");
275 #endif
276 outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
277 outw(0x0c04, base);
278 InterruptTheCard(base);
279 port->status &= ~(ISI_RTS | ISI_DTR);
282 static inline void kill_queue(struct isi_port * port, short queue)
284 struct isi_board * card = port->card;
285 unsigned short base = card->base;
286 unsigned char channel = port->channel;
287 short wait=400;
288 while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
289 if (wait <= 0) {
290 printk(KERN_WARNING "ISICOM: Card found busy in kill_queue.\n");
291 return;
293 #ifdef ISICOM_DEBUG
294 printk(KERN_DEBUG "ISICOM: kill_queue 0x%x.\n", queue);
295 #endif
296 outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
297 outw((queue << 8) | 0x06, base);
298 InterruptTheCard(base);
301 #endif /* __KERNEL__ */
303 #endif /* ISICOM_H */