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 #define		SERIAL_TYPE_CALLOUT	2
77 
78 /*   character sizes  */
79 
80 #define		ISICOM_CS5		0x0000
81 #define		ISICOM_CS6		0x0001
82 #define		ISICOM_CS7		0x0002
83 #define		ISICOM_CS8		0x0003
84 
85 /* stop bits */
86 
87 #define		ISICOM_1SB		0x0000
88 #define		ISICOM_2SB		0x0004
89 
90 /* parity */
91 
92 #define		ISICOM_NOPAR		0x0000
93 #define		ISICOM_ODPAR		0x0008
94 #define		ISICOM_EVPAR		0x0018
95 
96 /* flow control */
97 
98 #define		ISICOM_CTSRTS		0x03
99 #define		ISICOM_INITIATE_XONXOFF	0x04
100 #define		ISICOM_RESPOND_XONXOFF	0x08
101 
102 #define InterruptTheCard(base) (outw(0,(base)+0xc))
103 #define ClearInterrupt(base) (inw((base)+0x0a))
104 
105 #define	BOARD(line)  (((line) >> 4) & 0x3)
106 #define MIN(a, b) ( (a) < (b) ? (a) : (b) )
107 
108 	/*	isi kill queue bitmap	*/
109 
110 #define		ISICOM_KILLTX		0x01
111 #define		ISICOM_KILLRX		0x02
112 
113 	/* isi_board status bitmap */
114 
115 #define		FIRMWARE_LOADED		0x0001
116 #define		BOARD_ACTIVE		0x0002
117 
118  	/* isi_port status bitmap  */
119 
120 #define		ISI_CTS			0x1000
121 #define		ISI_DSR			0x2000
122 #define		ISI_RI			0x4000
123 #define		ISI_DCD			0x8000
124 #define		ISI_DTR			0x0100
125 #define		ISI_RTS			0x0200
126 
127 
128 #define		ISI_TXOK		0x0001
129 
130 struct	isi_board {
131 	unsigned short		base;
132 	unsigned char		irq;
133 	unsigned char		port_count;
134 	unsigned short		status;
135 	unsigned short		port_status; /* each bit represents a single port */
136 	unsigned short		shift_count;
137 	struct isi_port		* ports;
138 	signed char		count;
139 	unsigned char		isa;
140 };
141 
142 struct	isi_port {
143 	unsigned short		magic;
144 	unsigned int		flags;
145 	int			count;
146 	int			blocked_open;
147 	int			close_delay;
148 	unsigned short		channel;
149 	unsigned short		status;
150 	unsigned short		closing_wait;
151 	long 			session;
152 	long			pgrp;
153 	struct isi_board	* card;
154 	struct tty_struct 	* tty;
155 	wait_queue_head_t	close_wait;
156 	wait_queue_head_t	open_wait;
157 	struct tq_struct	hangup_tq;
158 	struct tq_struct	bh_tqueue;
159 	unsigned char		* xmit_buf;
160 	int			xmit_head;
161 	int			xmit_tail;
162 	int			xmit_cnt;
163 	struct termios 		normal_termios;
164 	struct termios		callout_termios;
165 };
166 
167 
168 /*
169  *  ISI Card specific ops ...
170  */
171 
raise_dtr(struct isi_port * port)172 static inline void raise_dtr(struct isi_port * port)
173 {
174 	struct isi_board * card = port->card;
175 	unsigned short base = card->base;
176 	unsigned char channel = port->channel;
177 	short wait=400;
178 	while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
179 	if (wait <= 0) {
180 		printk(KERN_WARNING "ISICOM: Card found busy in raise_dtr.\n");
181 		return;
182 	}
183 #ifdef ISICOM_DEBUG_DTR_RTS
184 	printk(KERN_DEBUG "ISICOM: raise_dtr.\n");
185 #endif
186 	outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
187 	outw(0x0504, base);
188 	InterruptTheCard(base);
189 	port->status |= ISI_DTR;
190 }
191 
drop_dtr(struct isi_port * port)192 static inline void drop_dtr(struct isi_port * port)
193 {
194 	struct isi_board * card = port->card;
195 	unsigned short base = card->base;
196 	unsigned char channel = port->channel;
197 	short wait=400;
198 	while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
199 	if (wait <= 0) {
200 		printk(KERN_WARNING "ISICOM: Card found busy in drop_dtr.\n");
201 		return;
202 	}
203 #ifdef ISICOM_DEBUG_DTR_RTS
204 	printk(KERN_DEBUG "ISICOM: drop_dtr.\n");
205 #endif
206 	outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
207 	outw(0x0404, base);
208 	InterruptTheCard(base);
209 	port->status &= ~ISI_DTR;
210 }
raise_rts(struct isi_port * port)211 static inline void raise_rts(struct isi_port * port)
212 {
213 	struct isi_board * card = port->card;
214 	unsigned short base = card->base;
215 	unsigned char channel = port->channel;
216 	short wait=400;
217 	while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
218 	if (wait <= 0) {
219 		printk(KERN_WARNING "ISICOM: Card found busy in raise_rts.\n");
220 		return;
221 	}
222 #ifdef ISICOM_DEBUG_DTR_RTS
223 	printk(KERN_DEBUG "ISICOM: raise_rts.\n");
224 #endif
225 	outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
226 	outw(0x0a04, base);
227 	InterruptTheCard(base);
228 	port->status |= ISI_RTS;
229 }
drop_rts(struct isi_port * port)230 static inline void drop_rts(struct isi_port * port)
231 {
232 	struct isi_board * card = port->card;
233 	unsigned short base = card->base;
234 	unsigned char channel = port->channel;
235 	short wait=400;
236 	while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
237 	if (wait <= 0) {
238 		printk(KERN_WARNING "ISICOM: Card found busy in drop_rts.\n");
239 		return;
240 	}
241 #ifdef ISICOM_DEBUG_DTR_RTS
242 	printk(KERN_DEBUG "ISICOM: drop_rts.\n");
243 #endif
244 	outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
245 	outw(0x0804, base);
246 	InterruptTheCard(base);
247 	port->status &= ~ISI_RTS;
248 }
raise_dtr_rts(struct isi_port * port)249 static inline void raise_dtr_rts(struct isi_port * port)
250 {
251 	struct isi_board * card = port->card;
252 	unsigned short base = card->base;
253 	unsigned char channel = port->channel;
254 	short wait=400;
255 	while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
256 	if (wait <= 0) {
257 		printk(KERN_WARNING "ISICOM: Card found busy in raise_dtr_rts.\n");
258 		return;
259 	}
260 #ifdef ISICOM_DEBUG_DTR_RTS
261 	printk(KERN_DEBUG "ISICOM: raise_dtr_rts.\n");
262 #endif
263 	outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
264 	outw(0x0f04, base);
265 	InterruptTheCard(base);
266 	port->status |= (ISI_DTR | ISI_RTS);
267 }
drop_dtr_rts(struct isi_port * port)268 static inline void drop_dtr_rts(struct isi_port * port)
269 {
270 	struct isi_board * card = port->card;
271 	unsigned short base = card->base;
272 	unsigned char channel = port->channel;
273 	short wait=400;
274 	while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
275 	if (wait <= 0) {
276 		printk(KERN_WARNING "ISICOM: Card found busy in drop_dtr_rts.\n");
277 		return;
278 	}
279 #ifdef ISICOM_DEBUG_DTR_RTS
280 	printk(KERN_DEBUG "ISICOM: drop_dtr_rts.\n");
281 #endif
282 	outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
283 	outw(0x0c04, base);
284 	InterruptTheCard(base);
285 	port->status &= ~(ISI_RTS | ISI_DTR);
286 }
287 
kill_queue(struct isi_port * port,short queue)288 static inline void kill_queue(struct isi_port * port, short queue)
289 {
290 	struct isi_board * card = port->card;
291 	unsigned short base = card->base;
292 	unsigned char channel = port->channel;
293 	short wait=400;
294 	while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
295 	if (wait <= 0) {
296 		printk(KERN_WARNING "ISICOM: Card found busy in kill_queue.\n");
297 		return;
298 	}
299 #ifdef ISICOM_DEBUG
300 	printk(KERN_DEBUG "ISICOM: kill_queue 0x%x.\n", queue);
301 #endif
302 	outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
303 	outw((queue << 8) | 0x06, base);
304 	InterruptTheCard(base);
305 }
306 
307 #endif	/*	__KERNEL__	*/
308 
309 #endif	/*	ISICOM_H	*/
310 
311