summaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/keyspan.h
blob: ce966dc4f31a1be5f4a9c89d833ec4f8976cf77f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
/*
  Keyspan USB to Serial Converter driver
 
  (C) Copyright (C) 2000
      Hugh Blemings <hugh@linuxcare.com>
   
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  See http://www.linuxcare.com.au/hugh/keyspan.html for more
  information on this driver.
  
  Code in this driver inspired by and in a number of places taken
  from Brian Warner's original Keyspan-PDA driver.

  This driver has been put together with the support of Innosys, Inc.
  and Keyspan, Inc the manufacturers of the Keyspan USB-serial products.
  Thanks Guys :)
  
  Tip 'o the hat to Linuxcare for supporting staff in their work on
  open source projects.
  
  See keyspan.c for update history.

*/

#ifndef __LINUX_USB_SERIAL_KEYSPAN_H
#define __LINUX_USB_SERIAL_KEYSPAN_H


	/* Function prototypes for Keyspan serial converter */
static int  keyspan_open		(struct usb_serial_port *port,
					 struct file *filp);
static void keyspan_close		(struct usb_serial_port *port,
					 struct file *filp);
static int  keyspan_startup		(struct usb_serial *serial);
static void keyspan_shutdown		(struct usb_serial *serial);
static void keyspan_rx_throttle		(struct usb_serial_port *port);
static void keyspan_rx_unthrottle	(struct usb_serial_port *port);
static int  keyspan_write_room		(struct usb_serial_port *port);
static int  keyspan_write		(struct usb_serial_port *port,
					 int from_user,
					 const unsigned char *buf,
					 int count);
static void keyspan_write_bulk_callback (struct urb *urb);
static void keyspan_read_bulk_callback  (struct urb *urb);
static int  keyspan_chars_in_buffer 	(struct usb_serial_port *port);
static int  keyspan_ioctl		(struct usb_serial_port *port,
					 struct file *file,
					 unsigned int cmd,
					 unsigned long arg);
static void keyspan_set_termios		(struct usb_serial_port *port,
					 struct termios *old);
static void keyspan_break_ctl		(struct usb_serial_port *port,
					 int break_state);
static int  keyspan_fake_startup	(struct usb_serial *serial);

static int  keyspan_usa19_calc_baud	(u32 baud_rate, u8 *rate_hi, 
					 u8 *rate_low);
static void keyspan_usa19_setup_urbs	(struct usb_serial *serial);
static int  keyspan_usa19_send_setup	(struct usb_serial *serial,
					 struct usb_serial_port *port);


	/* Functions from usbserial.c for ezusb firmware handling */
extern int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit);
extern int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *data, int length, __u8 bRequest);

	/* Struct used for firmware */
struct ezusb_hex_record {
	__u16 address;
	__u8 data_size;
	__u8 data[16];
};
	/* Conditionally include firmware images, if they aren't
	   included create a null pointer instead.  Current 
	   firmware images aren't optimised to remove duplicate
	   addresses. */
#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA28
        #include "keyspan_usa28_fw.h"
#else
	static const struct ezusb_hex_record *keyspan_usa28_firmware = NULL;
#endif

#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA28X
        #include "keyspan_usa28x_fw.h"
#else
	static const struct ezusb_hex_record *keyspan_usa28x_firmware = NULL;
#endif

#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA19
        #include "keyspan_usa19_fw.h"
#else
	static const struct ezusb_hex_record *keyspan_usa19_firmware = NULL;
#endif

#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA18X
        #include "keyspan_usa18x_fw.h"
#else
	static const struct ezusb_hex_record *keyspan_usa18x_firmware = NULL;
#endif

#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA19W
        #include "keyspan_usa19w_fw.h"
#else
	static const struct ezusb_hex_record *keyspan_usa19w_firmware = NULL;
#endif


	/* Values used for baud rate calculation - device specific */
#define	KEYSPAN_INVALID_BAUD_RATE		(-1)
#define	KEYSPAN_BAUD_RATE_OK			(0)
#define	USA19_BAUDCLK				(12000000L)

	/* Device info for the Keyspan serial converter */
#define KEYSPAN_VENDOR_ID			(0x06cd)
static __u16	keyspan_vendor_id		= KEYSPAN_VENDOR_ID;

    /* Product IDs for the five products supported, pre-renumeration */
static __u16	keyspan_usa18x_pre_product_id	= 0x0105;	
static __u16	keyspan_usa19_pre_product_id	= 0x0103;	
static __u16	keyspan_usa19w_pre_product_id	= 0x0106;	
static __u16	keyspan_usa28_pre_product_id	= 0x0101;	
static __u16	keyspan_usa28x_pre_product_id	= 0x0102;	

    /* Product IDs post-renumeration */
static __u16	keyspan_usa18x_product_id	= 0x0112;	
static __u16	keyspan_usa19_product_id	= 0x0107;	
static __u16	keyspan_usa19w_product_id	= 0x0108;	
static __u16	keyspan_usa28_product_id	= 0x010f;	
static __u16	keyspan_usa28x_product_id	= 0x0110;	

    /* Structs for the devices, pre and post renumeration.
       These are incomplete at present - HAB 20000708  */
struct usb_serial_device_type keyspan_usa18x_pre_device = {
	name:			"Keyspan USA18X - (prerenumeration)",
	idVendor:		&keyspan_vendor_id,
	idProduct:		&keyspan_usa18x_pre_product_id,
	needs_interrupt_in:	DONT_CARE,
	needs_bulk_in:		DONT_CARE,
	needs_bulk_out:		DONT_CARE,
	num_interrupt_in:	NUM_DONT_CARE,
	num_bulk_in:		NUM_DONT_CARE,
	num_bulk_out:		NUM_DONT_CARE,
	num_ports:		1,
	startup:		keyspan_fake_startup	
};

struct usb_serial_device_type keyspan_usa19_pre_device = {
	name:			"Keyspan USA19 - (prerenumeration)",
	idVendor:		&keyspan_vendor_id,
	idProduct:		&keyspan_usa19_pre_product_id,
	needs_interrupt_in:	DONT_CARE,
	needs_bulk_in:		DONT_CARE,
	needs_bulk_out:		DONT_CARE,
	num_interrupt_in:	NUM_DONT_CARE,
	num_bulk_in:		NUM_DONT_CARE,
	num_bulk_out:		NUM_DONT_CARE,
	num_ports:		1,
	startup:		keyspan_fake_startup	
};


struct usb_serial_device_type keyspan_usa19w_pre_device = {
	name:			"Keyspan USA19W - (prerenumeration)",
	idVendor:		&keyspan_vendor_id,
	idProduct:		&keyspan_usa19w_pre_product_id,
	needs_interrupt_in:	DONT_CARE,
	needs_bulk_in:		DONT_CARE,
	needs_bulk_out:		DONT_CARE,
	num_interrupt_in:	NUM_DONT_CARE,
	num_bulk_in:		NUM_DONT_CARE,
	num_bulk_out:		NUM_DONT_CARE,
	num_ports:		1,
	startup:		keyspan_fake_startup	
};


struct usb_serial_device_type keyspan_usa28_pre_device = {
	name:			"Keyspan USA28 - (prerenumeration)",
	idVendor:		&keyspan_vendor_id,
	idProduct:		&keyspan_usa28_pre_product_id,
	needs_interrupt_in:	DONT_CARE,
	needs_bulk_in:		DONT_CARE,
	needs_bulk_out:		DONT_CARE,
	num_interrupt_in:	NUM_DONT_CARE,
	num_bulk_in:		NUM_DONT_CARE,
	num_bulk_out:		NUM_DONT_CARE,
	num_ports:		2,
	startup:		keyspan_fake_startup	
};

struct usb_serial_device_type keyspan_usa28x_pre_device = {
	name:			"Keyspan USA28X - (prerenumeration)",
	idVendor:		&keyspan_vendor_id,
	idProduct:		&keyspan_usa28x_pre_product_id,
	needs_interrupt_in:	DONT_CARE,
	needs_bulk_in:		DONT_CARE,
	needs_bulk_out:		DONT_CARE,
	num_interrupt_in:	NUM_DONT_CARE,
	num_bulk_in:		NUM_DONT_CARE,
	num_bulk_out:		NUM_DONT_CARE,
	num_ports:		2,
	startup:		keyspan_fake_startup	
};


struct usb_serial_device_type keyspan_usa18x_device = {
	name:			"Keyspan USA18X",
	idVendor:		&keyspan_vendor_id,
	idProduct:		&keyspan_usa18x_product_id,
	needs_interrupt_in:	DONT_CARE,	
	needs_bulk_in:		DONT_CARE,
	needs_bulk_out:		DONT_CARE,
	num_interrupt_in:	NUM_DONT_CARE,
	num_bulk_in:		NUM_DONT_CARE,
	num_bulk_out:		NUM_DONT_CARE,
	num_ports:		1,
	open:			keyspan_open,
	close:			keyspan_close,
	throttle:		keyspan_rx_throttle,
	unthrottle:		keyspan_rx_unthrottle,
	set_termios:		keyspan_set_termios,
};

struct usb_serial_device_type keyspan_usa19_device = {
	name:			"Keyspan USA19",
	idVendor:		&keyspan_vendor_id,
	idProduct:		&keyspan_usa19_product_id,
	needs_interrupt_in:	DONT_CARE,	
	needs_bulk_in:		MUST_HAVE,
	needs_bulk_out:		MUST_HAVE,
	num_interrupt_in:	NUM_DONT_CARE,
	num_bulk_in:		3,
	num_bulk_out:		4,
	num_ports:		1,
	open:			keyspan_open,
	close:			keyspan_close,
	write:			keyspan_write,
	write_room:		keyspan_write_room,
	write_bulk_callback: 	keyspan_write_bulk_callback,
	read_int_callback:	keyspan_read_bulk_callback,
	chars_in_buffer:	keyspan_chars_in_buffer,
	throttle:		keyspan_rx_throttle,
	unthrottle:		keyspan_rx_unthrottle,
	ioctl:			keyspan_ioctl,
	set_termios:		keyspan_set_termios,
	break_ctl:		keyspan_break_ctl,
	startup:		keyspan_startup,
	shutdown:		keyspan_shutdown,
};


struct usb_serial_device_type keyspan_usa19w_device = {
	name:			"Keyspan USA19W",
	idVendor:		&keyspan_vendor_id,
	idProduct:		&keyspan_usa19w_product_id,
	needs_interrupt_in:	DONT_CARE,	
	needs_bulk_in:		DONT_CARE,
	needs_bulk_out:		DONT_CARE,
	num_interrupt_in:	NUM_DONT_CARE,
	num_bulk_in:		NUM_DONT_CARE,
	num_bulk_out:		NUM_DONT_CARE,
	num_ports:		1,
	open:			keyspan_open,
	close:			keyspan_close,
	throttle:		keyspan_rx_throttle,
	unthrottle:		keyspan_rx_unthrottle,
	set_termios:		keyspan_set_termios,
};


struct usb_serial_device_type keyspan_usa28_device = {
	name:			"Keyspan USA28",
	idVendor:		&keyspan_vendor_id,
	idProduct:		&keyspan_usa28_product_id,
	needs_interrupt_in:	DONT_CARE,	
	needs_bulk_in:		DONT_CARE,
	needs_bulk_out:		DONT_CARE,
	num_interrupt_in:	NUM_DONT_CARE,
	num_bulk_in:		NUM_DONT_CARE,
	num_bulk_out:		NUM_DONT_CARE,
	num_ports:		2,
	open:			keyspan_open,
	close:			keyspan_close,
	throttle:		keyspan_rx_throttle,
	unthrottle:		keyspan_rx_unthrottle,
	set_termios:		keyspan_set_termios,
};


struct usb_serial_device_type keyspan_usa28x_device = {
	name:			"Keyspan USA28X",
	idVendor:		&keyspan_vendor_id,
	idProduct:		&keyspan_usa28x_product_id,
	needs_interrupt_in:	DONT_CARE,	
	needs_bulk_in:		DONT_CARE,
	needs_bulk_out:		DONT_CARE,
	num_interrupt_in:	NUM_DONT_CARE,
	num_bulk_in:		NUM_DONT_CARE,
	num_bulk_out:		NUM_DONT_CARE,
	num_ports:		2,
	open:			keyspan_open,
	close:			keyspan_close,
	write:			keyspan_write,
	write_room:		keyspan_write_room,
	write_bulk_callback: 	keyspan_write_bulk_callback,
	read_int_callback:	keyspan_read_bulk_callback,
	chars_in_buffer:	keyspan_chars_in_buffer,
	throttle:		keyspan_rx_throttle,
	unthrottle:		keyspan_rx_unthrottle,
	ioctl:			keyspan_ioctl,
	set_termios:		keyspan_set_termios,
	break_ctl:		keyspan_break_ctl,
	startup:		keyspan_startup,
	shutdown:		keyspan_shutdown,

				

};



#endif