diff options
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r-- | drivers/usb/serial/Kconfig | 8 | ||||
-rw-r--r-- | drivers/usb/serial/Makefile | 1 | ||||
-rw-r--r-- | drivers/usb/serial/airprime.c | 353 | ||||
-rw-r--r-- | drivers/usb/serial/cp2101.c | 13 | ||||
-rw-r--r-- | drivers/usb/serial/digi_acceleport.c | 3 | ||||
-rw-r--r-- | drivers/usb/serial/io_ti.c | 1860 | ||||
-rw-r--r-- | drivers/usb/serial/ipaq.c | 3 | ||||
-rw-r--r-- | drivers/usb/serial/ir-usb.c | 490 | ||||
-rw-r--r-- | drivers/usb/serial/keyspan.h | 5 | ||||
-rw-r--r-- | drivers/usb/serial/keyspan_pda.c | 2 | ||||
-rw-r--r-- | drivers/usb/serial/kl5kusb105.c | 2 | ||||
-rw-r--r-- | drivers/usb/serial/option.c | 2 | ||||
-rw-r--r-- | drivers/usb/serial/usb-serial.c | 13 | ||||
-rw-r--r-- | drivers/usb/serial/usb_debug.c | 9 |
14 files changed, 1155 insertions, 1609 deletions
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index 9a7681b55266..8878c1767fc8 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig | |||
@@ -64,14 +64,6 @@ config USB_SERIAL_AIRCABLE | |||
64 | To compile this driver as a module, choose M here: the module | 64 | To compile this driver as a module, choose M here: the module |
65 | will be called aircable. | 65 | will be called aircable. |
66 | 66 | ||
67 | config USB_SERIAL_AIRPRIME | ||
68 | tristate "USB AirPrime CDMA Wireless Driver" | ||
69 | help | ||
70 | Say Y here if you want to use a AirPrime CDMA Wireless PC card. | ||
71 | |||
72 | To compile this driver as a module, choose M here: the | ||
73 | module will be called airprime. | ||
74 | |||
75 | config USB_SERIAL_ARK3116 | 67 | config USB_SERIAL_ARK3116 |
76 | tristate "USB ARK Micro 3116 USB Serial Driver" | 68 | tristate "USB ARK Micro 3116 USB Serial Driver" |
77 | help | 69 | help |
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile index 17a762ab6769..6047f818adfe 100644 --- a/drivers/usb/serial/Makefile +++ b/drivers/usb/serial/Makefile | |||
@@ -12,7 +12,6 @@ usbserial-obj-$(CONFIG_USB_EZUSB) += ezusb.o | |||
12 | usbserial-objs := usb-serial.o generic.o bus.o $(usbserial-obj-y) | 12 | usbserial-objs := usb-serial.o generic.o bus.o $(usbserial-obj-y) |
13 | 13 | ||
14 | obj-$(CONFIG_USB_SERIAL_AIRCABLE) += aircable.o | 14 | obj-$(CONFIG_USB_SERIAL_AIRCABLE) += aircable.o |
15 | obj-$(CONFIG_USB_SERIAL_AIRPRIME) += airprime.o | ||
16 | obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o | 15 | obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o |
17 | obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o | 16 | obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o |
18 | obj-$(CONFIG_USB_SERIAL_CH341) += ch341.o | 17 | obj-$(CONFIG_USB_SERIAL_CH341) += ch341.o |
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c deleted file mode 100644 index 0798c14ce787..000000000000 --- a/drivers/usb/serial/airprime.c +++ /dev/null | |||
@@ -1,353 +0,0 @@ | |||
1 | /* | ||
2 | * AirPrime CDMA Wireless Serial USB driver | ||
3 | * | ||
4 | * Copyright (C) 2005-2006 Greg Kroah-Hartman <gregkh@suse.de> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License version | ||
8 | * 2 as published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/tty.h> | ||
14 | #include <linux/tty_flip.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/usb.h> | ||
17 | #include <linux/usb/serial.h> | ||
18 | |||
19 | static struct usb_device_id id_table [] = { | ||
20 | { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */ | ||
21 | { }, | ||
22 | }; | ||
23 | MODULE_DEVICE_TABLE(usb, id_table); | ||
24 | |||
25 | #define URB_TRANSFER_BUFFER_SIZE 4096 | ||
26 | #define NUM_READ_URBS 4 | ||
27 | #define NUM_WRITE_URBS 4 | ||
28 | #define NUM_BULK_EPS 3 | ||
29 | #define MAX_BULK_EPS 6 | ||
30 | |||
31 | /* if overridden by the user, then use their value for the size of the | ||
32 | * read and write urbs, and the number of endpoints */ | ||
33 | static int buffer_size = URB_TRANSFER_BUFFER_SIZE; | ||
34 | static int endpoints = NUM_BULK_EPS; | ||
35 | static int debug; | ||
36 | struct airprime_private { | ||
37 | spinlock_t lock; | ||
38 | int outstanding_urbs; | ||
39 | int throttled; | ||
40 | struct urb *read_urbp[NUM_READ_URBS]; | ||
41 | |||
42 | /* Settings for the port */ | ||
43 | int rts_state; /* Handshaking pins (outputs) */ | ||
44 | int dtr_state; | ||
45 | int cts_state; /* Handshaking pins (inputs) */ | ||
46 | int dsr_state; | ||
47 | int dcd_state; | ||
48 | int ri_state; | ||
49 | }; | ||
50 | |||
51 | static int airprime_send_setup(struct usb_serial_port *port) | ||
52 | { | ||
53 | struct usb_serial *serial = port->serial; | ||
54 | struct airprime_private *priv; | ||
55 | |||
56 | dbg("%s", __func__); | ||
57 | |||
58 | if (port->number != 0) | ||
59 | return 0; | ||
60 | |||
61 | priv = usb_get_serial_port_data(port); | ||
62 | |||
63 | if (port->tty) { | ||
64 | int val = 0; | ||
65 | if (priv->dtr_state) | ||
66 | val |= 0x01; | ||
67 | if (priv->rts_state) | ||
68 | val |= 0x02; | ||
69 | |||
70 | return usb_control_msg(serial->dev, | ||
71 | usb_rcvctrlpipe(serial->dev, 0), | ||
72 | 0x22, 0x21, val, 0, NULL, 0, | ||
73 | USB_CTRL_SET_TIMEOUT); | ||
74 | } | ||
75 | |||
76 | return 0; | ||
77 | } | ||
78 | |||
79 | static void airprime_read_bulk_callback(struct urb *urb) | ||
80 | { | ||
81 | struct usb_serial_port *port = urb->context; | ||
82 | unsigned char *data = urb->transfer_buffer; | ||
83 | struct tty_struct *tty; | ||
84 | int result; | ||
85 | int status = urb->status; | ||
86 | |||
87 | dbg("%s - port %d", __func__, port->number); | ||
88 | |||
89 | if (status) { | ||
90 | dbg("%s - nonzero read bulk status received: %d", | ||
91 | __func__, status); | ||
92 | return; | ||
93 | } | ||
94 | usb_serial_debug_data(debug, &port->dev, __func__, | ||
95 | urb->actual_length, data); | ||
96 | |||
97 | tty = port->tty; | ||
98 | if (tty && urb->actual_length) { | ||
99 | tty_insert_flip_string(tty, data, urb->actual_length); | ||
100 | tty_flip_buffer_push(tty); | ||
101 | } | ||
102 | |||
103 | result = usb_submit_urb(urb, GFP_ATOMIC); | ||
104 | if (result) | ||
105 | dev_err(&port->dev, | ||
106 | "%s - failed resubmitting read urb, error %d\n", | ||
107 | __func__, result); | ||
108 | return; | ||
109 | } | ||
110 | |||
111 | static void airprime_write_bulk_callback(struct urb *urb) | ||
112 | { | ||
113 | struct usb_serial_port *port = urb->context; | ||
114 | struct airprime_private *priv = usb_get_serial_port_data(port); | ||
115 | int status = urb->status; | ||
116 | unsigned long flags; | ||
117 | |||
118 | dbg("%s - port %d", __func__, port->number); | ||
119 | |||
120 | /* free up the transfer buffer, as usb_free_urb() does not do this */ | ||
121 | kfree(urb->transfer_buffer); | ||
122 | |||
123 | if (status) | ||
124 | dbg("%s - nonzero write bulk status received: %d", | ||
125 | __func__, status); | ||
126 | spin_lock_irqsave(&priv->lock, flags); | ||
127 | --priv->outstanding_urbs; | ||
128 | spin_unlock_irqrestore(&priv->lock, flags); | ||
129 | |||
130 | usb_serial_port_softint(port); | ||
131 | } | ||
132 | |||
133 | static int airprime_open(struct usb_serial_port *port, struct file *filp) | ||
134 | { | ||
135 | struct airprime_private *priv = usb_get_serial_port_data(port); | ||
136 | struct usb_serial *serial = port->serial; | ||
137 | struct urb *urb; | ||
138 | char *buffer = NULL; | ||
139 | int i; | ||
140 | int result = 0; | ||
141 | |||
142 | dbg("%s - port %d", __func__, port->number); | ||
143 | |||
144 | /* initialize our private data structure if it isn't already created */ | ||
145 | if (!priv) { | ||
146 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | ||
147 | if (!priv) { | ||
148 | result = -ENOMEM; | ||
149 | goto out; | ||
150 | } | ||
151 | spin_lock_init(&priv->lock); | ||
152 | usb_set_serial_port_data(port, priv); | ||
153 | } | ||
154 | |||
155 | /* Set some sane defaults */ | ||
156 | priv->rts_state = 1; | ||
157 | priv->dtr_state = 1; | ||
158 | |||
159 | for (i = 0; i < NUM_READ_URBS; ++i) { | ||
160 | buffer = kmalloc(buffer_size, GFP_KERNEL); | ||
161 | if (!buffer) { | ||
162 | dev_err(&port->dev, "%s - out of memory.\n", | ||
163 | __func__); | ||
164 | result = -ENOMEM; | ||
165 | goto errout; | ||
166 | } | ||
167 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
168 | if (!urb) { | ||
169 | kfree(buffer); | ||
170 | dev_err(&port->dev, "%s - no more urbs?\n", | ||
171 | __func__); | ||
172 | result = -ENOMEM; | ||
173 | goto errout; | ||
174 | } | ||
175 | usb_fill_bulk_urb(urb, serial->dev, | ||
176 | usb_rcvbulkpipe(serial->dev, | ||
177 | port->bulk_out_endpointAddress), | ||
178 | buffer, buffer_size, | ||
179 | airprime_read_bulk_callback, port); | ||
180 | result = usb_submit_urb(urb, GFP_KERNEL); | ||
181 | if (result) { | ||
182 | usb_free_urb(urb); | ||
183 | kfree(buffer); | ||
184 | dev_err(&port->dev, | ||
185 | "%s - failed submitting read urb %d for port %d, error %d\n", | ||
186 | __func__, i, port->number, result); | ||
187 | goto errout; | ||
188 | } | ||
189 | /* remember this urb so we can kill it when the | ||
190 | port is closed */ | ||
191 | priv->read_urbp[i] = urb; | ||
192 | } | ||
193 | |||
194 | airprime_send_setup(port); | ||
195 | |||
196 | goto out; | ||
197 | |||
198 | errout: | ||
199 | /* some error happened, cancel any submitted urbs and clean up | ||
200 | anything that got allocated successfully */ | ||
201 | |||
202 | while (i-- != 0) { | ||
203 | urb = priv->read_urbp[i]; | ||
204 | buffer = urb->transfer_buffer; | ||
205 | usb_kill_urb(urb); | ||
206 | usb_free_urb(urb); | ||
207 | kfree(buffer); | ||
208 | } | ||
209 | |||
210 | out: | ||
211 | return result; | ||
212 | } | ||
213 | |||
214 | static void airprime_close(struct usb_serial_port *port, struct file *filp) | ||
215 | { | ||
216 | struct airprime_private *priv = usb_get_serial_port_data(port); | ||
217 | int i; | ||
218 | |||
219 | dbg("%s - port %d", __func__, port->number); | ||
220 | |||
221 | priv->rts_state = 0; | ||
222 | priv->dtr_state = 0; | ||
223 | |||
224 | mutex_lock(&port->serial->disc_mutex); | ||
225 | if (!port->serial->disconnected) | ||
226 | airprime_send_setup(port); | ||
227 | mutex_unlock(&port->serial->disc_mutex); | ||
228 | |||
229 | for (i = 0; i < NUM_READ_URBS; ++i) { | ||
230 | usb_kill_urb(priv->read_urbp[i]); | ||
231 | kfree(priv->read_urbp[i]->transfer_buffer); | ||
232 | usb_free_urb(priv->read_urbp[i]); | ||
233 | } | ||
234 | |||
235 | /* free up private structure */ | ||
236 | kfree(priv); | ||
237 | usb_set_serial_port_data(port, NULL); | ||
238 | } | ||
239 | |||
240 | static int airprime_write(struct usb_serial_port *port, | ||
241 | const unsigned char *buf, int count) | ||
242 | { | ||
243 | struct airprime_private *priv = usb_get_serial_port_data(port); | ||
244 | struct usb_serial *serial = port->serial; | ||
245 | struct urb *urb; | ||
246 | unsigned char *buffer; | ||
247 | unsigned long flags; | ||
248 | int status; | ||
249 | dbg("%s - port %d", __func__, port->number); | ||
250 | |||
251 | spin_lock_irqsave(&priv->lock, flags); | ||
252 | if (priv->outstanding_urbs > NUM_WRITE_URBS) { | ||
253 | spin_unlock_irqrestore(&priv->lock, flags); | ||
254 | dbg("%s - write limit hit\n", __func__); | ||
255 | return 0; | ||
256 | } | ||
257 | spin_unlock_irqrestore(&priv->lock, flags); | ||
258 | buffer = kmalloc(count, GFP_ATOMIC); | ||
259 | if (!buffer) { | ||
260 | dev_err(&port->dev, "out of memory\n"); | ||
261 | return -ENOMEM; | ||
262 | } | ||
263 | urb = usb_alloc_urb(0, GFP_ATOMIC); | ||
264 | if (!urb) { | ||
265 | dev_err(&port->dev, "no more free urbs\n"); | ||
266 | kfree(buffer); | ||
267 | return -ENOMEM; | ||
268 | } | ||
269 | memcpy(buffer, buf, count); | ||
270 | |||
271 | usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); | ||
272 | |||
273 | usb_fill_bulk_urb(urb, serial->dev, | ||
274 | usb_sndbulkpipe(serial->dev, | ||
275 | port->bulk_out_endpointAddress), | ||
276 | buffer, count, | ||
277 | airprime_write_bulk_callback, port); | ||
278 | |||
279 | /* send it down the pipe */ | ||
280 | status = usb_submit_urb(urb, GFP_ATOMIC); | ||
281 | if (status) { | ||
282 | dev_err(&port->dev, | ||
283 | "%s - usb_submit_urb(write bulk) failed with status = %d\n", | ||
284 | __func__, status); | ||
285 | count = status; | ||
286 | kfree(buffer); | ||
287 | } else { | ||
288 | spin_lock_irqsave(&priv->lock, flags); | ||
289 | ++priv->outstanding_urbs; | ||
290 | spin_unlock_irqrestore(&priv->lock, flags); | ||
291 | } | ||
292 | /* we are done with this urb, so let the host driver | ||
293 | * really free it when it is finished with it */ | ||
294 | usb_free_urb(urb); | ||
295 | return count; | ||
296 | } | ||
297 | |||
298 | static struct usb_driver airprime_driver = { | ||
299 | .name = "airprime", | ||
300 | .probe = usb_serial_probe, | ||
301 | .disconnect = usb_serial_disconnect, | ||
302 | .id_table = id_table, | ||
303 | .no_dynamic_id = 1, | ||
304 | }; | ||
305 | |||
306 | static struct usb_serial_driver airprime_device = { | ||
307 | .driver = { | ||
308 | .owner = THIS_MODULE, | ||
309 | .name = "airprime", | ||
310 | }, | ||
311 | .usb_driver = &airprime_driver, | ||
312 | .id_table = id_table, | ||
313 | .open = airprime_open, | ||
314 | .close = airprime_close, | ||
315 | .write = airprime_write, | ||
316 | }; | ||
317 | |||
318 | static int __init airprime_init(void) | ||
319 | { | ||
320 | int retval; | ||
321 | |||
322 | airprime_device.num_ports = endpoints; | ||
323 | if (endpoints < 0 || endpoints >= MAX_BULK_EPS) | ||
324 | airprime_device.num_ports = NUM_BULK_EPS; | ||
325 | |||
326 | retval = usb_serial_register(&airprime_device); | ||
327 | if (retval) | ||
328 | return retval; | ||
329 | retval = usb_register(&airprime_driver); | ||
330 | if (retval) | ||
331 | usb_serial_deregister(&airprime_device); | ||
332 | return retval; | ||
333 | } | ||
334 | |||
335 | static void __exit airprime_exit(void) | ||
336 | { | ||
337 | dbg("%s", __func__); | ||
338 | |||
339 | usb_deregister(&airprime_driver); | ||
340 | usb_serial_deregister(&airprime_device); | ||
341 | } | ||
342 | |||
343 | module_init(airprime_init); | ||
344 | module_exit(airprime_exit); | ||
345 | MODULE_LICENSE("GPL"); | ||
346 | |||
347 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
348 | MODULE_PARM_DESC(debug, "Debug enabled"); | ||
349 | module_param(buffer_size, int, 0); | ||
350 | MODULE_PARM_DESC(buffer_size, | ||
351 | "Size of the transfer buffers in bytes (default 4096)"); | ||
352 | module_param(endpoints, int, 0); | ||
353 | MODULE_PARM_DESC(endpoints, "Number of bulk EPs to configure (default 3)"); | ||
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index f5b57b196c5a..2bc5576c443a 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c | |||
@@ -365,8 +365,8 @@ static void cp2101_close (struct usb_serial_port *port, struct file * filp) | |||
365 | static void cp2101_get_termios (struct usb_serial_port *port) | 365 | static void cp2101_get_termios (struct usb_serial_port *port) |
366 | { | 366 | { |
367 | unsigned int cflag, modem_ctl[4]; | 367 | unsigned int cflag, modem_ctl[4]; |
368 | int baud; | 368 | unsigned int baud; |
369 | int bits; | 369 | unsigned int bits; |
370 | 370 | ||
371 | dbg("%s - port %d", __func__, port->number); | 371 | dbg("%s - port %d", __func__, port->number); |
372 | 372 | ||
@@ -498,7 +498,7 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
498 | struct ktermios *old_termios) | 498 | struct ktermios *old_termios) |
499 | { | 499 | { |
500 | unsigned int cflag, old_cflag; | 500 | unsigned int cflag, old_cflag; |
501 | int baud=0, bits; | 501 | unsigned int baud = 0, bits; |
502 | unsigned int modem_ctl[4]; | 502 | unsigned int modem_ctl[4]; |
503 | 503 | ||
504 | dbg("%s - port %d", __func__, port->number); | 504 | dbg("%s - port %d", __func__, port->number); |
@@ -654,7 +654,7 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
654 | static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file, | 654 | static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file, |
655 | unsigned int set, unsigned int clear) | 655 | unsigned int set, unsigned int clear) |
656 | { | 656 | { |
657 | int control = 0; | 657 | unsigned int control = 0; |
658 | 658 | ||
659 | dbg("%s - port %d", __func__, port->number); | 659 | dbg("%s - port %d", __func__, port->number); |
660 | 660 | ||
@@ -683,7 +683,8 @@ static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file, | |||
683 | 683 | ||
684 | static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file) | 684 | static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file) |
685 | { | 685 | { |
686 | int control, result; | 686 | unsigned int control; |
687 | int result; | ||
687 | 688 | ||
688 | dbg("%s - port %d", __func__, port->number); | 689 | dbg("%s - port %d", __func__, port->number); |
689 | 690 | ||
@@ -703,7 +704,7 @@ static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file) | |||
703 | 704 | ||
704 | static void cp2101_break_ctl (struct usb_serial_port *port, int break_state) | 705 | static void cp2101_break_ctl (struct usb_serial_port *port, int break_state) |
705 | { | 706 | { |
706 | int state; | 707 | unsigned int state; |
707 | 708 | ||
708 | dbg("%s - port %d", __func__, port->number); | 709 | dbg("%s - port %d", __func__, port->number); |
709 | if (break_state == 0) | 710 | if (break_state == 0) |
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index 04a56f300ea6..28bc6fcf44f0 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c | |||
@@ -229,8 +229,6 @@ | |||
229 | * in case a wake up is lost. | 229 | * in case a wake up is lost. |
230 | * - Following Documentation/DocBook/kernel-locking.pdf no spin locks | 230 | * - Following Documentation/DocBook/kernel-locking.pdf no spin locks |
231 | * are held when calling copy_to/from_user or printk. | 231 | * are held when calling copy_to/from_user or printk. |
232 | * | ||
233 | * $Id: digi_acceleport.c,v 1.80.1.2 2000/11/02 05:45:08 root Exp $ | ||
234 | */ | 232 | */ |
235 | 233 | ||
236 | #include <linux/kernel.h> | 234 | #include <linux/kernel.h> |
@@ -573,6 +571,7 @@ static struct usb_serial_driver digi_acceleport_4_device = { | |||
573 | static long cond_wait_interruptible_timeout_irqrestore( | 571 | static long cond_wait_interruptible_timeout_irqrestore( |
574 | wait_queue_head_t *q, long timeout, | 572 | wait_queue_head_t *q, long timeout, |
575 | spinlock_t *lock, unsigned long flags) | 573 | spinlock_t *lock, unsigned long flags) |
574 | __releases(lock) | ||
576 | { | 575 | { |
577 | DEFINE_WAIT(wait); | 576 | DEFINE_WAIT(wait); |
578 | 577 | ||
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 61daea3f7b2d..a58822a14a87 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c | |||
@@ -18,8 +18,8 @@ | |||
18 | * | 18 | * |
19 | * Version history: | 19 | * Version history: |
20 | * | 20 | * |
21 | * July 11, 2002 Removed 4 port device structure since all TI UMP | 21 | * July 11, 2002 Removed 4 port device structure since all TI UMP |
22 | * chips have only 2 ports | 22 | * chips have only 2 ports |
23 | * David Iacovelli (davidi@ionetworks.com) | 23 | * David Iacovelli (davidi@ionetworks.com) |
24 | * | 24 | * |
25 | */ | 25 | */ |
@@ -38,7 +38,7 @@ | |||
38 | #include <linux/serial.h> | 38 | #include <linux/serial.h> |
39 | #include <linux/ioctl.h> | 39 | #include <linux/ioctl.h> |
40 | #include <linux/firmware.h> | 40 | #include <linux/firmware.h> |
41 | #include <asm/uaccess.h> | 41 | #include <linux/uaccess.h> |
42 | #include <linux/usb.h> | 42 | #include <linux/usb.h> |
43 | #include <linux/usb/serial.h> | 43 | #include <linux/usb/serial.h> |
44 | 44 | ||
@@ -57,18 +57,19 @@ | |||
57 | 57 | ||
58 | 58 | ||
59 | struct edgeport_uart_buf_desc { | 59 | struct edgeport_uart_buf_desc { |
60 | __u32 count; // Number of bytes currently in buffer | 60 | __u32 count; /* Number of bytes currently in buffer */ |
61 | }; | 61 | }; |
62 | 62 | ||
63 | /* different hardware types */ | 63 | /* different hardware types */ |
64 | #define HARDWARE_TYPE_930 0 | 64 | #define HARDWARE_TYPE_930 0 |
65 | #define HARDWARE_TYPE_TIUMP 1 | 65 | #define HARDWARE_TYPE_TIUMP 1 |
66 | 66 | ||
67 | // IOCTL_PRIVATE_TI_GET_MODE Definitions | 67 | /* IOCTL_PRIVATE_TI_GET_MODE Definitions */ |
68 | #define TI_MODE_CONFIGURING 0 // Device has not entered start device | 68 | #define TI_MODE_CONFIGURING 0 /* Device has not entered start device */ |
69 | #define TI_MODE_BOOT 1 // Staying in boot mode | 69 | #define TI_MODE_BOOT 1 /* Staying in boot mode */ |
70 | #define TI_MODE_DOWNLOAD 2 // Made it to download mode | 70 | #define TI_MODE_DOWNLOAD 2 /* Made it to download mode */ |
71 | #define TI_MODE_TRANSITIONING 3 // Currently in boot mode but transitioning to download mode | 71 | #define TI_MODE_TRANSITIONING 3 /* Currently in boot mode but |
72 | transitioning to download mode */ | ||
72 | 73 | ||
73 | /* read urb state */ | 74 | /* read urb state */ |
74 | #define EDGE_READ_URB_RUNNING 0 | 75 | #define EDGE_READ_URB_RUNNING 0 |
@@ -82,10 +83,9 @@ struct edgeport_uart_buf_desc { | |||
82 | 83 | ||
83 | 84 | ||
84 | /* Product information read from the Edgeport */ | 85 | /* Product information read from the Edgeport */ |
85 | struct product_info | 86 | struct product_info { |
86 | { | 87 | int TiMode; /* Current TI Mode */ |
87 | int TiMode; // Current TI Mode | 88 | __u8 hardware_type; /* Type of hardware */ |
88 | __u8 hardware_type; // Type of hardware | ||
89 | } __attribute__((packed)); | 89 | } __attribute__((packed)); |
90 | 90 | ||
91 | /* circular buffer */ | 91 | /* circular buffer */ |
@@ -116,7 +116,7 @@ struct edgeport_port { | |||
116 | happen */ | 116 | happen */ |
117 | struct edgeport_serial *edge_serial; | 117 | struct edgeport_serial *edge_serial; |
118 | struct usb_serial_port *port; | 118 | struct usb_serial_port *port; |
119 | __u8 bUartMode; /* Port type, 0: RS232, etc. */ | 119 | __u8 bUartMode; /* Port type, 0: RS232, etc. */ |
120 | spinlock_t ep_lock; | 120 | spinlock_t ep_lock; |
121 | int ep_read_urb_state; | 121 | int ep_read_urb_state; |
122 | int ep_write_urb_in_use; | 122 | int ep_write_urb_in_use; |
@@ -125,8 +125,9 @@ struct edgeport_port { | |||
125 | 125 | ||
126 | struct edgeport_serial { | 126 | struct edgeport_serial { |
127 | struct product_info product_info; | 127 | struct product_info product_info; |
128 | u8 TI_I2C_Type; // Type of I2C in UMP | 128 | u8 TI_I2C_Type; /* Type of I2C in UMP */ |
129 | u8 TiReadI2C; // Set to TRUE if we have read the I2c in Boot Mode | 129 | u8 TiReadI2C; /* Set to TRUE if we have read the |
130 | I2c in Boot Mode */ | ||
130 | struct mutex es_lock; | 131 | struct mutex es_lock; |
131 | int num_ports_open; | 132 | int num_ports_open; |
132 | struct usb_serial *serial; | 133 | struct usb_serial *serial; |
@@ -214,7 +215,7 @@ static struct usb_device_id id_table_combined [] = { | |||
214 | { } | 215 | { } |
215 | }; | 216 | }; |
216 | 217 | ||
217 | MODULE_DEVICE_TABLE (usb, id_table_combined); | 218 | MODULE_DEVICE_TABLE(usb, id_table_combined); |
218 | 219 | ||
219 | static struct usb_driver io_driver = { | 220 | static struct usb_driver io_driver = { |
220 | .name = "io_ti", | 221 | .name = "io_ti", |
@@ -231,19 +232,19 @@ static unsigned short OperationalBuildNumber; | |||
231 | 232 | ||
232 | static int debug; | 233 | static int debug; |
233 | 234 | ||
234 | static int TIStayInBootMode = 0; | ||
235 | static int low_latency = EDGE_LOW_LATENCY; | 235 | static int low_latency = EDGE_LOW_LATENCY; |
236 | static int closing_wait = EDGE_CLOSING_WAIT; | 236 | static int closing_wait = EDGE_CLOSING_WAIT; |
237 | static int ignore_cpu_rev = 0; | 237 | static int ignore_cpu_rev; |
238 | static int default_uart_mode = 0; /* RS232 */ | 238 | static int default_uart_mode; /* RS232 */ |
239 | |||
240 | 239 | ||
241 | static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned char *data, int length); | 240 | static void edge_tty_recv(struct device *dev, struct tty_struct *tty, |
241 | unsigned char *data, int length); | ||
242 | 242 | ||
243 | static void stop_read(struct edgeport_port *edge_port); | 243 | static void stop_read(struct edgeport_port *edge_port); |
244 | static int restart_read(struct edgeport_port *edge_port); | 244 | static int restart_read(struct edgeport_port *edge_port); |
245 | 245 | ||
246 | static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old_termios); | 246 | static void edge_set_termios(struct usb_serial_port *port, |
247 | struct ktermios *old_termios); | ||
247 | static void edge_send(struct usb_serial_port *port); | 248 | static void edge_send(struct usb_serial_port *port); |
248 | 249 | ||
249 | /* sysfs attributes */ | 250 | /* sysfs attributes */ |
@@ -262,87 +263,57 @@ static unsigned int edge_buf_get(struct edge_buf *eb, char *buf, | |||
262 | unsigned int count); | 263 | unsigned int count); |
263 | 264 | ||
264 | 265 | ||
265 | static int TIReadVendorRequestSync (struct usb_device *dev, | 266 | static int ti_vread_sync(struct usb_device *dev, __u8 request, |
266 | __u8 request, | 267 | __u16 value, __u16 index, u8 *data, int size) |
267 | __u16 value, | ||
268 | __u16 index, | ||
269 | u8 *data, | ||
270 | int size) | ||
271 | { | 268 | { |
272 | int status; | 269 | int status; |
273 | 270 | ||
274 | status = usb_control_msg (dev, | 271 | status = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request, |
275 | usb_rcvctrlpipe(dev, 0), | 272 | (USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN), |
276 | request, | 273 | value, index, data, size, 1000); |
277 | (USB_TYPE_VENDOR | | ||
278 | USB_RECIP_DEVICE | | ||
279 | USB_DIR_IN), | ||
280 | value, | ||
281 | index, | ||
282 | data, | ||
283 | size, | ||
284 | 1000); | ||
285 | if (status < 0) | 274 | if (status < 0) |
286 | return status; | 275 | return status; |
287 | if (status != size) { | 276 | if (status != size) { |
288 | dbg ("%s - wanted to write %d, but only wrote %d", | 277 | dbg("%s - wanted to write %d, but only wrote %d", |
289 | __func__, size, status); | 278 | __func__, size, status); |
290 | return -ECOMM; | 279 | return -ECOMM; |
291 | } | 280 | } |
292 | return 0; | 281 | return 0; |
293 | } | 282 | } |
294 | 283 | ||
295 | static int TISendVendorRequestSync (struct usb_device *dev, | 284 | static int ti_vsend_sync(struct usb_device *dev, __u8 request, |
296 | __u8 request, | 285 | __u16 value, __u16 index, u8 *data, int size) |
297 | __u16 value, | ||
298 | __u16 index, | ||
299 | u8 *data, | ||
300 | int size) | ||
301 | { | 286 | { |
302 | int status; | 287 | int status; |
303 | 288 | ||
304 | status = usb_control_msg (dev, | 289 | status = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request, |
305 | usb_sndctrlpipe(dev, 0), | 290 | (USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT), |
306 | request, | 291 | value, index, data, size, 1000); |
307 | (USB_TYPE_VENDOR | | ||
308 | USB_RECIP_DEVICE | | ||
309 | USB_DIR_OUT), | ||
310 | value, | ||
311 | index, | ||
312 | data, | ||
313 | size, | ||
314 | 1000); | ||
315 | if (status < 0) | 292 | if (status < 0) |
316 | return status; | 293 | return status; |
317 | if (status != size) { | 294 | if (status != size) { |
318 | dbg ("%s - wanted to write %d, but only wrote %d", | 295 | dbg("%s - wanted to write %d, but only wrote %d", |
319 | __func__, size, status); | 296 | __func__, size, status); |
320 | return -ECOMM; | 297 | return -ECOMM; |
321 | } | 298 | } |
322 | return 0; | 299 | return 0; |
323 | } | 300 | } |
324 | 301 | ||
325 | static int TIWriteCommandSync (struct usb_device *dev, __u8 command, | 302 | static int send_cmd(struct usb_device *dev, __u8 command, |
326 | __u8 moduleid, __u16 value, u8 *data, | 303 | __u8 moduleid, __u16 value, u8 *data, |
327 | int size) | 304 | int size) |
328 | { | 305 | { |
329 | return TISendVendorRequestSync (dev, | 306 | return ti_vsend_sync(dev, command, value, moduleid, data, size); |
330 | command, // Request | ||
331 | value, // wValue | ||
332 | moduleid, // wIndex | ||
333 | data, // TransferBuffer | ||
334 | size); // TransferBufferLength | ||
335 | |||
336 | } | 307 | } |
337 | 308 | ||
338 | /* clear tx/rx buffers and fifo in TI UMP */ | 309 | /* clear tx/rx buffers and fifo in TI UMP */ |
339 | static int TIPurgeDataSync (struct usb_serial_port *port, __u16 mask) | 310 | static int purge_port(struct usb_serial_port *port, __u16 mask) |
340 | { | 311 | { |
341 | int port_number = port->number - port->serial->minor; | 312 | int port_number = port->number - port->serial->minor; |
342 | 313 | ||
343 | dbg ("%s - port %d, mask %x", __func__, port_number, mask); | 314 | dbg("%s - port %d, mask %x", __func__, port_number, mask); |
344 | 315 | ||
345 | return TIWriteCommandSync (port->serial->dev, | 316 | return send_cmd(port->serial->dev, |
346 | UMPC_PURGE_PORT, | 317 | UMPC_PURGE_PORT, |
347 | (__u8)(UMPM_UART1_PORT + port_number), | 318 | (__u8)(UMPM_UART1_PORT + port_number), |
348 | mask, | 319 | mask, |
@@ -351,92 +322,87 @@ static int TIPurgeDataSync (struct usb_serial_port *port, __u16 mask) | |||
351 | } | 322 | } |
352 | 323 | ||
353 | /** | 324 | /** |
354 | * TIReadDownloadMemory - Read edgeport memory from TI chip | 325 | * read_download_mem - Read edgeport memory from TI chip |
355 | * @dev: usb device pointer | 326 | * @dev: usb device pointer |
356 | * @start_address: Device CPU address at which to read | 327 | * @start_address: Device CPU address at which to read |
357 | * @length: Length of above data | 328 | * @length: Length of above data |
358 | * @address_type: Can read both XDATA and I2C | 329 | * @address_type: Can read both XDATA and I2C |
359 | * @buffer: pointer to input data buffer | 330 | * @buffer: pointer to input data buffer |
360 | */ | 331 | */ |
361 | static int TIReadDownloadMemory(struct usb_device *dev, int start_address, | 332 | static int read_download_mem(struct usb_device *dev, int start_address, |
362 | int length, __u8 address_type, __u8 *buffer) | 333 | int length, __u8 address_type, __u8 *buffer) |
363 | { | 334 | { |
364 | int status = 0; | 335 | int status = 0; |
365 | __u8 read_length; | 336 | __u8 read_length; |
366 | __be16 be_start_address; | 337 | __be16 be_start_address; |
367 | 338 | ||
368 | dbg ("%s - @ %x for %d", __func__, start_address, length); | 339 | dbg("%s - @ %x for %d", __func__, start_address, length); |
369 | 340 | ||
370 | /* Read in blocks of 64 bytes | 341 | /* Read in blocks of 64 bytes |
371 | * (TI firmware can't handle more than 64 byte reads) | 342 | * (TI firmware can't handle more than 64 byte reads) |
372 | */ | 343 | */ |
373 | while (length) { | 344 | while (length) { |
374 | if (length > 64) | 345 | if (length > 64) |
375 | read_length= 64; | 346 | read_length = 64; |
376 | else | 347 | else |
377 | read_length = (__u8)length; | 348 | read_length = (__u8)length; |
378 | 349 | ||
379 | if (read_length > 1) { | 350 | if (read_length > 1) { |
380 | dbg ("%s - @ %x for %d", __func__, | 351 | dbg("%s - @ %x for %d", __func__, |
381 | start_address, read_length); | 352 | start_address, read_length); |
382 | } | 353 | } |
383 | be_start_address = cpu_to_be16 (start_address); | 354 | be_start_address = cpu_to_be16(start_address); |
384 | status = TIReadVendorRequestSync (dev, | 355 | status = ti_vread_sync(dev, UMPC_MEMORY_READ, |
385 | UMPC_MEMORY_READ, // Request | 356 | (__u16)address_type, |
386 | (__u16)address_type, // wValue (Address type) | 357 | (__force __u16)be_start_address, |
387 | (__force __u16)be_start_address, // wIndex (Address to read) | 358 | buffer, read_length); |
388 | buffer, // TransferBuffer | ||
389 | read_length); // TransferBufferLength | ||
390 | 359 | ||
391 | if (status) { | 360 | if (status) { |
392 | dbg ("%s - ERROR %x", __func__, status); | 361 | dbg("%s - ERROR %x", __func__, status); |
393 | return status; | 362 | return status; |
394 | } | 363 | } |
395 | 364 | ||
396 | if (read_length > 1) { | 365 | if (read_length > 1) |
397 | usb_serial_debug_data(debug, &dev->dev, __func__, | 366 | usb_serial_debug_data(debug, &dev->dev, __func__, |
398 | read_length, buffer); | 367 | read_length, buffer); |
399 | } | ||
400 | 368 | ||
401 | /* Update pointers/length */ | 369 | /* Update pointers/length */ |
402 | start_address += read_length; | 370 | start_address += read_length; |
403 | buffer += read_length; | 371 | buffer += read_length; |
404 | length -= read_length; | 372 | length -= read_length; |
405 | } | 373 | } |
406 | 374 | ||
407 | return status; | 375 | return status; |
408 | } | 376 | } |
409 | 377 | ||
410 | static int TIReadRam (struct usb_device *dev, int start_address, int length, __u8 *buffer) | 378 | static int read_ram(struct usb_device *dev, int start_address, |
379 | int length, __u8 *buffer) | ||
411 | { | 380 | { |
412 | return TIReadDownloadMemory (dev, | 381 | return read_download_mem(dev, start_address, length, |
413 | start_address, | 382 | DTK_ADDR_SPACE_XDATA, buffer); |
414 | length, | ||
415 | DTK_ADDR_SPACE_XDATA, | ||
416 | buffer); | ||
417 | } | 383 | } |
418 | 384 | ||
419 | /* Read edgeport memory to a given block */ | 385 | /* Read edgeport memory to a given block */ |
420 | static int TIReadBootMemory (struct edgeport_serial *serial, int start_address, int length, __u8 * buffer) | 386 | static int read_boot_mem(struct edgeport_serial *serial, |
387 | int start_address, int length, __u8 *buffer) | ||
421 | { | 388 | { |
422 | int status = 0; | 389 | int status = 0; |
423 | int i; | 390 | int i; |
424 | 391 | ||
425 | for (i=0; i< length; i++) { | 392 | for (i = 0; i < length; i++) { |
426 | status = TIReadVendorRequestSync (serial->serial->dev, | 393 | status = ti_vread_sync(serial->serial->dev, |
427 | UMPC_MEMORY_READ, // Request | 394 | UMPC_MEMORY_READ, serial->TI_I2C_Type, |
428 | serial->TI_I2C_Type, // wValue (Address type) | 395 | (__u16)(start_address+i), &buffer[i], 0x01); |
429 | (__u16)(start_address+i), // wIndex | ||
430 | &buffer[i], // TransferBuffer | ||
431 | 0x01); // TransferBufferLength | ||
432 | if (status) { | 396 | if (status) { |
433 | dbg ("%s - ERROR %x", __func__, status); | 397 | dbg("%s - ERROR %x", __func__, status); |
434 | return status; | 398 | return status; |
435 | } | 399 | } |
436 | } | 400 | } |
437 | 401 | ||
438 | dbg ("%s - start_address = %x, length = %d", __func__, start_address, length); | 402 | dbg("%s - start_address = %x, length = %d", |
439 | usb_serial_debug_data(debug, &serial->serial->dev->dev, __func__, length, buffer); | 403 | __func__, start_address, length); |
404 | usb_serial_debug_data(debug, &serial->serial->dev->dev, | ||
405 | __func__, length, buffer); | ||
440 | 406 | ||
441 | serial->TiReadI2C = 1; | 407 | serial->TiReadI2C = 1; |
442 | 408 | ||
@@ -444,7 +410,8 @@ static int TIReadBootMemory (struct edgeport_serial *serial, int start_address, | |||
444 | } | 410 | } |
445 | 411 | ||
446 | /* Write given block to TI EPROM memory */ | 412 | /* Write given block to TI EPROM memory */ |
447 | static int TIWriteBootMemory (struct edgeport_serial *serial, int start_address, int length, __u8 *buffer) | 413 | static int write_boot_mem(struct edgeport_serial *serial, |
414 | int start_address, int length, __u8 *buffer) | ||
448 | { | 415 | { |
449 | int status = 0; | 416 | int status = 0; |
450 | int i; | 417 | int i; |
@@ -452,57 +419,58 @@ static int TIWriteBootMemory (struct edgeport_serial *serial, int start_address, | |||
452 | 419 | ||
453 | /* Must do a read before write */ | 420 | /* Must do a read before write */ |
454 | if (!serial->TiReadI2C) { | 421 | if (!serial->TiReadI2C) { |
455 | status = TIReadBootMemory(serial, 0, 1, &temp); | 422 | status = read_boot_mem(serial, 0, 1, &temp); |
456 | if (status) | 423 | if (status) |
457 | return status; | 424 | return status; |
458 | } | 425 | } |
459 | 426 | ||
460 | for (i=0; i < length; ++i) { | 427 | for (i = 0; i < length; ++i) { |
461 | status = TISendVendorRequestSync (serial->serial->dev, | 428 | status = ti_vsend_sync(serial->serial->dev, |
462 | UMPC_MEMORY_WRITE, // Request | 429 | UMPC_MEMORY_WRITE, buffer[i], |
463 | buffer[i], // wValue | 430 | (__u16)(i + start_address), NULL, 0); |
464 | (__u16)(i+start_address), // wIndex | ||
465 | NULL, // TransferBuffer | ||
466 | 0); // TransferBufferLength | ||
467 | if (status) | 431 | if (status) |
468 | return status; | 432 | return status; |
469 | } | 433 | } |
470 | 434 | ||
471 | dbg ("%s - start_sddr = %x, length = %d", __func__, start_address, length); | 435 | dbg("%s - start_sddr = %x, length = %d", |
472 | usb_serial_debug_data(debug, &serial->serial->dev->dev, __func__, length, buffer); | 436 | __func__, start_address, length); |
437 | usb_serial_debug_data(debug, &serial->serial->dev->dev, | ||
438 | __func__, length, buffer); | ||
473 | 439 | ||
474 | return status; | 440 | return status; |
475 | } | 441 | } |
476 | 442 | ||
477 | 443 | ||
478 | /* Write edgeport I2C memory to TI chip */ | 444 | /* Write edgeport I2C memory to TI chip */ |
479 | static int TIWriteDownloadI2C (struct edgeport_serial *serial, int start_address, int length, __u8 address_type, __u8 *buffer) | 445 | static int write_i2c_mem(struct edgeport_serial *serial, |
446 | int start_address, int length, __u8 address_type, __u8 *buffer) | ||
480 | { | 447 | { |
481 | int status = 0; | 448 | int status = 0; |
482 | int write_length; | 449 | int write_length; |
483 | __be16 be_start_address; | 450 | __be16 be_start_address; |
484 | 451 | ||
485 | /* We can only send a maximum of 1 aligned byte page at a time */ | 452 | /* We can only send a maximum of 1 aligned byte page at a time */ |
486 | 453 | ||
487 | /* calulate the number of bytes left in the first page */ | 454 | /* calulate the number of bytes left in the first page */ |
488 | write_length = EPROM_PAGE_SIZE - (start_address & (EPROM_PAGE_SIZE - 1)); | 455 | write_length = EPROM_PAGE_SIZE - |
456 | (start_address & (EPROM_PAGE_SIZE - 1)); | ||
489 | 457 | ||
490 | if (write_length > length) | 458 | if (write_length > length) |
491 | write_length = length; | 459 | write_length = length; |
492 | 460 | ||
493 | dbg ("%s - BytesInFirstPage Addr = %x, length = %d", __func__, start_address, write_length); | 461 | dbg("%s - BytesInFirstPage Addr = %x, length = %d", |
494 | usb_serial_debug_data(debug, &serial->serial->dev->dev, __func__, write_length, buffer); | 462 | __func__, start_address, write_length); |
463 | usb_serial_debug_data(debug, &serial->serial->dev->dev, | ||
464 | __func__, write_length, buffer); | ||
495 | 465 | ||
496 | /* Write first page */ | 466 | /* Write first page */ |
497 | be_start_address = cpu_to_be16 (start_address); | 467 | be_start_address = cpu_to_be16(start_address); |
498 | status = TISendVendorRequestSync (serial->serial->dev, | 468 | status = ti_vsend_sync(serial->serial->dev, |
499 | UMPC_MEMORY_WRITE, // Request | 469 | UMPC_MEMORY_WRITE, (__u16)address_type, |
500 | (__u16)address_type, // wValue | 470 | (__force __u16)be_start_address, |
501 | (__force __u16)be_start_address, // wIndex | 471 | buffer, write_length); |
502 | buffer, // TransferBuffer | ||
503 | write_length); | ||
504 | if (status) { | 472 | if (status) { |
505 | dbg ("%s - ERROR %d", __func__, status); | 473 | dbg("%s - ERROR %d", __func__, status); |
506 | return status; | 474 | return status; |
507 | } | 475 | } |
508 | 476 | ||
@@ -510,29 +478,31 @@ static int TIWriteDownloadI2C (struct edgeport_serial *serial, int start_address | |||
510 | start_address += write_length; | 478 | start_address += write_length; |
511 | buffer += write_length; | 479 | buffer += write_length; |
512 | 480 | ||
513 | /* We should be aligned now -- can write max page size bytes at a time */ | 481 | /* We should be aligned now -- can write |
482 | max page size bytes at a time */ | ||
514 | while (length) { | 483 | while (length) { |
515 | if (length > EPROM_PAGE_SIZE) | 484 | if (length > EPROM_PAGE_SIZE) |
516 | write_length = EPROM_PAGE_SIZE; | 485 | write_length = EPROM_PAGE_SIZE; |
517 | else | 486 | else |
518 | write_length = length; | 487 | write_length = length; |
519 | 488 | ||
520 | dbg ("%s - Page Write Addr = %x, length = %d", __func__, start_address, write_length); | 489 | dbg("%s - Page Write Addr = %x, length = %d", |
521 | usb_serial_debug_data(debug, &serial->serial->dev->dev, __func__, write_length, buffer); | 490 | __func__, start_address, write_length); |
491 | usb_serial_debug_data(debug, &serial->serial->dev->dev, | ||
492 | __func__, write_length, buffer); | ||
522 | 493 | ||
523 | /* Write next page */ | 494 | /* Write next page */ |
524 | be_start_address = cpu_to_be16 (start_address); | 495 | be_start_address = cpu_to_be16(start_address); |
525 | status = TISendVendorRequestSync (serial->serial->dev, | 496 | status = ti_vsend_sync(serial->serial->dev, UMPC_MEMORY_WRITE, |
526 | UMPC_MEMORY_WRITE, // Request | 497 | (__u16)address_type, |
527 | (__u16)address_type, // wValue | 498 | (__force __u16)be_start_address, |
528 | (__force __u16)be_start_address, // wIndex | 499 | buffer, write_length); |
529 | buffer, // TransferBuffer | ||
530 | write_length); // TransferBufferLength | ||
531 | if (status) { | 500 | if (status) { |
532 | dev_err (&serial->serial->dev->dev, "%s - ERROR %d\n", __func__, status); | 501 | dev_err(&serial->serial->dev->dev, "%s - ERROR %d\n", |
502 | __func__, status); | ||
533 | return status; | 503 | return status; |
534 | } | 504 | } |
535 | 505 | ||
536 | length -= write_length; | 506 | length -= write_length; |
537 | start_address += write_length; | 507 | start_address += write_length; |
538 | buffer += write_length; | 508 | buffer += write_length; |
@@ -541,25 +511,25 @@ static int TIWriteDownloadI2C (struct edgeport_serial *serial, int start_address | |||
541 | } | 511 | } |
542 | 512 | ||
543 | /* Examine the UMP DMA registers and LSR | 513 | /* Examine the UMP DMA registers and LSR |
544 | * | 514 | * |
545 | * Check the MSBit of the X and Y DMA byte count registers. | 515 | * Check the MSBit of the X and Y DMA byte count registers. |
546 | * A zero in this bit indicates that the TX DMA buffers are empty | 516 | * A zero in this bit indicates that the TX DMA buffers are empty |
547 | * then check the TX Empty bit in the UART. | 517 | * then check the TX Empty bit in the UART. |
548 | */ | 518 | */ |
549 | static int TIIsTxActive (struct edgeport_port *port) | 519 | static int tx_active(struct edgeport_port *port) |
550 | { | 520 | { |
551 | int status; | 521 | int status; |
552 | struct out_endpoint_desc_block *oedb; | 522 | struct out_endpoint_desc_block *oedb; |
553 | __u8 *lsr; | 523 | __u8 *lsr; |
554 | int bytes_left = 0; | 524 | int bytes_left = 0; |
555 | 525 | ||
556 | oedb = kmalloc (sizeof (* oedb), GFP_KERNEL); | 526 | oedb = kmalloc(sizeof(*oedb), GFP_KERNEL); |
557 | if (!oedb) { | 527 | if (!oedb) { |
558 | dev_err (&port->port->dev, "%s - out of memory\n", __func__); | 528 | dev_err(&port->port->dev, "%s - out of memory\n", __func__); |
559 | return -ENOMEM; | 529 | return -ENOMEM; |
560 | } | 530 | } |
561 | 531 | ||
562 | lsr = kmalloc (1, GFP_KERNEL); /* Sigh, that's right, just one byte, | 532 | lsr = kmalloc(1, GFP_KERNEL); /* Sigh, that's right, just one byte, |
563 | as not all platforms can do DMA | 533 | as not all platforms can do DMA |
564 | from stack */ | 534 | from stack */ |
565 | if (!lsr) { | 535 | if (!lsr) { |
@@ -567,43 +537,39 @@ static int TIIsTxActive (struct edgeport_port *port) | |||
567 | return -ENOMEM; | 537 | return -ENOMEM; |
568 | } | 538 | } |
569 | /* Read the DMA Count Registers */ | 539 | /* Read the DMA Count Registers */ |
570 | status = TIReadRam (port->port->serial->dev, | 540 | status = read_ram(port->port->serial->dev, port->dma_address, |
571 | port->dma_address, | 541 | sizeof(*oedb), (void *)oedb); |
572 | sizeof( *oedb), | ||
573 | (void *)oedb); | ||
574 | |||
575 | if (status) | 542 | if (status) |
576 | goto exit_is_tx_active; | 543 | goto exit_is_tx_active; |
577 | 544 | ||
578 | dbg ("%s - XByteCount 0x%X", __func__, oedb->XByteCount); | 545 | dbg("%s - XByteCount 0x%X", __func__, oedb->XByteCount); |
579 | 546 | ||
580 | /* and the LSR */ | 547 | /* and the LSR */ |
581 | status = TIReadRam (port->port->serial->dev, | 548 | status = read_ram(port->port->serial->dev, |
582 | port->uart_base + UMPMEM_OFFS_UART_LSR, | 549 | port->uart_base + UMPMEM_OFFS_UART_LSR, 1, lsr); |
583 | 1, | ||
584 | lsr); | ||
585 | 550 | ||
586 | if (status) | 551 | if (status) |
587 | goto exit_is_tx_active; | 552 | goto exit_is_tx_active; |
588 | dbg ("%s - LSR = 0x%X", __func__, *lsr); | 553 | dbg("%s - LSR = 0x%X", __func__, *lsr); |
589 | 554 | ||
590 | /* If either buffer has data or we are transmitting then return TRUE */ | 555 | /* If either buffer has data or we are transmitting then return TRUE */ |
591 | if ((oedb->XByteCount & 0x80 ) != 0 ) | 556 | if ((oedb->XByteCount & 0x80) != 0) |
592 | bytes_left += 64; | 557 | bytes_left += 64; |
593 | 558 | ||
594 | if ((*lsr & UMP_UART_LSR_TX_MASK ) == 0 ) | 559 | if ((*lsr & UMP_UART_LSR_TX_MASK) == 0) |
595 | bytes_left += 1; | 560 | bytes_left += 1; |
596 | 561 | ||
597 | /* We return Not Active if we get any kind of error */ | 562 | /* We return Not Active if we get any kind of error */ |
598 | exit_is_tx_active: | 563 | exit_is_tx_active: |
599 | dbg ("%s - return %d", __func__, bytes_left ); | 564 | dbg("%s - return %d", __func__, bytes_left); |
600 | 565 | ||
601 | kfree(lsr); | 566 | kfree(lsr); |
602 | kfree(oedb); | 567 | kfree(oedb); |
603 | return bytes_left; | 568 | return bytes_left; |
604 | } | 569 | } |
605 | 570 | ||
606 | static void TIChasePort(struct edgeport_port *port, unsigned long timeout, int flush) | 571 | static void chase_port(struct edgeport_port *port, unsigned long timeout, |
572 | int flush) | ||
607 | { | 573 | { |
608 | int baud_rate; | 574 | int baud_rate; |
609 | struct tty_struct *tty = port->port->tty; | 575 | struct tty_struct *tty = port->port->tty; |
@@ -611,7 +577,7 @@ static void TIChasePort(struct edgeport_port *port, unsigned long timeout, int f | |||
611 | unsigned long flags; | 577 | unsigned long flags; |
612 | 578 | ||
613 | if (!timeout) | 579 | if (!timeout) |
614 | timeout = (HZ*EDGE_CLOSING_WAIT)/100; | 580 | timeout = (HZ * EDGE_CLOSING_WAIT)/100; |
615 | 581 | ||
616 | /* wait for data to drain from the buffer */ | 582 | /* wait for data to drain from the buffer */ |
617 | spin_lock_irqsave(&port->ep_lock, flags); | 583 | spin_lock_irqsave(&port->ep_lock, flags); |
@@ -621,7 +587,8 @@ static void TIChasePort(struct edgeport_port *port, unsigned long timeout, int f | |||
621 | set_current_state(TASK_INTERRUPTIBLE); | 587 | set_current_state(TASK_INTERRUPTIBLE); |
622 | if (edge_buf_data_avail(port->ep_out_buf) == 0 | 588 | if (edge_buf_data_avail(port->ep_out_buf) == 0 |
623 | || timeout == 0 || signal_pending(current) | 589 | || timeout == 0 || signal_pending(current) |
624 | || !usb_get_intfdata(port->port->serial->interface)) /* disconnect */ | 590 | || !usb_get_intfdata(port->port->serial->interface)) |
591 | /* disconnect */ | ||
625 | break; | 592 | break; |
626 | spin_unlock_irqrestore(&port->ep_lock, flags); | 593 | spin_unlock_irqrestore(&port->ep_lock, flags); |
627 | timeout = schedule_timeout(timeout); | 594 | timeout = schedule_timeout(timeout); |
@@ -636,8 +603,9 @@ static void TIChasePort(struct edgeport_port *port, unsigned long timeout, int f | |||
636 | /* wait for data to drain from the device */ | 603 | /* wait for data to drain from the device */ |
637 | timeout += jiffies; | 604 | timeout += jiffies; |
638 | while ((long)(jiffies - timeout) < 0 && !signal_pending(current) | 605 | while ((long)(jiffies - timeout) < 0 && !signal_pending(current) |
639 | && usb_get_intfdata(port->port->serial->interface)) { /* not disconnected */ | 606 | && usb_get_intfdata(port->port->serial->interface)) { |
640 | if (!TIIsTxActive(port)) | 607 | /* not disconnected */ |
608 | if (!tx_active(port)) | ||
641 | break; | 609 | break; |
642 | msleep(10); | 610 | msleep(10); |
643 | } | 611 | } |
@@ -647,72 +615,72 @@ static void TIChasePort(struct edgeport_port *port, unsigned long timeout, int f | |||
647 | return; | 615 | return; |
648 | 616 | ||
649 | /* wait one more character time, based on baud rate */ | 617 | /* wait one more character time, based on baud rate */ |
650 | /* (TIIsTxActive doesn't seem to wait for the last byte) */ | 618 | /* (tx_active doesn't seem to wait for the last byte) */ |
651 | if ((baud_rate=port->baud_rate) == 0) | 619 | baud_rate = port->baud_rate; |
620 | if (baud_rate == 0) | ||
652 | baud_rate = 50; | 621 | baud_rate = 50; |
653 | msleep(max(1, DIV_ROUND_UP(10000, baud_rate))); | 622 | msleep(max(1, DIV_ROUND_UP(10000, baud_rate))); |
654 | } | 623 | } |
655 | 624 | ||
656 | static int TIChooseConfiguration (struct usb_device *dev) | 625 | static int choose_config(struct usb_device *dev) |
657 | { | 626 | { |
658 | // There may be multiple configurations on this device, in which case | 627 | /* |
659 | // we would need to read and parse all of them to find out which one | 628 | * There may be multiple configurations on this device, in which case |
660 | // we want. However, we just support one config at this point, | 629 | * we would need to read and parse all of them to find out which one |
661 | // configuration # 1, which is Config Descriptor 0. | 630 | * we want. However, we just support one config at this point, |
631 | * configuration # 1, which is Config Descriptor 0. | ||
632 | */ | ||
662 | 633 | ||
663 | dbg ("%s - Number of Interfaces = %d", __func__, dev->config->desc.bNumInterfaces); | 634 | dbg("%s - Number of Interfaces = %d", |
664 | dbg ("%s - MAX Power = %d", __func__, dev->config->desc.bMaxPower*2); | 635 | __func__, dev->config->desc.bNumInterfaces); |
636 | dbg("%s - MAX Power = %d", | ||
637 | __func__, dev->config->desc.bMaxPower * 2); | ||
665 | 638 | ||
666 | if (dev->config->desc.bNumInterfaces != 1) { | 639 | if (dev->config->desc.bNumInterfaces != 1) { |
667 | dev_err (&dev->dev, "%s - bNumInterfaces is not 1, ERROR!\n", __func__); | 640 | dev_err(&dev->dev, "%s - bNumInterfaces is not 1, ERROR!\n", |
641 | __func__); | ||
668 | return -ENODEV; | 642 | return -ENODEV; |
669 | } | 643 | } |
670 | 644 | ||
671 | return 0; | 645 | return 0; |
672 | } | 646 | } |
673 | 647 | ||
674 | static int TIReadRom (struct edgeport_serial *serial, int start_address, int length, __u8 *buffer) | 648 | static int read_rom(struct edgeport_serial *serial, |
649 | int start_address, int length, __u8 *buffer) | ||
675 | { | 650 | { |
676 | int status; | 651 | int status; |
677 | 652 | ||
678 | if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) { | 653 | if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) { |
679 | status = TIReadDownloadMemory (serial->serial->dev, | 654 | status = read_download_mem(serial->serial->dev, |
680 | start_address, | 655 | start_address, |
681 | length, | 656 | length, |
682 | serial->TI_I2C_Type, | 657 | serial->TI_I2C_Type, |
683 | buffer); | 658 | buffer); |
684 | } else { | 659 | } else { |
685 | status = TIReadBootMemory (serial, | 660 | status = read_boot_mem(serial, start_address, length, |
686 | start_address, | 661 | buffer); |
687 | length, | ||
688 | buffer); | ||
689 | } | 662 | } |
690 | |||
691 | return status; | 663 | return status; |
692 | } | 664 | } |
693 | 665 | ||
694 | static int TIWriteRom (struct edgeport_serial *serial, int start_address, int length, __u8 *buffer) | 666 | static int write_rom(struct edgeport_serial *serial, int start_address, |
667 | int length, __u8 *buffer) | ||
695 | { | 668 | { |
696 | if (serial->product_info.TiMode == TI_MODE_BOOT) | 669 | if (serial->product_info.TiMode == TI_MODE_BOOT) |
697 | return TIWriteBootMemory (serial, | 670 | return write_boot_mem(serial, start_address, length, |
698 | start_address, | 671 | buffer); |
699 | length, | ||
700 | buffer); | ||
701 | 672 | ||
702 | if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) | 673 | if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) |
703 | return TIWriteDownloadI2C (serial, | 674 | return write_i2c_mem(serial, start_address, length, |
704 | start_address, | 675 | serial->TI_I2C_Type, buffer); |
705 | length, | ||
706 | serial->TI_I2C_Type, | ||
707 | buffer); | ||
708 | |||
709 | return -EINVAL; | 676 | return -EINVAL; |
710 | } | 677 | } |
711 | 678 | ||
712 | 679 | ||
713 | 680 | ||
714 | /* Read a descriptor header from I2C based on type */ | 681 | /* Read a descriptor header from I2C based on type */ |
715 | static int TIGetDescriptorAddress (struct edgeport_serial *serial, int desc_type, struct ti_i2c_desc *rom_desc) | 682 | static int get_descriptor_addr(struct edgeport_serial *serial, |
683 | int desc_type, struct ti_i2c_desc *rom_desc) | ||
716 | { | 684 | { |
717 | int start_address; | 685 | int start_address; |
718 | int status; | 686 | int status; |
@@ -720,41 +688,42 @@ static int TIGetDescriptorAddress (struct edgeport_serial *serial, int desc_type | |||
720 | /* Search for requested descriptor in I2C */ | 688 | /* Search for requested descriptor in I2C */ |
721 | start_address = 2; | 689 | start_address = 2; |
722 | do { | 690 | do { |
723 | status = TIReadRom (serial, | 691 | status = read_rom(serial, |
724 | start_address, | 692 | start_address, |
725 | sizeof(struct ti_i2c_desc), | 693 | sizeof(struct ti_i2c_desc), |
726 | (__u8 *)rom_desc ); | 694 | (__u8 *)rom_desc); |
727 | if (status) | 695 | if (status) |
728 | return 0; | 696 | return 0; |
729 | 697 | ||
730 | if (rom_desc->Type == desc_type) | 698 | if (rom_desc->Type == desc_type) |
731 | return start_address; | 699 | return start_address; |
732 | 700 | ||
733 | start_address = start_address + sizeof(struct ti_i2c_desc) + rom_desc->Size; | 701 | start_address = start_address + sizeof(struct ti_i2c_desc) |
702 | + rom_desc->Size; | ||
734 | 703 | ||
735 | } while ((start_address < TI_MAX_I2C_SIZE) && rom_desc->Type); | 704 | } while ((start_address < TI_MAX_I2C_SIZE) && rom_desc->Type); |
736 | 705 | ||
737 | return 0; | 706 | return 0; |
738 | } | 707 | } |
739 | 708 | ||
740 | /* Validate descriptor checksum */ | 709 | /* Validate descriptor checksum */ |
741 | static int ValidChecksum(struct ti_i2c_desc *rom_desc, __u8 *buffer) | 710 | static int valid_csum(struct ti_i2c_desc *rom_desc, __u8 *buffer) |
742 | { | 711 | { |
743 | __u16 i; | 712 | __u16 i; |
744 | __u8 cs = 0; | 713 | __u8 cs = 0; |
745 | 714 | ||
746 | for (i=0; i < rom_desc->Size; i++) { | 715 | for (i = 0; i < rom_desc->Size; i++) |
747 | cs = (__u8)(cs + buffer[i]); | 716 | cs = (__u8)(cs + buffer[i]); |
748 | } | 717 | |
749 | if (cs != rom_desc->CheckSum) { | 718 | if (cs != rom_desc->CheckSum) { |
750 | dbg ("%s - Mismatch %x - %x", __func__, rom_desc->CheckSum, cs); | 719 | dbg("%s - Mismatch %x - %x", __func__, rom_desc->CheckSum, cs); |
751 | return -EINVAL; | 720 | return -EINVAL; |
752 | } | 721 | } |
753 | return 0; | 722 | return 0; |
754 | } | 723 | } |
755 | 724 | ||
756 | /* Make sure that the I2C image is good */ | 725 | /* Make sure that the I2C image is good */ |
757 | static int TiValidateI2cImage (struct edgeport_serial *serial) | 726 | static int check_i2c_image(struct edgeport_serial *serial) |
758 | { | 727 | { |
759 | struct device *dev = &serial->serial->dev->dev; | 728 | struct device *dev = &serial->serial->dev->dev; |
760 | int status = 0; | 729 | int status = 0; |
@@ -763,120 +732,124 @@ static int TiValidateI2cImage (struct edgeport_serial *serial) | |||
763 | __u8 *buffer; | 732 | __u8 *buffer; |
764 | __u16 ttype; | 733 | __u16 ttype; |
765 | 734 | ||
766 | rom_desc = kmalloc (sizeof (*rom_desc), GFP_KERNEL); | 735 | rom_desc = kmalloc(sizeof(*rom_desc), GFP_KERNEL); |
767 | if (!rom_desc) { | 736 | if (!rom_desc) { |
768 | dev_err (dev, "%s - out of memory\n", __func__); | 737 | dev_err(dev, "%s - out of memory\n", __func__); |
769 | return -ENOMEM; | 738 | return -ENOMEM; |
770 | } | 739 | } |
771 | buffer = kmalloc (TI_MAX_I2C_SIZE, GFP_KERNEL); | 740 | buffer = kmalloc(TI_MAX_I2C_SIZE, GFP_KERNEL); |
772 | if (!buffer) { | 741 | if (!buffer) { |
773 | dev_err (dev, "%s - out of memory when allocating buffer\n", __func__); | 742 | dev_err(dev, "%s - out of memory when allocating buffer\n", |
774 | kfree (rom_desc); | 743 | __func__); |
744 | kfree(rom_desc); | ||
775 | return -ENOMEM; | 745 | return -ENOMEM; |
776 | } | 746 | } |
777 | 747 | ||
778 | // Read the first byte (Signature0) must be 0x52 or 0x10 | 748 | /* Read the first byte (Signature0) must be 0x52 or 0x10 */ |
779 | status = TIReadRom (serial, 0, 1, buffer); | 749 | status = read_rom(serial, 0, 1, buffer); |
780 | if (status) | 750 | if (status) |
781 | goto ExitTiValidateI2cImage; | 751 | goto out; |
782 | 752 | ||
783 | if (*buffer != UMP5152 && *buffer != UMP3410) { | 753 | if (*buffer != UMP5152 && *buffer != UMP3410) { |
784 | dev_err (dev, "%s - invalid buffer signature\n", __func__); | 754 | dev_err(dev, "%s - invalid buffer signature\n", __func__); |
785 | status = -ENODEV; | 755 | status = -ENODEV; |
786 | goto ExitTiValidateI2cImage; | 756 | goto out; |
787 | } | 757 | } |
788 | 758 | ||
789 | do { | 759 | do { |
790 | // Validate the I2C | 760 | /* Validate the I2C */ |
791 | status = TIReadRom (serial, | 761 | status = read_rom(serial, |
792 | start_address, | 762 | start_address, |
793 | sizeof(struct ti_i2c_desc), | 763 | sizeof(struct ti_i2c_desc), |
794 | (__u8 *)rom_desc); | 764 | (__u8 *)rom_desc); |
795 | if (status) | 765 | if (status) |
796 | break; | 766 | break; |
797 | 767 | ||
798 | if ((start_address + sizeof(struct ti_i2c_desc) + rom_desc->Size) > TI_MAX_I2C_SIZE) { | 768 | if ((start_address + sizeof(struct ti_i2c_desc) + |
769 | rom_desc->Size) > TI_MAX_I2C_SIZE) { | ||
799 | status = -ENODEV; | 770 | status = -ENODEV; |
800 | dbg ("%s - structure too big, erroring out.", __func__); | 771 | dbg("%s - structure too big, erroring out.", __func__); |
801 | break; | 772 | break; |
802 | } | 773 | } |
803 | 774 | ||
804 | dbg ("%s Type = 0x%x", __func__, rom_desc->Type); | 775 | dbg("%s Type = 0x%x", __func__, rom_desc->Type); |
805 | 776 | ||
806 | // Skip type 2 record | 777 | /* Skip type 2 record */ |
807 | ttype = rom_desc->Type & 0x0f; | 778 | ttype = rom_desc->Type & 0x0f; |
808 | if ( ttype != I2C_DESC_TYPE_FIRMWARE_BASIC | 779 | if (ttype != I2C_DESC_TYPE_FIRMWARE_BASIC |
809 | && ttype != I2C_DESC_TYPE_FIRMWARE_AUTO ) { | 780 | && ttype != I2C_DESC_TYPE_FIRMWARE_AUTO) { |
810 | // Read the descriptor data | 781 | /* Read the descriptor data */ |
811 | status = TIReadRom(serial, | 782 | status = read_rom(serial, start_address + |
812 | start_address+sizeof(struct ti_i2c_desc), | 783 | sizeof(struct ti_i2c_desc), |
813 | rom_desc->Size, | 784 | rom_desc->Size, buffer); |
814 | buffer); | ||
815 | if (status) | 785 | if (status) |
816 | break; | 786 | break; |
817 | 787 | ||
818 | status = ValidChecksum(rom_desc, buffer); | 788 | status = valid_csum(rom_desc, buffer); |
819 | if (status) | 789 | if (status) |
820 | break; | 790 | break; |
821 | } | 791 | } |
822 | start_address = start_address + sizeof(struct ti_i2c_desc) + rom_desc->Size; | 792 | start_address = start_address + sizeof(struct ti_i2c_desc) + |
793 | rom_desc->Size; | ||
823 | 794 | ||
824 | } while ((rom_desc->Type != I2C_DESC_TYPE_ION) && (start_address < TI_MAX_I2C_SIZE)); | 795 | } while ((rom_desc->Type != I2C_DESC_TYPE_ION) && |
796 | (start_address < TI_MAX_I2C_SIZE)); | ||
825 | 797 | ||
826 | if ((rom_desc->Type != I2C_DESC_TYPE_ION) || (start_address > TI_MAX_I2C_SIZE)) | 798 | if ((rom_desc->Type != I2C_DESC_TYPE_ION) || |
799 | (start_address > TI_MAX_I2C_SIZE)) | ||
827 | status = -ENODEV; | 800 | status = -ENODEV; |
828 | 801 | ||
829 | ExitTiValidateI2cImage: | 802 | out: |
830 | kfree (buffer); | 803 | kfree(buffer); |
831 | kfree (rom_desc); | 804 | kfree(rom_desc); |
832 | return status; | 805 | return status; |
833 | } | 806 | } |
834 | 807 | ||
835 | static int TIReadManufDescriptor (struct edgeport_serial *serial, __u8 *buffer) | 808 | static int get_manuf_info(struct edgeport_serial *serial, __u8 *buffer) |
836 | { | 809 | { |
837 | int status; | 810 | int status; |
838 | int start_address; | 811 | int start_address; |
839 | struct ti_i2c_desc *rom_desc; | 812 | struct ti_i2c_desc *rom_desc; |
840 | struct edge_ti_manuf_descriptor *desc; | 813 | struct edge_ti_manuf_descriptor *desc; |
841 | 814 | ||
842 | rom_desc = kmalloc (sizeof (*rom_desc), GFP_KERNEL); | 815 | rom_desc = kmalloc(sizeof(*rom_desc), GFP_KERNEL); |
843 | if (!rom_desc) { | 816 | if (!rom_desc) { |
844 | dev_err (&serial->serial->dev->dev, "%s - out of memory\n", __func__); | 817 | dev_err(&serial->serial->dev->dev, "%s - out of memory\n", |
818 | __func__); | ||
845 | return -ENOMEM; | 819 | return -ENOMEM; |
846 | } | 820 | } |
847 | start_address = TIGetDescriptorAddress (serial, I2C_DESC_TYPE_ION, rom_desc); | 821 | start_address = get_descriptor_addr(serial, I2C_DESC_TYPE_ION, |
822 | rom_desc); | ||
848 | 823 | ||
849 | if (!start_address) { | 824 | if (!start_address) { |
850 | dbg ("%s - Edge Descriptor not found in I2C", __func__); | 825 | dbg("%s - Edge Descriptor not found in I2C", __func__); |
851 | status = -ENODEV; | 826 | status = -ENODEV; |
852 | goto exit; | 827 | goto exit; |
853 | } | 828 | } |
854 | 829 | ||
855 | // Read the descriptor data | 830 | /* Read the descriptor data */ |
856 | status = TIReadRom (serial, | 831 | status = read_rom(serial, start_address+sizeof(struct ti_i2c_desc), |
857 | start_address+sizeof(struct ti_i2c_desc), | 832 | rom_desc->Size, buffer); |
858 | rom_desc->Size, | ||
859 | buffer); | ||
860 | if (status) | 833 | if (status) |
861 | goto exit; | 834 | goto exit; |
862 | 835 | ||
863 | status = ValidChecksum(rom_desc, buffer); | 836 | status = valid_csum(rom_desc, buffer); |
864 | 837 | ||
865 | desc = (struct edge_ti_manuf_descriptor *)buffer; | 838 | desc = (struct edge_ti_manuf_descriptor *)buffer; |
866 | dbg ( "%s - IonConfig 0x%x", __func__, desc->IonConfig ); | 839 | dbg("%s - IonConfig 0x%x", __func__, desc->IonConfig); |
867 | dbg ( "%s - Version %d", __func__, desc->Version ); | 840 | dbg("%s - Version %d", __func__, desc->Version); |
868 | dbg ( "%s - Cpu/Board 0x%x", __func__, desc->CpuRev_BoardRev ); | 841 | dbg("%s - Cpu/Board 0x%x", __func__, desc->CpuRev_BoardRev); |
869 | dbg ( "%s - NumPorts %d", __func__, desc->NumPorts ); | 842 | dbg("%s - NumPorts %d", __func__, desc->NumPorts); |
870 | dbg ( "%s - NumVirtualPorts %d", __func__, desc->NumVirtualPorts ); | 843 | dbg("%s - NumVirtualPorts %d", __func__, desc->NumVirtualPorts); |
871 | dbg ( "%s - TotalPorts %d", __func__, desc->TotalPorts ); | 844 | dbg("%s - TotalPorts %d", __func__, desc->TotalPorts); |
872 | 845 | ||
873 | exit: | 846 | exit: |
874 | kfree (rom_desc); | 847 | kfree(rom_desc); |
875 | return status; | 848 | return status; |
876 | } | 849 | } |
877 | 850 | ||
878 | /* Build firmware header used for firmware update */ | 851 | /* Build firmware header used for firmware update */ |
879 | static int BuildI2CFirmwareHeader (__u8 *header, struct device *dev) | 852 | static int build_i2c_fw_hdr(__u8 *header, struct device *dev) |
880 | { | 853 | { |
881 | __u8 *buffer; | 854 | __u8 *buffer; |
882 | int buffer_size; | 855 | int buffer_size; |
@@ -889,24 +862,28 @@ static int BuildI2CFirmwareHeader (__u8 *header, struct device *dev) | |||
889 | const struct firmware *fw; | 862 | const struct firmware *fw; |
890 | const char *fw_name = "edgeport/down3.bin"; | 863 | const char *fw_name = "edgeport/down3.bin"; |
891 | 864 | ||
892 | // In order to update the I2C firmware we must change the type 2 record to type 0xF2. | 865 | /* In order to update the I2C firmware we must change the type 2 record |
893 | // This will force the UMP to come up in Boot Mode. Then while in boot mode, the driver | 866 | * to type 0xF2. This will force the UMP to come up in Boot Mode. |
894 | // will download the latest firmware (padded to 15.5k) into the UMP ram. | 867 | * Then while in boot mode, the driver will download the latest |
895 | // And finally when the device comes back up in download mode the driver will cause | 868 | * firmware (padded to 15.5k) into the UMP ram. And finally when the |
896 | // the new firmware to be copied from the UMP Ram to I2C and the firmware will update | 869 | * device comes back up in download mode the driver will cause the new |
897 | // the record type from 0xf2 to 0x02. | 870 | * firmware to be copied from the UMP Ram to I2C and the firmware will |
898 | 871 | * update the record type from 0xf2 to 0x02. | |
899 | // Allocate a 15.5k buffer + 2 bytes for version number (Firmware Record) | 872 | */ |
900 | buffer_size = (((1024 * 16) - 512 )+ sizeof(struct ti_i2c_firmware_rec)); | 873 | |
901 | 874 | /* Allocate a 15.5k buffer + 2 bytes for version number | |
902 | buffer = kmalloc (buffer_size, GFP_KERNEL); | 875 | * (Firmware Record) */ |
876 | buffer_size = (((1024 * 16) - 512 ) + | ||
877 | sizeof(struct ti_i2c_firmware_rec)); | ||
878 | |||
879 | buffer = kmalloc(buffer_size, GFP_KERNEL); | ||
903 | if (!buffer) { | 880 | if (!buffer) { |
904 | dev_err (dev, "%s - out of memory\n", __func__); | 881 | dev_err(dev, "%s - out of memory\n", __func__); |
905 | return -ENOMEM; | 882 | return -ENOMEM; |
906 | } | 883 | } |
907 | 884 | ||
908 | // Set entire image of 0xffs | 885 | // Set entire image of 0xffs |
909 | memset (buffer, 0xff, buffer_size); | 886 | memset(buffer, 0xff, buffer_size); |
910 | 887 | ||
911 | err = request_firmware(&fw, fw_name, dev); | 888 | err = request_firmware(&fw, fw_name, dev); |
912 | if (err) { | 889 | if (err) { |
@@ -921,16 +898,16 @@ static int BuildI2CFirmwareHeader (__u8 *header, struct device *dev) | |||
921 | OperationalMinorVersion = fw->data[1]; | 898 | OperationalMinorVersion = fw->data[1]; |
922 | OperationalBuildNumber = fw->data[2] | (fw->data[3] << 8); | 899 | OperationalBuildNumber = fw->data[2] | (fw->data[3] << 8); |
923 | 900 | ||
924 | // Copy version number into firmware record | 901 | /* Copy version number into firmware record */ |
925 | firmware_rec = (struct ti_i2c_firmware_rec *)buffer; | 902 | firmware_rec = (struct ti_i2c_firmware_rec *)buffer; |
926 | 903 | ||
927 | firmware_rec->Ver_Major = OperationalMajorVersion; | 904 | firmware_rec->Ver_Major = OperationalMajorVersion; |
928 | firmware_rec->Ver_Minor = OperationalMinorVersion; | 905 | firmware_rec->Ver_Minor = OperationalMinorVersion; |
929 | 906 | ||
930 | // Pointer to fw_down memory image | 907 | /* Pointer to fw_down memory image */ |
931 | img_header = (struct ti_i2c_image_header *)&fw->data[4]; | 908 | img_header = (struct ti_i2c_image_header *)&fw->data[4]; |
932 | 909 | ||
933 | memcpy (buffer + sizeof(struct ti_i2c_firmware_rec), | 910 | memcpy(buffer + sizeof(struct ti_i2c_firmware_rec), |
934 | &fw->data[4 + sizeof(struct ti_i2c_image_header)], | 911 | &fw->data[4 + sizeof(struct ti_i2c_image_header)], |
935 | le16_to_cpu(img_header->Length)); | 912 | le16_to_cpu(img_header->Length)); |
936 | 913 | ||
@@ -940,12 +917,12 @@ static int BuildI2CFirmwareHeader (__u8 *header, struct device *dev) | |||
940 | cs = (__u8)(cs + buffer[i]); | 917 | cs = (__u8)(cs + buffer[i]); |
941 | } | 918 | } |
942 | 919 | ||
943 | kfree (buffer); | 920 | kfree(buffer); |
944 | 921 | ||
945 | // Build new header | 922 | /* Build new header */ |
946 | i2c_header = (struct ti_i2c_desc *)header; | 923 | i2c_header = (struct ti_i2c_desc *)header; |
947 | firmware_rec = (struct ti_i2c_firmware_rec*)i2c_header->Data; | 924 | firmware_rec = (struct ti_i2c_firmware_rec*)i2c_header->Data; |
948 | 925 | ||
949 | i2c_header->Type = I2C_DESC_TYPE_FIRMWARE_BLANK; | 926 | i2c_header->Type = I2C_DESC_TYPE_FIRMWARE_BLANK; |
950 | i2c_header->Size = (__u16)buffer_size; | 927 | i2c_header->Size = (__u16)buffer_size; |
951 | i2c_header->CheckSum = cs; | 928 | i2c_header->CheckSum = cs; |
@@ -956,103 +933,100 @@ static int BuildI2CFirmwareHeader (__u8 *header, struct device *dev) | |||
956 | } | 933 | } |
957 | 934 | ||
958 | /* Try to figure out what type of I2c we have */ | 935 | /* Try to figure out what type of I2c we have */ |
959 | static int TIGetI2cTypeInBootMode (struct edgeport_serial *serial) | 936 | static int i2c_type_bootmode(struct edgeport_serial *serial) |
960 | { | 937 | { |
961 | int status; | 938 | int status; |
962 | __u8 data; | 939 | __u8 data; |
963 | 940 | ||
964 | // Try to read type 2 | 941 | /* Try to read type 2 */ |
965 | status = TIReadVendorRequestSync (serial->serial->dev, | 942 | status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ, |
966 | UMPC_MEMORY_READ, // Request | 943 | DTK_ADDR_SPACE_I2C_TYPE_II, 0, &data, 0x01); |
967 | DTK_ADDR_SPACE_I2C_TYPE_II, // wValue (Address type) | ||
968 | 0, // wIndex | ||
969 | &data, // TransferBuffer | ||
970 | 0x01); // TransferBufferLength | ||
971 | if (status) | 944 | if (status) |
972 | dbg ("%s - read 2 status error = %d", __func__, status); | 945 | dbg("%s - read 2 status error = %d", __func__, status); |
973 | else | 946 | else |
974 | dbg ("%s - read 2 data = 0x%x", __func__, data); | 947 | dbg("%s - read 2 data = 0x%x", __func__, data); |
975 | if ((!status) && (data == UMP5152 || data == UMP3410)) { | 948 | if ((!status) && (data == UMP5152 || data == UMP3410)) { |
976 | dbg ("%s - ROM_TYPE_II", __func__); | 949 | dbg("%s - ROM_TYPE_II", __func__); |
977 | serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; | 950 | serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; |
978 | return 0; | 951 | return 0; |
979 | } | 952 | } |
980 | 953 | ||
981 | // Try to read type 3 | 954 | /* Try to read type 3 */ |
982 | status = TIReadVendorRequestSync (serial->serial->dev, | 955 | status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ, |
983 | UMPC_MEMORY_READ, // Request | 956 | DTK_ADDR_SPACE_I2C_TYPE_III, 0, &data, 0x01); |
984 | DTK_ADDR_SPACE_I2C_TYPE_III, // wValue (Address type) | ||
985 | 0, // wIndex | ||
986 | &data, // TransferBuffer | ||
987 | 0x01); // TransferBufferLength | ||
988 | if (status) | 957 | if (status) |
989 | dbg ("%s - read 3 status error = %d", __func__, status); | 958 | dbg("%s - read 3 status error = %d", __func__, status); |
990 | else | 959 | else |
991 | dbg ("%s - read 2 data = 0x%x", __func__, data); | 960 | dbg("%s - read 2 data = 0x%x", __func__, data); |
992 | if ((!status) && (data == UMP5152 || data == UMP3410)) { | 961 | if ((!status) && (data == UMP5152 || data == UMP3410)) { |
993 | dbg ("%s - ROM_TYPE_III", __func__); | 962 | dbg("%s - ROM_TYPE_III", __func__); |
994 | serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_III; | 963 | serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_III; |
995 | return 0; | 964 | return 0; |
996 | } | 965 | } |
997 | 966 | ||
998 | dbg ("%s - Unknown", __func__); | 967 | dbg("%s - Unknown", __func__); |
999 | serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; | 968 | serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; |
1000 | return -ENODEV; | 969 | return -ENODEV; |
1001 | } | 970 | } |
1002 | 971 | ||
1003 | static int TISendBulkTransferSync (struct usb_serial *serial, void *buffer, int length, int *num_sent) | 972 | static int bulk_xfer(struct usb_serial *serial, void *buffer, |
973 | int length, int *num_sent) | ||
1004 | { | 974 | { |
1005 | int status; | 975 | int status; |
1006 | 976 | ||
1007 | status = usb_bulk_msg (serial->dev, | 977 | status = usb_bulk_msg(serial->dev, |
1008 | usb_sndbulkpipe(serial->dev, | 978 | usb_sndbulkpipe(serial->dev, |
1009 | serial->port[0]->bulk_out_endpointAddress), | 979 | serial->port[0]->bulk_out_endpointAddress), |
1010 | buffer, | 980 | buffer, length, num_sent, 1000); |
1011 | length, | ||
1012 | num_sent, | ||
1013 | 1000); | ||
1014 | return status; | 981 | return status; |
1015 | } | 982 | } |
1016 | 983 | ||
1017 | /* Download given firmware image to the device (IN BOOT MODE) */ | 984 | /* Download given firmware image to the device (IN BOOT MODE) */ |
1018 | static int TIDownloadCodeImage (struct edgeport_serial *serial, __u8 *image, int image_length) | 985 | static int download_code(struct edgeport_serial *serial, __u8 *image, |
986 | int image_length) | ||
1019 | { | 987 | { |
1020 | int status = 0; | 988 | int status = 0; |
1021 | int pos; | 989 | int pos; |
1022 | int transfer; | 990 | int transfer; |
1023 | int done; | 991 | int done; |
1024 | 992 | ||
1025 | // Transfer firmware image | 993 | /* Transfer firmware image */ |
1026 | for (pos = 0; pos < image_length; ) { | 994 | for (pos = 0; pos < image_length; ) { |
1027 | // Read the next buffer from file | 995 | /* Read the next buffer from file */ |
1028 | transfer = image_length - pos; | 996 | transfer = image_length - pos; |
1029 | if (transfer > EDGE_FW_BULK_MAX_PACKET_SIZE) | 997 | if (transfer > EDGE_FW_BULK_MAX_PACKET_SIZE) |
1030 | transfer = EDGE_FW_BULK_MAX_PACKET_SIZE; | 998 | transfer = EDGE_FW_BULK_MAX_PACKET_SIZE; |
1031 | 999 | ||
1032 | // Transfer data | 1000 | /* Transfer data */ |
1033 | status = TISendBulkTransferSync (serial->serial, &image[pos], transfer, &done); | 1001 | status = bulk_xfer(serial->serial, &image[pos], |
1002 | transfer, &done); | ||
1034 | if (status) | 1003 | if (status) |
1035 | break; | 1004 | break; |
1036 | // Advance buffer pointer | 1005 | /* Advance buffer pointer */ |
1037 | pos += done; | 1006 | pos += done; |
1038 | } | 1007 | } |
1039 | 1008 | ||
1040 | return status; | 1009 | return status; |
1041 | } | 1010 | } |
1042 | 1011 | ||
1043 | // FIXME!!! | 1012 | /* FIXME!!! */ |
1044 | static int TIConfigureBootDevice (struct usb_device *dev) | 1013 | static int config_boot_dev(struct usb_device *dev) |
1045 | { | 1014 | { |
1046 | return 0; | 1015 | return 0; |
1047 | } | 1016 | } |
1048 | 1017 | ||
1018 | static int ti_cpu_rev(struct edge_ti_manuf_descriptor *desc) | ||
1019 | { | ||
1020 | return TI_GET_CPU_REVISION(desc->CpuRev_BoardRev); | ||
1021 | } | ||
1022 | |||
1049 | /** | 1023 | /** |
1050 | * DownloadTIFirmware - Download run-time operating firmware to the TI5052 | 1024 | * DownloadTIFirmware - Download run-time operating firmware to the TI5052 |
1051 | * | 1025 | * |
1052 | * This routine downloads the main operating code into the TI5052, using the | 1026 | * This routine downloads the main operating code into the TI5052, using the |
1053 | * boot code already burned into E2PROM or ROM. | 1027 | * boot code already burned into E2PROM or ROM. |
1054 | */ | 1028 | */ |
1055 | static int TIDownloadFirmware (struct edgeport_serial *serial) | 1029 | static int download_fw(struct edgeport_serial *serial) |
1056 | { | 1030 | { |
1057 | struct device *dev = &serial->serial->dev->dev; | 1031 | struct device *dev = &serial->serial->dev->dev; |
1058 | int status = 0; | 1032 | int status = 0; |
@@ -1071,22 +1045,25 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) | |||
1071 | /* Default to type 2 i2c */ | 1045 | /* Default to type 2 i2c */ |
1072 | serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; | 1046 | serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; |
1073 | 1047 | ||
1074 | status = TIChooseConfiguration (serial->serial->dev); | 1048 | status = choose_config(serial->serial->dev); |
1075 | if (status) | 1049 | if (status) |
1076 | return status; | 1050 | return status; |
1077 | 1051 | ||
1078 | interface = &serial->serial->interface->cur_altsetting->desc; | 1052 | interface = &serial->serial->interface->cur_altsetting->desc; |
1079 | if (!interface) { | 1053 | if (!interface) { |
1080 | dev_err (dev, "%s - no interface set, error!\n", __func__); | 1054 | dev_err(dev, "%s - no interface set, error!\n", __func__); |
1081 | return -ENODEV; | 1055 | return -ENODEV; |
1082 | } | 1056 | } |
1083 | 1057 | ||
1084 | // Setup initial mode -- the default mode 0 is TI_MODE_CONFIGURING | 1058 | /* |
1085 | // if we have more than one endpoint we are definitely in download mode | 1059 | * Setup initial mode -- the default mode 0 is TI_MODE_CONFIGURING |
1060 | * if we have more than one endpoint we are definitely in download | ||
1061 | * mode | ||
1062 | */ | ||
1086 | if (interface->bNumEndpoints > 1) | 1063 | if (interface->bNumEndpoints > 1) |
1087 | serial->product_info.TiMode = TI_MODE_DOWNLOAD; | 1064 | serial->product_info.TiMode = TI_MODE_DOWNLOAD; |
1088 | else | 1065 | else |
1089 | // Otherwise we will remain in configuring mode | 1066 | /* Otherwise we will remain in configuring mode */ |
1090 | serial->product_info.TiMode = TI_MODE_CONFIGURING; | 1067 | serial->product_info.TiMode = TI_MODE_CONFIGURING; |
1091 | 1068 | ||
1092 | /********************************************************************/ | 1069 | /********************************************************************/ |
@@ -1097,256 +1074,273 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) | |||
1097 | 1074 | ||
1098 | dbg("%s - RUNNING IN DOWNLOAD MODE", __func__); | 1075 | dbg("%s - RUNNING IN DOWNLOAD MODE", __func__); |
1099 | 1076 | ||
1100 | status = TiValidateI2cImage (serial); | 1077 | status = check_i2c_image(serial); |
1101 | if (status) { | 1078 | if (status) { |
1102 | dbg("%s - DOWNLOAD MODE -- BAD I2C", __func__); | 1079 | dbg("%s - DOWNLOAD MODE -- BAD I2C", __func__); |
1103 | return status; | 1080 | return status; |
1104 | } | 1081 | } |
1105 | 1082 | ||
1106 | /* Validate Hardware version number | 1083 | /* Validate Hardware version number |
1107 | * Read Manufacturing Descriptor from TI Based Edgeport | 1084 | * Read Manufacturing Descriptor from TI Based Edgeport |
1108 | */ | 1085 | */ |
1109 | ti_manuf_desc = kmalloc (sizeof (*ti_manuf_desc), GFP_KERNEL); | 1086 | ti_manuf_desc = kmalloc(sizeof(*ti_manuf_desc), GFP_KERNEL); |
1110 | if (!ti_manuf_desc) { | 1087 | if (!ti_manuf_desc) { |
1111 | dev_err (dev, "%s - out of memory.\n", __func__); | 1088 | dev_err(dev, "%s - out of memory.\n", __func__); |
1112 | return -ENOMEM; | 1089 | return -ENOMEM; |
1113 | } | 1090 | } |
1114 | status = TIReadManufDescriptor (serial, (__u8 *)ti_manuf_desc); | 1091 | status = get_manuf_info(serial, (__u8 *)ti_manuf_desc); |
1115 | if (status) { | 1092 | if (status) { |
1116 | kfree (ti_manuf_desc); | 1093 | kfree(ti_manuf_desc); |
1117 | return status; | 1094 | return status; |
1118 | } | 1095 | } |
1119 | 1096 | ||
1120 | // Check version number of ION descriptor | 1097 | /* Check version number of ION descriptor */ |
1121 | if (!ignore_cpu_rev && TI_GET_CPU_REVISION(ti_manuf_desc->CpuRev_BoardRev) < 2) { | 1098 | if (!ignore_cpu_rev && ti_cpu_rev(ti_manuf_desc) < 2) { |
1122 | dbg ( "%s - Wrong CPU Rev %d (Must be 2)", __func__, | 1099 | dbg("%s - Wrong CPU Rev %d (Must be 2)", |
1123 | TI_GET_CPU_REVISION(ti_manuf_desc->CpuRev_BoardRev)); | 1100 | __func__, ti_cpu_rev(ti_manuf_desc)); |
1124 | kfree (ti_manuf_desc); | 1101 | kfree(ti_manuf_desc); |
1125 | return -EINVAL; | 1102 | return -EINVAL; |
1126 | } | 1103 | } |
1127 | 1104 | ||
1128 | rom_desc = kmalloc (sizeof (*rom_desc), GFP_KERNEL); | 1105 | rom_desc = kmalloc(sizeof(*rom_desc), GFP_KERNEL); |
1129 | if (!rom_desc) { | 1106 | if (!rom_desc) { |
1130 | dev_err (dev, "%s - out of memory.\n", __func__); | 1107 | dev_err(dev, "%s - out of memory.\n", __func__); |
1131 | kfree (ti_manuf_desc); | 1108 | kfree(ti_manuf_desc); |
1132 | return -ENOMEM; | 1109 | return -ENOMEM; |
1133 | } | 1110 | } |
1134 | 1111 | ||
1135 | // Search for type 2 record (firmware record) | 1112 | /* Search for type 2 record (firmware record) */ |
1136 | if ((start_address = TIGetDescriptorAddress (serial, I2C_DESC_TYPE_FIRMWARE_BASIC, rom_desc)) != 0) { | 1113 | start_address = get_descriptor_addr(serial, |
1114 | I2C_DESC_TYPE_FIRMWARE_BASIC, rom_desc); | ||
1115 | if (start_address != 0) { | ||
1137 | struct ti_i2c_firmware_rec *firmware_version; | 1116 | struct ti_i2c_firmware_rec *firmware_version; |
1138 | __u8 record; | 1117 | __u8 record; |
1139 | 1118 | ||
1140 | dbg ("%s - Found Type FIRMWARE (Type 2) record", __func__); | 1119 | dbg("%s - Found Type FIRMWARE (Type 2) record", |
1120 | __func__); | ||
1141 | 1121 | ||
1142 | firmware_version = kmalloc (sizeof (*firmware_version), GFP_KERNEL); | 1122 | firmware_version = kmalloc(sizeof(*firmware_version), |
1123 | GFP_KERNEL); | ||
1143 | if (!firmware_version) { | 1124 | if (!firmware_version) { |
1144 | dev_err (dev, "%s - out of memory.\n", __func__); | 1125 | dev_err(dev, "%s - out of memory.\n", __func__); |
1145 | kfree (rom_desc); | 1126 | kfree(rom_desc); |
1146 | kfree (ti_manuf_desc); | 1127 | kfree(ti_manuf_desc); |
1147 | return -ENOMEM; | 1128 | return -ENOMEM; |
1148 | } | 1129 | } |
1149 | 1130 | ||
1150 | // Validate version number | 1131 | /* Validate version number |
1151 | // Read the descriptor data | 1132 | * Read the descriptor data |
1152 | status = TIReadRom (serial, | 1133 | */ |
1153 | start_address+sizeof(struct ti_i2c_desc), | 1134 | status = read_rom(serial, start_address + |
1135 | sizeof(struct ti_i2c_desc), | ||
1154 | sizeof(struct ti_i2c_firmware_rec), | 1136 | sizeof(struct ti_i2c_firmware_rec), |
1155 | (__u8 *)firmware_version); | 1137 | (__u8 *)firmware_version); |
1156 | if (status) { | 1138 | if (status) { |
1157 | kfree (firmware_version); | 1139 | kfree(firmware_version); |
1158 | kfree (rom_desc); | 1140 | kfree(rom_desc); |
1159 | kfree (ti_manuf_desc); | 1141 | kfree(ti_manuf_desc); |
1160 | return status; | 1142 | return status; |
1161 | } | 1143 | } |
1162 | 1144 | ||
1163 | // Check version number of download with current version in I2c | 1145 | /* Check version number of download with current |
1164 | download_cur_ver = (firmware_version->Ver_Major << 8) + | 1146 | version in I2c */ |
1147 | download_cur_ver = (firmware_version->Ver_Major << 8) + | ||
1165 | (firmware_version->Ver_Minor); | 1148 | (firmware_version->Ver_Minor); |
1166 | download_new_ver = (OperationalMajorVersion << 8) + | 1149 | download_new_ver = (OperationalMajorVersion << 8) + |
1167 | (OperationalMinorVersion); | 1150 | (OperationalMinorVersion); |
1168 | 1151 | ||
1169 | dbg ("%s - >>>Firmware Versions Device %d.%d Driver %d.%d", | 1152 | dbg("%s - >> FW Versions Device %d.%d Driver %d.%d", |
1170 | __func__, | 1153 | __func__, |
1171 | firmware_version->Ver_Major, | 1154 | firmware_version->Ver_Major, |
1172 | firmware_version->Ver_Minor, | 1155 | firmware_version->Ver_Minor, |
1173 | OperationalMajorVersion, | 1156 | OperationalMajorVersion, |
1174 | OperationalMinorVersion); | 1157 | OperationalMinorVersion); |
1175 | 1158 | ||
1176 | // Check if we have an old version in the I2C and update if necessary | 1159 | /* Check if we have an old version in the I2C and |
1160 | update if necessary */ | ||
1177 | if (download_cur_ver != download_new_ver) { | 1161 | if (download_cur_ver != download_new_ver) { |
1178 | dbg ("%s - Update I2C Download from %d.%d to %d.%d", | 1162 | dbg("%s - Update I2C dld from %d.%d to %d.%d", |
1179 | __func__, | 1163 | __func__, |
1180 | firmware_version->Ver_Major, | 1164 | firmware_version->Ver_Major, |
1181 | firmware_version->Ver_Minor, | 1165 | firmware_version->Ver_Minor, |
1182 | OperationalMajorVersion, | 1166 | OperationalMajorVersion, |
1183 | OperationalMinorVersion); | 1167 | OperationalMinorVersion); |
1184 | 1168 | ||
1185 | // In order to update the I2C firmware we must change the type 2 record to type 0xF2. | 1169 | /* In order to update the I2C firmware we must |
1186 | // This will force the UMP to come up in Boot Mode. Then while in boot mode, the driver | 1170 | * change the type 2 record to type 0xF2. This |
1187 | // will download the latest firmware (padded to 15.5k) into the UMP ram. | 1171 | * will force the UMP to come up in Boot Mode. |
1188 | // And finally when the device comes back up in download mode the driver will cause | 1172 | * Then while in boot mode, the driver will |
1189 | // the new firmware to be copied from the UMP Ram to I2C and the firmware will update | 1173 | * download the latest firmware (padded to |
1190 | // the record type from 0xf2 to 0x02. | 1174 | * 15.5k) into the UMP ram. Finally when the |
1191 | 1175 | * device comes back up in download mode the | |
1176 | * driver will cause the new firmware to be | ||
1177 | * copied from the UMP Ram to I2C and the | ||
1178 | * firmware will update the record type from | ||
1179 | * 0xf2 to 0x02. | ||
1180 | */ | ||
1192 | record = I2C_DESC_TYPE_FIRMWARE_BLANK; | 1181 | record = I2C_DESC_TYPE_FIRMWARE_BLANK; |
1193 | 1182 | ||
1194 | // Change the I2C Firmware record type to 0xf2 to trigger an update | 1183 | /* Change the I2C Firmware record type to |
1195 | status = TIWriteRom (serial, | 1184 | 0xf2 to trigger an update */ |
1196 | start_address, | 1185 | status = write_rom(serial, start_address, |
1197 | sizeof(record), | 1186 | sizeof(record), &record); |
1198 | &record); | ||
1199 | if (status) { | 1187 | if (status) { |
1200 | kfree (firmware_version); | 1188 | kfree(firmware_version); |
1201 | kfree (rom_desc); | 1189 | kfree(rom_desc); |
1202 | kfree (ti_manuf_desc); | 1190 | kfree(ti_manuf_desc); |
1203 | return status; | 1191 | return status; |
1204 | } | 1192 | } |
1205 | 1193 | ||
1206 | // verify the write -- must do this in order for write to | 1194 | /* verify the write -- must do this in order |
1207 | // complete before we do the hardware reset | 1195 | * for write to complete before we do the |
1208 | status = TIReadRom (serial, | 1196 | * hardware reset |
1197 | */ | ||
1198 | status = read_rom(serial, | ||
1209 | start_address, | 1199 | start_address, |
1210 | sizeof(record), | 1200 | sizeof(record), |
1211 | &record); | 1201 | &record); |
1212 | |||
1213 | if (status) { | 1202 | if (status) { |
1214 | kfree (firmware_version); | 1203 | kfree(firmware_version); |
1215 | kfree (rom_desc); | 1204 | kfree(rom_desc); |
1216 | kfree (ti_manuf_desc); | 1205 | kfree(ti_manuf_desc); |
1217 | return status; | 1206 | return status; |
1218 | } | 1207 | } |
1219 | 1208 | ||
1220 | if (record != I2C_DESC_TYPE_FIRMWARE_BLANK) { | 1209 | if (record != I2C_DESC_TYPE_FIRMWARE_BLANK) { |
1221 | dev_err (dev, "%s - error resetting device\n", __func__); | 1210 | dev_err(dev, |
1222 | kfree (firmware_version); | 1211 | "%s - error resetting device\n", |
1223 | kfree (rom_desc); | 1212 | __func__); |
1224 | kfree (ti_manuf_desc); | 1213 | kfree(firmware_version); |
1214 | kfree(rom_desc); | ||
1215 | kfree(ti_manuf_desc); | ||
1225 | return -ENODEV; | 1216 | return -ENODEV; |
1226 | } | 1217 | } |
1227 | 1218 | ||
1228 | dbg ("%s - HARDWARE RESET", __func__); | 1219 | dbg("%s - HARDWARE RESET", __func__); |
1229 | 1220 | ||
1230 | // Reset UMP -- Back to BOOT MODE | 1221 | /* Reset UMP -- Back to BOOT MODE */ |
1231 | status = TISendVendorRequestSync (serial->serial->dev, | 1222 | status = ti_vsend_sync(serial->serial->dev, |
1232 | UMPC_HARDWARE_RESET, // Request | 1223 | UMPC_HARDWARE_RESET, |
1233 | 0, // wValue | 1224 | 0, 0, NULL, 0); |
1234 | 0, // wIndex | ||
1235 | NULL, // TransferBuffer | ||
1236 | 0); // TransferBufferLength | ||
1237 | 1225 | ||
1238 | dbg ( "%s - HARDWARE RESET return %d", __func__, status); | 1226 | dbg("%s - HARDWARE RESET return %d", |
1227 | __func__, status); | ||
1239 | 1228 | ||
1240 | /* return an error on purpose. */ | 1229 | /* return an error on purpose. */ |
1241 | kfree (firmware_version); | 1230 | kfree(firmware_version); |
1242 | kfree (rom_desc); | 1231 | kfree(rom_desc); |
1243 | kfree (ti_manuf_desc); | 1232 | kfree(ti_manuf_desc); |
1244 | return -ENODEV; | 1233 | return -ENODEV; |
1245 | } | 1234 | } |
1246 | kfree (firmware_version); | 1235 | kfree(firmware_version); |
1247 | } | 1236 | } |
1248 | // Search for type 0xF2 record (firmware blank record) | 1237 | /* Search for type 0xF2 record (firmware blank record) */ |
1249 | else if ((start_address = TIGetDescriptorAddress (serial, I2C_DESC_TYPE_FIRMWARE_BLANK, rom_desc)) != 0) { | 1238 | else if ((start_address = get_descriptor_addr(serial, I2C_DESC_TYPE_FIRMWARE_BLANK, rom_desc)) != 0) { |
1250 | #define HEADER_SIZE (sizeof(struct ti_i2c_desc) + sizeof(struct ti_i2c_firmware_rec)) | 1239 | #define HEADER_SIZE (sizeof(struct ti_i2c_desc) + \ |
1240 | sizeof(struct ti_i2c_firmware_rec)) | ||
1251 | __u8 *header; | 1241 | __u8 *header; |
1252 | __u8 *vheader; | 1242 | __u8 *vheader; |
1253 | 1243 | ||
1254 | header = kmalloc (HEADER_SIZE, GFP_KERNEL); | 1244 | header = kmalloc(HEADER_SIZE, GFP_KERNEL); |
1255 | if (!header) { | 1245 | if (!header) { |
1256 | dev_err (dev, "%s - out of memory.\n", __func__); | 1246 | dev_err(dev, "%s - out of memory.\n", __func__); |
1257 | kfree (rom_desc); | 1247 | kfree(rom_desc); |
1258 | kfree (ti_manuf_desc); | 1248 | kfree(ti_manuf_desc); |
1259 | return -ENOMEM; | 1249 | return -ENOMEM; |
1260 | } | 1250 | } |
1261 | 1251 | ||
1262 | vheader = kmalloc (HEADER_SIZE, GFP_KERNEL); | 1252 | vheader = kmalloc(HEADER_SIZE, GFP_KERNEL); |
1263 | if (!vheader) { | 1253 | if (!vheader) { |
1264 | dev_err (dev, "%s - out of memory.\n", __func__); | 1254 | dev_err(dev, "%s - out of memory.\n", __func__); |
1265 | kfree (header); | 1255 | kfree(header); |
1266 | kfree (rom_desc); | 1256 | kfree(rom_desc); |
1267 | kfree (ti_manuf_desc); | 1257 | kfree(ti_manuf_desc); |
1268 | return -ENOMEM; | 1258 | return -ENOMEM; |
1269 | } | 1259 | } |
1270 | 1260 | ||
1271 | dbg ("%s - Found Type BLANK FIRMWARE (Type F2) record", __func__); | 1261 | dbg("%s - Found Type BLANK FIRMWARE (Type F2) record", |
1272 | 1262 | __func__); | |
1273 | // In order to update the I2C firmware we must change the type 2 record to type 0xF2. | 1263 | |
1274 | // This will force the UMP to come up in Boot Mode. Then while in boot mode, the driver | 1264 | /* |
1275 | // will download the latest firmware (padded to 15.5k) into the UMP ram. | 1265 | * In order to update the I2C firmware we must change |
1276 | // And finally when the device comes back up in download mode the driver will cause | 1266 | * the type 2 record to type 0xF2. This will force the |
1277 | // the new firmware to be copied from the UMP Ram to I2C and the firmware will update | 1267 | * UMP to come up in Boot Mode. Then while in boot |
1278 | // the record type from 0xf2 to 0x02. | 1268 | * mode, the driver will download the latest firmware |
1279 | status = BuildI2CFirmwareHeader(header, dev); | 1269 | * (padded to 15.5k) into the UMP ram. Finally when the |
1270 | * device comes back up in download mode the driver | ||
1271 | * will cause the new firmware to be copied from the | ||
1272 | * UMP Ram to I2C and the firmware will update the | ||
1273 | * record type from 0xf2 to 0x02. | ||
1274 | */ | ||
1275 | status = build_i2c_fw_hdr(header, dev); | ||
1280 | if (status) { | 1276 | if (status) { |
1281 | kfree (vheader); | 1277 | kfree(vheader); |
1282 | kfree (header); | 1278 | kfree(header); |
1283 | kfree (rom_desc); | 1279 | kfree(rom_desc); |
1284 | kfree (ti_manuf_desc); | 1280 | kfree(ti_manuf_desc); |
1285 | return status; | 1281 | return status; |
1286 | } | 1282 | } |
1287 | 1283 | ||
1288 | // Update I2C with type 0xf2 record with correct size and checksum | 1284 | /* Update I2C with type 0xf2 record with correct |
1289 | status = TIWriteRom (serial, | 1285 | size and checksum */ |
1286 | status = write_rom(serial, | ||
1290 | start_address, | 1287 | start_address, |
1291 | HEADER_SIZE, | 1288 | HEADER_SIZE, |
1292 | header); | 1289 | header); |
1293 | if (status) { | 1290 | if (status) { |
1294 | kfree (vheader); | 1291 | kfree(vheader); |
1295 | kfree (header); | 1292 | kfree(header); |
1296 | kfree (rom_desc); | 1293 | kfree(rom_desc); |
1297 | kfree (ti_manuf_desc); | 1294 | kfree(ti_manuf_desc); |
1298 | return status; | 1295 | return status; |
1299 | } | 1296 | } |
1300 | 1297 | ||
1301 | // verify the write -- must do this in order for write to | 1298 | /* verify the write -- must do this in order for |
1302 | // complete before we do the hardware reset | 1299 | write to complete before we do the hardware reset */ |
1303 | status = TIReadRom (serial, | 1300 | status = read_rom(serial, start_address, |
1304 | start_address, | 1301 | HEADER_SIZE, vheader); |
1305 | HEADER_SIZE, | ||
1306 | vheader); | ||
1307 | 1302 | ||
1308 | if (status) { | 1303 | if (status) { |
1309 | dbg ("%s - can't read header back", __func__); | 1304 | dbg("%s - can't read header back", __func__); |
1310 | kfree (vheader); | 1305 | kfree(vheader); |
1311 | kfree (header); | 1306 | kfree(header); |
1312 | kfree (rom_desc); | 1307 | kfree(rom_desc); |
1313 | kfree (ti_manuf_desc); | 1308 | kfree(ti_manuf_desc); |
1314 | return status; | 1309 | return status; |
1315 | } | 1310 | } |
1316 | if (memcmp(vheader, header, HEADER_SIZE)) { | 1311 | if (memcmp(vheader, header, HEADER_SIZE)) { |
1317 | dbg ("%s - write download record failed", __func__); | 1312 | dbg("%s - write download record failed", |
1318 | kfree (vheader); | 1313 | __func__); |
1319 | kfree (header); | 1314 | kfree(vheader); |
1320 | kfree (rom_desc); | 1315 | kfree(header); |
1321 | kfree (ti_manuf_desc); | 1316 | kfree(rom_desc); |
1317 | kfree(ti_manuf_desc); | ||
1322 | return status; | 1318 | return status; |
1323 | } | 1319 | } |
1324 | 1320 | ||
1325 | kfree (vheader); | 1321 | kfree(vheader); |
1326 | kfree (header); | 1322 | kfree(header); |
1327 | 1323 | ||
1328 | dbg ("%s - Start firmware update", __func__); | 1324 | dbg("%s - Start firmware update", __func__); |
1329 | 1325 | ||
1330 | // Tell firmware to copy download image into I2C | 1326 | /* Tell firmware to copy download image into I2C */ |
1331 | status = TISendVendorRequestSync (serial->serial->dev, | 1327 | status = ti_vsend_sync(serial->serial->dev, |
1332 | UMPC_COPY_DNLD_TO_I2C, // Request | 1328 | UMPC_COPY_DNLD_TO_I2C, 0, 0, NULL, 0); |
1333 | 0, // wValue | ||
1334 | 0, // wIndex | ||
1335 | NULL, // TransferBuffer | ||
1336 | 0); // TransferBufferLength | ||
1337 | 1329 | ||
1338 | dbg ("%s - Update complete 0x%x", __func__, status); | 1330 | dbg("%s - Update complete 0x%x", __func__, status); |
1339 | if (status) { | 1331 | if (status) { |
1340 | dev_err (dev, "%s - UMPC_COPY_DNLD_TO_I2C failed\n", __func__); | 1332 | dev_err(dev, |
1341 | kfree (rom_desc); | 1333 | "%s - UMPC_COPY_DNLD_TO_I2C failed\n", |
1342 | kfree (ti_manuf_desc); | 1334 | __func__); |
1335 | kfree(rom_desc); | ||
1336 | kfree(ti_manuf_desc); | ||
1343 | return status; | 1337 | return status; |
1344 | } | 1338 | } |
1345 | } | 1339 | } |
1346 | 1340 | ||
1347 | // The device is running the download code | 1341 | // The device is running the download code |
1348 | kfree (rom_desc); | 1342 | kfree(rom_desc); |
1349 | kfree (ti_manuf_desc); | 1343 | kfree(ti_manuf_desc); |
1350 | return 0; | 1344 | return 0; |
1351 | } | 1345 | } |
1352 | 1346 | ||
@@ -1355,32 +1349,26 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) | |||
1355 | /********************************************************************/ | 1349 | /********************************************************************/ |
1356 | dbg("%s - RUNNING IN BOOT MODE", __func__); | 1350 | dbg("%s - RUNNING IN BOOT MODE", __func__); |
1357 | 1351 | ||
1358 | // Configure the TI device so we can use the BULK pipes for download | 1352 | /* Configure the TI device so we can use the BULK pipes for download */ |
1359 | status = TIConfigureBootDevice (serial->serial->dev); | 1353 | status = config_boot_dev(serial->serial->dev); |
1360 | if (status) | 1354 | if (status) |
1361 | return status; | 1355 | return status; |
1362 | 1356 | ||
1363 | if (le16_to_cpu(serial->serial->dev->descriptor.idVendor) != USB_VENDOR_ID_ION) { | 1357 | if (le16_to_cpu(serial->serial->dev->descriptor.idVendor) |
1364 | dbg ("%s - VID = 0x%x", __func__, | 1358 | != USB_VENDOR_ID_ION) { |
1359 | dbg("%s - VID = 0x%x", __func__, | ||
1365 | le16_to_cpu(serial->serial->dev->descriptor.idVendor)); | 1360 | le16_to_cpu(serial->serial->dev->descriptor.idVendor)); |
1366 | serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; | 1361 | serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; |
1367 | goto StayInBootMode; | 1362 | goto stayinbootmode; |
1368 | } | ||
1369 | |||
1370 | // We have an ION device (I2c Must be programmed) | ||
1371 | // Determine I2C image type | ||
1372 | if (TIGetI2cTypeInBootMode(serial)) { | ||
1373 | goto StayInBootMode; | ||
1374 | } | 1363 | } |
1375 | 1364 | ||
1376 | // Registry variable set? | 1365 | /* We have an ION device (I2c Must be programmed) |
1377 | if (TIStayInBootMode) { | 1366 | Determine I2C image type */ |
1378 | dbg ("%s - TIStayInBootMode", __func__); | 1367 | if (i2c_type_bootmode(serial)) |
1379 | goto StayInBootMode; | 1368 | goto stayinbootmode; |
1380 | } | ||
1381 | 1369 | ||
1382 | // Check for ION Vendor ID and that the I2C is valid | 1370 | /* Check for ION Vendor ID and that the I2C is valid */ |
1383 | if (!TiValidateI2cImage(serial)) { | 1371 | if (!check_i2c_image(serial)) { |
1384 | struct ti_i2c_image_header *header; | 1372 | struct ti_i2c_image_header *header; |
1385 | int i; | 1373 | int i; |
1386 | __u8 cs = 0; | 1374 | __u8 cs = 0; |
@@ -1393,49 +1381,52 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) | |||
1393 | /* Validate Hardware version number | 1381 | /* Validate Hardware version number |
1394 | * Read Manufacturing Descriptor from TI Based Edgeport | 1382 | * Read Manufacturing Descriptor from TI Based Edgeport |
1395 | */ | 1383 | */ |
1396 | ti_manuf_desc = kmalloc (sizeof (*ti_manuf_desc), GFP_KERNEL); | 1384 | ti_manuf_desc = kmalloc(sizeof(*ti_manuf_desc), GFP_KERNEL); |
1397 | if (!ti_manuf_desc) { | 1385 | if (!ti_manuf_desc) { |
1398 | dev_err (dev, "%s - out of memory.\n", __func__); | 1386 | dev_err(dev, "%s - out of memory.\n", __func__); |
1399 | return -ENOMEM; | 1387 | return -ENOMEM; |
1400 | } | 1388 | } |
1401 | status = TIReadManufDescriptor (serial, (__u8 *)ti_manuf_desc); | 1389 | status = get_manuf_info(serial, (__u8 *)ti_manuf_desc); |
1402 | if (status) { | 1390 | if (status) { |
1403 | kfree (ti_manuf_desc); | 1391 | kfree(ti_manuf_desc); |
1404 | goto StayInBootMode; | 1392 | goto stayinbootmode; |
1405 | } | 1393 | } |
1406 | 1394 | ||
1407 | // Check for version 2 | 1395 | /* Check for version 2 */ |
1408 | if (!ignore_cpu_rev && TI_GET_CPU_REVISION(ti_manuf_desc->CpuRev_BoardRev) < 2) { | 1396 | if (!ignore_cpu_rev && ti_cpu_rev(ti_manuf_desc) < 2) { |
1409 | dbg ("%s - Wrong CPU Rev %d (Must be 2)", __func__, | 1397 | dbg("%s - Wrong CPU Rev %d (Must be 2)", |
1410 | TI_GET_CPU_REVISION(ti_manuf_desc->CpuRev_BoardRev)); | 1398 | __func__, ti_cpu_rev(ti_manuf_desc)); |
1411 | kfree (ti_manuf_desc); | 1399 | kfree(ti_manuf_desc); |
1412 | goto StayInBootMode; | 1400 | goto stayinbootmode; |
1413 | } | 1401 | } |
1414 | 1402 | ||
1415 | kfree (ti_manuf_desc); | 1403 | kfree(ti_manuf_desc); |
1416 | 1404 | ||
1417 | // In order to update the I2C firmware we must change the type 2 record to type 0xF2. | ||
1418 | // This will force the UMP to come up in Boot Mode. Then while in boot mode, the driver | ||
1419 | // will download the latest firmware (padded to 15.5k) into the UMP ram. | ||
1420 | // And finally when the device comes back up in download mode the driver will cause | ||
1421 | // the new firmware to be copied from the UMP Ram to I2C and the firmware will update | ||
1422 | // the record type from 0xf2 to 0x02. | ||
1423 | |||
1424 | /* | 1405 | /* |
1406 | * In order to update the I2C firmware we must change the type | ||
1407 | * 2 record to type 0xF2. This will force the UMP to come up | ||
1408 | * in Boot Mode. Then while in boot mode, the driver will | ||
1409 | * download the latest firmware (padded to 15.5k) into the | ||
1410 | * UMP ram. Finally when the device comes back up in download | ||
1411 | * mode the driver will cause the new firmware to be copied | ||
1412 | * from the UMP Ram to I2C and the firmware will update the | ||
1413 | * record type from 0xf2 to 0x02. | ||
1414 | * | ||
1425 | * Do we really have to copy the whole firmware image, | 1415 | * Do we really have to copy the whole firmware image, |
1426 | * or could we do this in place! | 1416 | * or could we do this in place! |
1427 | */ | 1417 | */ |
1428 | 1418 | ||
1429 | // Allocate a 15.5k buffer + 3 byte header | 1419 | /* Allocate a 15.5k buffer + 3 byte header */ |
1430 | buffer_size = (((1024 * 16) - 512) + sizeof(struct ti_i2c_image_header)); | 1420 | buffer_size = (((1024 * 16) - 512) + |
1431 | buffer = kmalloc (buffer_size, GFP_KERNEL); | 1421 | sizeof(struct ti_i2c_image_header)); |
1422 | buffer = kmalloc(buffer_size, GFP_KERNEL); | ||
1432 | if (!buffer) { | 1423 | if (!buffer) { |
1433 | dev_err (dev, "%s - out of memory\n", __func__); | 1424 | dev_err(dev, "%s - out of memory\n", __func__); |
1434 | return -ENOMEM; | 1425 | return -ENOMEM; |
1435 | } | 1426 | } |
1436 | 1427 | ||
1437 | // Initialize the buffer to 0xff (pad the buffer) | 1428 | /* Initialize the buffer to 0xff (pad the buffer) */ |
1438 | memset (buffer, 0xff, buffer_size); | 1429 | memset(buffer, 0xff, buffer_size); |
1439 | 1430 | ||
1440 | err = request_firmware(&fw, fw_name, dev); | 1431 | err = request_firmware(&fw, fw_name, dev); |
1441 | if (err) { | 1432 | if (err) { |
@@ -1447,38 +1438,43 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) | |||
1447 | memcpy(buffer, &fw->data[4], fw->size - 4); | 1438 | memcpy(buffer, &fw->data[4], fw->size - 4); |
1448 | release_firmware(fw); | 1439 | release_firmware(fw); |
1449 | 1440 | ||
1450 | for(i = sizeof(struct ti_i2c_image_header); i < buffer_size; i++) { | 1441 | for (i = sizeof(struct ti_i2c_image_header); |
1442 | i < buffer_size; i++) { | ||
1451 | cs = (__u8)(cs + buffer[i]); | 1443 | cs = (__u8)(cs + buffer[i]); |
1452 | } | 1444 | } |
1453 | 1445 | ||
1454 | header = (struct ti_i2c_image_header *)buffer; | 1446 | header = (struct ti_i2c_image_header *)buffer; |
1455 | 1447 | ||
1456 | // update length and checksum after padding | 1448 | /* update length and checksum after padding */ |
1457 | header->Length = cpu_to_le16((__u16)(buffer_size - sizeof(struct ti_i2c_image_header))); | 1449 | header->Length = cpu_to_le16((__u16)(buffer_size - |
1450 | sizeof(struct ti_i2c_image_header))); | ||
1458 | header->CheckSum = cs; | 1451 | header->CheckSum = cs; |
1459 | 1452 | ||
1460 | // Download the operational code | 1453 | /* Download the operational code */ |
1461 | dbg ("%s - Downloading operational code image (TI UMP)", __func__); | 1454 | dbg("%s - Downloading operational code image (TI UMP)", |
1462 | status = TIDownloadCodeImage (serial, buffer, buffer_size); | 1455 | __func__); |
1456 | status = download_code(serial, buffer, buffer_size); | ||
1463 | 1457 | ||
1464 | kfree (buffer); | 1458 | kfree(buffer); |
1465 | 1459 | ||
1466 | if (status) { | 1460 | if (status) { |
1467 | dbg ("%s - Error downloading operational code image", __func__); | 1461 | dbg("%s - Error downloading operational code image", |
1462 | __func__); | ||
1468 | return status; | 1463 | return status; |
1469 | } | 1464 | } |
1470 | 1465 | ||
1471 | // Device will reboot | 1466 | /* Device will reboot */ |
1472 | serial->product_info.TiMode = TI_MODE_TRANSITIONING; | 1467 | serial->product_info.TiMode = TI_MODE_TRANSITIONING; |
1473 | 1468 | ||
1474 | dbg ("%s - Download successful -- Device rebooting...", __func__); | 1469 | dbg("%s - Download successful -- Device rebooting...", |
1470 | __func__); | ||
1475 | 1471 | ||
1476 | /* return an error on purpose */ | 1472 | /* return an error on purpose */ |
1477 | return -ENODEV; | 1473 | return -ENODEV; |
1478 | } | 1474 | } |
1479 | 1475 | ||
1480 | StayInBootMode: | 1476 | stayinbootmode: |
1481 | // Eprom is invalid or blank stay in boot mode | 1477 | /* Eprom is invalid or blank stay in boot mode */ |
1482 | dbg("%s - STAYING IN BOOT MODE", __func__); | 1478 | dbg("%s - STAYING IN BOOT MODE", __func__); |
1483 | serial->product_info.TiMode = TI_MODE_BOOT; | 1479 | serial->product_info.TiMode = TI_MODE_BOOT; |
1484 | 1480 | ||
@@ -1486,156 +1482,33 @@ StayInBootMode: | |||
1486 | } | 1482 | } |
1487 | 1483 | ||
1488 | 1484 | ||
1489 | static int TISetDtr (struct edgeport_port *port) | 1485 | static int ti_do_config(struct edgeport_port *port, int feature, int on) |
1490 | { | 1486 | { |
1491 | int port_number = port->port->number - port->port->serial->minor; | 1487 | int port_number = port->port->number - port->port->serial->minor; |
1492 | 1488 | on = !!on; /* 1 or 0 not bitmask */ | |
1493 | dbg ("%s", __func__); | 1489 | return send_cmd(port->port->serial->dev, |
1494 | port->shadow_mcr |= MCR_DTR; | 1490 | feature, (__u8)(UMPM_UART1_PORT + port_number), |
1495 | 1491 | on, NULL, 0); | |
1496 | return TIWriteCommandSync (port->port->serial->dev, | ||
1497 | UMPC_SET_CLR_DTR, | ||
1498 | (__u8)(UMPM_UART1_PORT + port_number), | ||
1499 | 1, /* set */ | ||
1500 | NULL, | ||
1501 | 0); | ||
1502 | } | 1492 | } |
1503 | 1493 | ||
1504 | static int TIClearDtr (struct edgeport_port *port) | ||
1505 | { | ||
1506 | int port_number = port->port->number - port->port->serial->minor; | ||
1507 | |||
1508 | dbg ("%s", __func__); | ||
1509 | port->shadow_mcr &= ~MCR_DTR; | ||
1510 | 1494 | ||
1511 | return TIWriteCommandSync (port->port->serial->dev, | 1495 | static int restore_mcr(struct edgeport_port *port, __u8 mcr) |
1512 | UMPC_SET_CLR_DTR, | ||
1513 | (__u8)(UMPM_UART1_PORT + port_number), | ||
1514 | 0, /* clear */ | ||
1515 | NULL, | ||
1516 | 0); | ||
1517 | } | ||
1518 | |||
1519 | static int TISetRts (struct edgeport_port *port) | ||
1520 | { | ||
1521 | int port_number = port->port->number - port->port->serial->minor; | ||
1522 | |||
1523 | dbg ("%s", __func__); | ||
1524 | port->shadow_mcr |= MCR_RTS; | ||
1525 | |||
1526 | return TIWriteCommandSync (port->port->serial->dev, | ||
1527 | UMPC_SET_CLR_RTS, | ||
1528 | (__u8)(UMPM_UART1_PORT + port_number), | ||
1529 | 1, /* set */ | ||
1530 | NULL, | ||
1531 | 0); | ||
1532 | } | ||
1533 | |||
1534 | static int TIClearRts (struct edgeport_port *port) | ||
1535 | { | ||
1536 | int port_number = port->port->number - port->port->serial->minor; | ||
1537 | |||
1538 | dbg ("%s", __func__); | ||
1539 | port->shadow_mcr &= ~MCR_RTS; | ||
1540 | |||
1541 | return TIWriteCommandSync (port->port->serial->dev, | ||
1542 | UMPC_SET_CLR_RTS, | ||
1543 | (__u8)(UMPM_UART1_PORT + port_number), | ||
1544 | 0, /* clear */ | ||
1545 | NULL, | ||
1546 | 0); | ||
1547 | } | ||
1548 | |||
1549 | static int TISetLoopBack (struct edgeport_port *port) | ||
1550 | { | ||
1551 | int port_number = port->port->number - port->port->serial->minor; | ||
1552 | |||
1553 | dbg ("%s", __func__); | ||
1554 | |||
1555 | return TIWriteCommandSync (port->port->serial->dev, | ||
1556 | UMPC_SET_CLR_LOOPBACK, | ||
1557 | (__u8)(UMPM_UART1_PORT + port_number), | ||
1558 | 1, /* set */ | ||
1559 | NULL, | ||
1560 | 0); | ||
1561 | } | ||
1562 | |||
1563 | static int TIClearLoopBack (struct edgeport_port *port) | ||
1564 | { | ||
1565 | int port_number = port->port->number - port->port->serial->minor; | ||
1566 | |||
1567 | dbg ("%s", __func__); | ||
1568 | |||
1569 | return TIWriteCommandSync (port->port->serial->dev, | ||
1570 | UMPC_SET_CLR_LOOPBACK, | ||
1571 | (__u8)(UMPM_UART1_PORT + port_number), | ||
1572 | 0, /* clear */ | ||
1573 | NULL, | ||
1574 | 0); | ||
1575 | } | ||
1576 | |||
1577 | static int TISetBreak (struct edgeport_port *port) | ||
1578 | { | ||
1579 | int port_number = port->port->number - port->port->serial->minor; | ||
1580 | |||
1581 | dbg ("%s", __func__); | ||
1582 | |||
1583 | return TIWriteCommandSync (port->port->serial->dev, | ||
1584 | UMPC_SET_CLR_BREAK, | ||
1585 | (__u8)(UMPM_UART1_PORT + port_number), | ||
1586 | 1, /* set */ | ||
1587 | NULL, | ||
1588 | 0); | ||
1589 | } | ||
1590 | |||
1591 | static int TIClearBreak (struct edgeport_port *port) | ||
1592 | { | ||
1593 | int port_number = port->port->number - port->port->serial->minor; | ||
1594 | |||
1595 | dbg ("%s", __func__); | ||
1596 | |||
1597 | return TIWriteCommandSync (port->port->serial->dev, | ||
1598 | UMPC_SET_CLR_BREAK, | ||
1599 | (__u8)(UMPM_UART1_PORT + port_number), | ||
1600 | 0, /* clear */ | ||
1601 | NULL, | ||
1602 | 0); | ||
1603 | } | ||
1604 | |||
1605 | static int TIRestoreMCR (struct edgeport_port *port, __u8 mcr) | ||
1606 | { | 1496 | { |
1607 | int status = 0; | 1497 | int status = 0; |
1608 | 1498 | ||
1609 | dbg ("%s - %x", __func__, mcr); | 1499 | dbg("%s - %x", __func__, mcr); |
1610 | |||
1611 | if (mcr & MCR_DTR) | ||
1612 | status = TISetDtr (port); | ||
1613 | else | ||
1614 | status = TIClearDtr (port); | ||
1615 | 1500 | ||
1501 | status = ti_do_config(port, UMPC_SET_CLR_DTR, mcr & MCR_DTR); | ||
1616 | if (status) | 1502 | if (status) |
1617 | return status; | 1503 | return status; |
1618 | 1504 | status = ti_do_config(port, UMPC_SET_CLR_RTS, mcr & MCR_RTS); | |
1619 | if (mcr & MCR_RTS) | ||
1620 | status = TISetRts (port); | ||
1621 | else | ||
1622 | status = TIClearRts (port); | ||
1623 | |||
1624 | if (status) | 1505 | if (status) |
1625 | return status; | 1506 | return status; |
1626 | 1507 | return ti_do_config(port, UMPC_SET_CLR_LOOPBACK, mcr & MCR_LOOPBACK); | |
1627 | if (mcr & MCR_LOOPBACK) | ||
1628 | status = TISetLoopBack (port); | ||
1629 | else | ||
1630 | status = TIClearLoopBack (port); | ||
1631 | |||
1632 | return status; | ||
1633 | } | 1508 | } |
1634 | 1509 | ||
1635 | |||
1636 | |||
1637 | /* Convert TI LSR to standard UART flags */ | 1510 | /* Convert TI LSR to standard UART flags */ |
1638 | static __u8 MapLineStatus (__u8 ti_lsr) | 1511 | static __u8 map_line_status(__u8 ti_lsr) |
1639 | { | 1512 | { |
1640 | __u8 lsr = 0; | 1513 | __u8 lsr = 0; |
1641 | 1514 | ||
@@ -1647,22 +1520,23 @@ static __u8 MapLineStatus (__u8 ti_lsr) | |||
1647 | MAP_FLAG(UMP_UART_LSR_PE_MASK, LSR_PAR_ERR) /* parity error */ | 1520 | MAP_FLAG(UMP_UART_LSR_PE_MASK, LSR_PAR_ERR) /* parity error */ |
1648 | MAP_FLAG(UMP_UART_LSR_FE_MASK, LSR_FRM_ERR) /* framing error */ | 1521 | MAP_FLAG(UMP_UART_LSR_FE_MASK, LSR_FRM_ERR) /* framing error */ |
1649 | MAP_FLAG(UMP_UART_LSR_BR_MASK, LSR_BREAK) /* break detected */ | 1522 | MAP_FLAG(UMP_UART_LSR_BR_MASK, LSR_BREAK) /* break detected */ |
1650 | MAP_FLAG(UMP_UART_LSR_RX_MASK, LSR_RX_AVAIL) /* receive data available */ | 1523 | MAP_FLAG(UMP_UART_LSR_RX_MASK, LSR_RX_AVAIL) /* rx data available */ |
1651 | MAP_FLAG(UMP_UART_LSR_TX_MASK, LSR_TX_EMPTY) /* transmit holding register empty */ | 1524 | MAP_FLAG(UMP_UART_LSR_TX_MASK, LSR_TX_EMPTY) /* tx hold reg empty */ |
1652 | 1525 | ||
1653 | #undef MAP_FLAG | 1526 | #undef MAP_FLAG |
1654 | 1527 | ||
1655 | return lsr; | 1528 | return lsr; |
1656 | } | 1529 | } |
1657 | 1530 | ||
1658 | static void handle_new_msr (struct edgeport_port *edge_port, __u8 msr) | 1531 | static void handle_new_msr(struct edgeport_port *edge_port, __u8 msr) |
1659 | { | 1532 | { |
1660 | struct async_icount *icount; | 1533 | struct async_icount *icount; |
1661 | struct tty_struct *tty; | 1534 | struct tty_struct *tty; |
1662 | 1535 | ||
1663 | dbg ("%s - %02x", __func__, msr); | 1536 | dbg("%s - %02x", __func__, msr); |
1664 | 1537 | ||
1665 | if (msr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) { | 1538 | if (msr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | |
1539 | EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) { | ||
1666 | icount = &edge_port->icount; | 1540 | icount = &edge_port->icount; |
1667 | 1541 | ||
1668 | /* update input line counters */ | 1542 | /* update input line counters */ |
@@ -1674,7 +1548,7 @@ static void handle_new_msr (struct edgeport_port *edge_port, __u8 msr) | |||
1674 | icount->dcd++; | 1548 | icount->dcd++; |
1675 | if (msr & EDGEPORT_MSR_DELTA_RI) | 1549 | if (msr & EDGEPORT_MSR_DELTA_RI) |
1676 | icount->rng++; | 1550 | icount->rng++; |
1677 | wake_up_interruptible (&edge_port->delta_msr_wait); | 1551 | wake_up_interruptible(&edge_port->delta_msr_wait); |
1678 | } | 1552 | } |
1679 | 1553 | ||
1680 | /* Save the new modem status */ | 1554 | /* Save the new modem status */ |
@@ -1694,26 +1568,28 @@ static void handle_new_msr (struct edgeport_port *edge_port, __u8 msr) | |||
1694 | return; | 1568 | return; |
1695 | } | 1569 | } |
1696 | 1570 | ||
1697 | static void handle_new_lsr (struct edgeport_port *edge_port, int lsr_data, __u8 lsr, __u8 data) | 1571 | static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data, |
1572 | __u8 lsr, __u8 data) | ||
1698 | { | 1573 | { |
1699 | struct async_icount *icount; | 1574 | struct async_icount *icount; |
1700 | __u8 new_lsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | LSR_FRM_ERR | LSR_BREAK)); | 1575 | __u8 new_lsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | |
1576 | LSR_FRM_ERR | LSR_BREAK)); | ||
1701 | 1577 | ||
1702 | dbg ("%s - %02x", __func__, new_lsr); | 1578 | dbg("%s - %02x", __func__, new_lsr); |
1703 | 1579 | ||
1704 | edge_port->shadow_lsr = lsr; | 1580 | edge_port->shadow_lsr = lsr; |
1705 | 1581 | ||
1706 | if (new_lsr & LSR_BREAK) { | 1582 | if (new_lsr & LSR_BREAK) |
1707 | /* | 1583 | /* |
1708 | * Parity and Framing errors only count if they | 1584 | * Parity and Framing errors only count if they |
1709 | * occur exclusive of a break being received. | 1585 | * occur exclusive of a break being received. |
1710 | */ | 1586 | */ |
1711 | new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK); | 1587 | new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK); |
1712 | } | ||
1713 | 1588 | ||
1714 | /* Place LSR data byte into Rx buffer */ | 1589 | /* Place LSR data byte into Rx buffer */ |
1715 | if (lsr_data && edge_port->port->tty) | 1590 | if (lsr_data && edge_port->port->tty) |
1716 | edge_tty_recv(&edge_port->port->dev, edge_port->port->tty, &data, 1); | 1591 | edge_tty_recv(&edge_port->port->dev, edge_port->port->tty, |
1592 | &data, 1); | ||
1717 | 1593 | ||
1718 | /* update input line counters */ | 1594 | /* update input line counters */ |
1719 | icount = &edge_port->icount; | 1595 | icount = &edge_port->icount; |
@@ -1728,7 +1604,7 @@ static void handle_new_lsr (struct edgeport_port *edge_port, int lsr_data, __u8 | |||
1728 | } | 1604 | } |
1729 | 1605 | ||
1730 | 1606 | ||
1731 | static void edge_interrupt_callback (struct urb *urb) | 1607 | static void edge_interrupt_callback(struct urb *urb) |
1732 | { | 1608 | { |
1733 | struct edgeport_serial *edge_serial = urb->context; | 1609 | struct edgeport_serial *edge_serial = urb->context; |
1734 | struct usb_serial_port *port; | 1610 | struct usb_serial_port *port; |
@@ -1762,66 +1638,71 @@ static void edge_interrupt_callback (struct urb *urb) | |||
1762 | } | 1638 | } |
1763 | 1639 | ||
1764 | if (!length) { | 1640 | if (!length) { |
1765 | dbg ("%s - no data in urb", __func__); | 1641 | dbg("%s - no data in urb", __func__); |
1766 | goto exit; | 1642 | goto exit; |
1767 | } | 1643 | } |
1768 | 1644 | ||
1769 | usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __func__, length, data); | 1645 | usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, |
1770 | 1646 | __func__, length, data); | |
1647 | |||
1771 | if (length != 2) { | 1648 | if (length != 2) { |
1772 | dbg ("%s - expecting packet of size 2, got %d", __func__, length); | 1649 | dbg("%s - expecting packet of size 2, got %d", |
1650 | __func__, length); | ||
1773 | goto exit; | 1651 | goto exit; |
1774 | } | 1652 | } |
1775 | 1653 | ||
1776 | port_number = TIUMP_GET_PORT_FROM_CODE (data[0]); | 1654 | port_number = TIUMP_GET_PORT_FROM_CODE(data[0]); |
1777 | function = TIUMP_GET_FUNC_FROM_CODE (data[0]); | 1655 | function = TIUMP_GET_FUNC_FROM_CODE(data[0]); |
1778 | dbg ("%s - port_number %d, function %d, info 0x%x", | 1656 | dbg("%s - port_number %d, function %d, info 0x%x", |
1779 | __func__, port_number, function, data[1]); | 1657 | __func__, port_number, function, data[1]); |
1780 | port = edge_serial->serial->port[port_number]; | 1658 | port = edge_serial->serial->port[port_number]; |
1781 | edge_port = usb_get_serial_port_data(port); | 1659 | edge_port = usb_get_serial_port_data(port); |
1782 | if (!edge_port) { | 1660 | if (!edge_port) { |
1783 | dbg ("%s - edge_port not found", __func__); | 1661 | dbg("%s - edge_port not found", __func__); |
1784 | return; | 1662 | return; |
1785 | } | 1663 | } |
1786 | switch (function) { | 1664 | switch (function) { |
1787 | case TIUMP_INTERRUPT_CODE_LSR: | 1665 | case TIUMP_INTERRUPT_CODE_LSR: |
1788 | lsr = MapLineStatus(data[1]); | 1666 | lsr = map_line_status(data[1]); |
1789 | if (lsr & UMP_UART_LSR_DATA_MASK) { | 1667 | if (lsr & UMP_UART_LSR_DATA_MASK) { |
1790 | /* Save the LSR event for bulk read completion routine */ | 1668 | /* Save the LSR event for bulk read |
1791 | dbg ("%s - LSR Event Port %u LSR Status = %02x", | 1669 | completion routine */ |
1670 | dbg("%s - LSR Event Port %u LSR Status = %02x", | ||
1792 | __func__, port_number, lsr); | 1671 | __func__, port_number, lsr); |
1793 | edge_port->lsr_event = 1; | 1672 | edge_port->lsr_event = 1; |
1794 | edge_port->lsr_mask = lsr; | 1673 | edge_port->lsr_mask = lsr; |
1795 | } else { | 1674 | } else { |
1796 | dbg ("%s - ===== Port %d LSR Status = %02x ======", | 1675 | dbg("%s - ===== Port %d LSR Status = %02x ======", |
1797 | __func__, port_number, lsr); | 1676 | __func__, port_number, lsr); |
1798 | handle_new_lsr (edge_port, 0, lsr, 0); | 1677 | handle_new_lsr(edge_port, 0, lsr, 0); |
1799 | } | 1678 | } |
1800 | break; | 1679 | break; |
1801 | 1680 | ||
1802 | case TIUMP_INTERRUPT_CODE_MSR: // MSR | 1681 | case TIUMP_INTERRUPT_CODE_MSR: /* MSR */ |
1803 | /* Copy MSR from UMP */ | 1682 | /* Copy MSR from UMP */ |
1804 | msr = data[1]; | 1683 | msr = data[1]; |
1805 | dbg ("%s - ===== Port %u MSR Status = %02x ======\n", | 1684 | dbg("%s - ===== Port %u MSR Status = %02x ======\n", |
1806 | __func__, port_number, msr); | 1685 | __func__, port_number, msr); |
1807 | handle_new_msr (edge_port, msr); | 1686 | handle_new_msr(edge_port, msr); |
1808 | break; | 1687 | break; |
1809 | 1688 | ||
1810 | default: | 1689 | default: |
1811 | dev_err (&urb->dev->dev, "%s - Unknown Interrupt code from UMP %x\n", | 1690 | dev_err(&urb->dev->dev, |
1812 | __func__, data[1]); | 1691 | "%s - Unknown Interrupt code from UMP %x\n", |
1692 | __func__, data[1]); | ||
1813 | break; | 1693 | break; |
1814 | 1694 | ||
1815 | } | 1695 | } |
1816 | 1696 | ||
1817 | exit: | 1697 | exit: |
1818 | retval = usb_submit_urb (urb, GFP_ATOMIC); | 1698 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
1819 | if (retval) | 1699 | if (retval) |
1820 | dev_err (&urb->dev->dev, "%s - usb_submit_urb failed with result %d\n", | 1700 | dev_err(&urb->dev->dev, |
1701 | "%s - usb_submit_urb failed with result %d\n", | ||
1821 | __func__, retval); | 1702 | __func__, retval); |
1822 | } | 1703 | } |
1823 | 1704 | ||
1824 | static void edge_bulk_in_callback (struct urb *urb) | 1705 | static void edge_bulk_in_callback(struct urb *urb) |
1825 | { | 1706 | { |
1826 | struct edgeport_port *edge_port = urb->context; | 1707 | struct edgeport_port *edge_port = urb->context; |
1827 | unsigned char *data = urb->transfer_buffer; | 1708 | unsigned char *data = urb->transfer_buffer; |
@@ -1844,15 +1725,16 @@ static void edge_bulk_in_callback (struct urb *urb) | |||
1844 | __func__, status); | 1725 | __func__, status); |
1845 | return; | 1726 | return; |
1846 | default: | 1727 | default: |
1847 | dev_err (&urb->dev->dev,"%s - nonzero read bulk status received: %d\n", | 1728 | dev_err(&urb->dev->dev, |
1848 | __func__, status); | 1729 | "%s - nonzero read bulk status received: %d\n", |
1730 | __func__, status); | ||
1849 | } | 1731 | } |
1850 | 1732 | ||
1851 | if (status == -EPIPE) | 1733 | if (status == -EPIPE) |
1852 | goto exit; | 1734 | goto exit; |
1853 | 1735 | ||
1854 | if (status) { | 1736 | if (status) { |
1855 | dev_err(&urb->dev->dev,"%s - stopping read!\n", __func__); | 1737 | dev_err(&urb->dev->dev, "%s - stopping read!\n", __func__); |
1856 | return; | 1738 | return; |
1857 | } | 1739 | } |
1858 | 1740 | ||
@@ -1860,9 +1742,9 @@ static void edge_bulk_in_callback (struct urb *urb) | |||
1860 | 1742 | ||
1861 | if (edge_port->lsr_event) { | 1743 | if (edge_port->lsr_event) { |
1862 | edge_port->lsr_event = 0; | 1744 | edge_port->lsr_event = 0; |
1863 | dbg ("%s ===== Port %u LSR Status = %02x, Data = %02x ======", | 1745 | dbg("%s ===== Port %u LSR Status = %02x, Data = %02x ======", |
1864 | __func__, port_number, edge_port->lsr_mask, *data); | 1746 | __func__, port_number, edge_port->lsr_mask, *data); |
1865 | handle_new_lsr (edge_port, 1, edge_port->lsr_mask, *data); | 1747 | handle_new_lsr(edge_port, 1, edge_port->lsr_mask, *data); |
1866 | /* Adjust buffer length/pointer */ | 1748 | /* Adjust buffer length/pointer */ |
1867 | --urb->actual_length; | 1749 | --urb->actual_length; |
1868 | ++data; | 1750 | ++data; |
@@ -1870,13 +1752,14 @@ static void edge_bulk_in_callback (struct urb *urb) | |||
1870 | 1752 | ||
1871 | tty = edge_port->port->tty; | 1753 | tty = edge_port->port->tty; |
1872 | if (tty && urb->actual_length) { | 1754 | if (tty && urb->actual_length) { |
1873 | usb_serial_debug_data(debug, &edge_port->port->dev, __func__, urb->actual_length, data); | 1755 | usb_serial_debug_data(debug, &edge_port->port->dev, |
1874 | 1756 | __func__, urb->actual_length, data); | |
1875 | if (edge_port->close_pending) { | 1757 | if (edge_port->close_pending) |
1876 | dbg ("%s - close is pending, dropping data on the floor.", __func__); | 1758 | dbg("%s - close pending, dropping data on the floor", |
1877 | } else { | 1759 | __func__); |
1878 | edge_tty_recv(&edge_port->port->dev, tty, data, urb->actual_length); | 1760 | else |
1879 | } | 1761 | edge_tty_recv(&edge_port->port->dev, tty, data, |
1762 | urb->actual_length); | ||
1880 | edge_port->icount.rx += urb->actual_length; | 1763 | edge_port->icount.rx += urb->actual_length; |
1881 | } | 1764 | } |
1882 | 1765 | ||
@@ -1891,37 +1774,31 @@ exit: | |||
1891 | } | 1774 | } |
1892 | spin_unlock(&edge_port->ep_lock); | 1775 | spin_unlock(&edge_port->ep_lock); |
1893 | if (retval) | 1776 | if (retval) |
1894 | dev_err (&urb->dev->dev, "%s - usb_submit_urb failed with result %d\n", | 1777 | dev_err(&urb->dev->dev, |
1778 | "%s - usb_submit_urb failed with result %d\n", | ||
1895 | __func__, retval); | 1779 | __func__, retval); |
1896 | } | 1780 | } |
1897 | 1781 | ||
1898 | static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned char *data, int length) | 1782 | static void edge_tty_recv(struct device *dev, struct tty_struct *tty, |
1783 | unsigned char *data, int length) | ||
1899 | { | 1784 | { |
1900 | int cnt; | 1785 | int queued; |
1901 | |||
1902 | do { | ||
1903 | cnt = tty_buffer_request_room(tty, length); | ||
1904 | if (cnt < length) { | ||
1905 | dev_err(dev, "%s - dropping data, %d bytes lost\n", | ||
1906 | __func__, length - cnt); | ||
1907 | if(cnt == 0) | ||
1908 | break; | ||
1909 | } | ||
1910 | tty_insert_flip_string(tty, data, cnt); | ||
1911 | data += cnt; | ||
1912 | length -= cnt; | ||
1913 | } while (length > 0); | ||
1914 | 1786 | ||
1787 | tty_buffer_request_room(tty, length); | ||
1788 | queued = tty_insert_flip_string(tty, data, length); | ||
1789 | if (queued < length) | ||
1790 | dev_err(dev, "%s - dropping data, %d bytes lost\n", | ||
1791 | __func__, length - queued); | ||
1915 | tty_flip_buffer_push(tty); | 1792 | tty_flip_buffer_push(tty); |
1916 | } | 1793 | } |
1917 | 1794 | ||
1918 | static void edge_bulk_out_callback (struct urb *urb) | 1795 | static void edge_bulk_out_callback(struct urb *urb) |
1919 | { | 1796 | { |
1920 | struct usb_serial_port *port = urb->context; | 1797 | struct usb_serial_port *port = urb->context; |
1921 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 1798 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
1922 | int status = urb->status; | 1799 | int status = urb->status; |
1923 | 1800 | ||
1924 | dbg ("%s - port %d", __func__, port->number); | 1801 | dbg("%s - port %d", __func__, port->number); |
1925 | 1802 | ||
1926 | edge_port->ep_write_urb_in_use = 0; | 1803 | edge_port->ep_write_urb_in_use = 0; |
1927 | 1804 | ||
@@ -1945,7 +1822,7 @@ static void edge_bulk_out_callback (struct urb *urb) | |||
1945 | edge_send(port); | 1822 | edge_send(port); |
1946 | } | 1823 | } |
1947 | 1824 | ||
1948 | static int edge_open (struct usb_serial_port *port, struct file * filp) | 1825 | static int edge_open(struct usb_serial_port *port, struct file *filp) |
1949 | { | 1826 | { |
1950 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 1827 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
1951 | struct edgeport_serial *edge_serial; | 1828 | struct edgeport_serial *edge_serial; |
@@ -1965,118 +1842,119 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) | |||
1965 | 1842 | ||
1966 | port_number = port->number - port->serial->minor; | 1843 | port_number = port->number - port->serial->minor; |
1967 | switch (port_number) { | 1844 | switch (port_number) { |
1968 | case 0: | 1845 | case 0: |
1969 | edge_port->uart_base = UMPMEM_BASE_UART1; | 1846 | edge_port->uart_base = UMPMEM_BASE_UART1; |
1970 | edge_port->dma_address = UMPD_OEDB1_ADDRESS; | 1847 | edge_port->dma_address = UMPD_OEDB1_ADDRESS; |
1971 | break; | 1848 | break; |
1972 | case 1: | 1849 | case 1: |
1973 | edge_port->uart_base = UMPMEM_BASE_UART2; | 1850 | edge_port->uart_base = UMPMEM_BASE_UART2; |
1974 | edge_port->dma_address = UMPD_OEDB2_ADDRESS; | 1851 | edge_port->dma_address = UMPD_OEDB2_ADDRESS; |
1975 | break; | 1852 | break; |
1976 | default: | 1853 | default: |
1977 | dev_err (&port->dev, "Unknown port number!!!\n"); | 1854 | dev_err(&port->dev, "Unknown port number!!!\n"); |
1978 | return -ENODEV; | 1855 | return -ENODEV; |
1979 | } | 1856 | } |
1980 | 1857 | ||
1981 | dbg ("%s - port_number = %d, uart_base = %04x, dma_address = %04x", | 1858 | dbg("%s - port_number = %d, uart_base = %04x, dma_address = %04x", |
1982 | __func__, port_number, edge_port->uart_base, edge_port->dma_address); | 1859 | __func__, port_number, edge_port->uart_base, |
1860 | edge_port->dma_address); | ||
1983 | 1861 | ||
1984 | dev = port->serial->dev; | 1862 | dev = port->serial->dev; |
1985 | 1863 | ||
1986 | memset (&(edge_port->icount), 0x00, sizeof(edge_port->icount)); | 1864 | memset(&(edge_port->icount), 0x00, sizeof(edge_port->icount)); |
1987 | init_waitqueue_head (&edge_port->delta_msr_wait); | 1865 | init_waitqueue_head(&edge_port->delta_msr_wait); |
1988 | 1866 | ||
1989 | /* turn off loopback */ | 1867 | /* turn off loopback */ |
1990 | status = TIClearLoopBack (edge_port); | 1868 | status = ti_do_config(edge_port, UMPC_SET_CLR_LOOPBACK, 0); |
1991 | if (status) { | 1869 | if (status) { |
1992 | dev_err(&port->dev,"%s - cannot send clear loopback command, %d\n", | 1870 | dev_err(&port->dev, |
1871 | "%s - cannot send clear loopback command, %d\n", | ||
1993 | __func__, status); | 1872 | __func__, status); |
1994 | return status; | 1873 | return status; |
1995 | } | 1874 | } |
1996 | 1875 | ||
1997 | /* set up the port settings */ | 1876 | /* set up the port settings */ |
1998 | edge_set_termios (port, port->tty->termios); | 1877 | edge_set_termios(port, port->tty->termios); |
1999 | 1878 | ||
2000 | /* open up the port */ | 1879 | /* open up the port */ |
2001 | 1880 | ||
2002 | /* milliseconds to timeout for DMA transfer */ | 1881 | /* milliseconds to timeout for DMA transfer */ |
2003 | transaction_timeout = 2; | 1882 | transaction_timeout = 2; |
2004 | 1883 | ||
2005 | edge_port->ump_read_timeout = max (20, ((transaction_timeout * 3) / 2) ); | 1884 | edge_port->ump_read_timeout = |
1885 | max(20, ((transaction_timeout * 3) / 2)); | ||
2006 | 1886 | ||
2007 | // milliseconds to timeout for DMA transfer | 1887 | /* milliseconds to timeout for DMA transfer */ |
2008 | open_settings = (u8)(UMP_DMA_MODE_CONTINOUS | | 1888 | open_settings = (u8)(UMP_DMA_MODE_CONTINOUS | |
2009 | UMP_PIPE_TRANS_TIMEOUT_ENA | | 1889 | UMP_PIPE_TRANS_TIMEOUT_ENA | |
2010 | (transaction_timeout << 2)); | 1890 | (transaction_timeout << 2)); |
2011 | 1891 | ||
2012 | dbg ("%s - Sending UMPC_OPEN_PORT", __func__); | 1892 | dbg("%s - Sending UMPC_OPEN_PORT", __func__); |
2013 | 1893 | ||
2014 | /* Tell TI to open and start the port */ | 1894 | /* Tell TI to open and start the port */ |
2015 | status = TIWriteCommandSync (dev, | 1895 | status = send_cmd(dev, UMPC_OPEN_PORT, |
2016 | UMPC_OPEN_PORT, | 1896 | (u8)(UMPM_UART1_PORT + port_number), open_settings, NULL, 0); |
2017 | (u8)(UMPM_UART1_PORT + port_number), | ||
2018 | open_settings, | ||
2019 | NULL, | ||
2020 | 0); | ||
2021 | if (status) { | 1897 | if (status) { |
2022 | dev_err(&port->dev,"%s - cannot send open command, %d\n", __func__, status); | 1898 | dev_err(&port->dev, "%s - cannot send open command, %d\n", |
1899 | __func__, status); | ||
2023 | return status; | 1900 | return status; |
2024 | } | 1901 | } |
2025 | 1902 | ||
2026 | /* Start the DMA? */ | 1903 | /* Start the DMA? */ |
2027 | status = TIWriteCommandSync (dev, | 1904 | status = send_cmd(dev, UMPC_START_PORT, |
2028 | UMPC_START_PORT, | 1905 | (u8)(UMPM_UART1_PORT + port_number), 0, NULL, 0); |
2029 | (u8)(UMPM_UART1_PORT + port_number), | ||
2030 | 0, | ||
2031 | NULL, | ||
2032 | 0); | ||
2033 | if (status) { | 1906 | if (status) { |
2034 | dev_err(&port->dev,"%s - cannot send start DMA command, %d\n", __func__, status); | 1907 | dev_err(&port->dev, "%s - cannot send start DMA command, %d\n", |
1908 | __func__, status); | ||
2035 | return status; | 1909 | return status; |
2036 | } | 1910 | } |
2037 | 1911 | ||
2038 | /* Clear TX and RX buffers in UMP */ | 1912 | /* Clear TX and RX buffers in UMP */ |
2039 | status = TIPurgeDataSync (port, UMP_PORT_DIR_OUT | UMP_PORT_DIR_IN); | 1913 | status = purge_port(port, UMP_PORT_DIR_OUT | UMP_PORT_DIR_IN); |
2040 | if (status) { | 1914 | if (status) { |
2041 | dev_err(&port->dev,"%s - cannot send clear buffers command, %d\n", __func__, status); | 1915 | dev_err(&port->dev, |
1916 | "%s - cannot send clear buffers command, %d\n", | ||
1917 | __func__, status); | ||
2042 | return status; | 1918 | return status; |
2043 | } | 1919 | } |
2044 | 1920 | ||
2045 | /* Read Initial MSR */ | 1921 | /* Read Initial MSR */ |
2046 | status = TIReadVendorRequestSync (dev, | 1922 | status = ti_vread_sync(dev, UMPC_READ_MSR, 0, |
2047 | UMPC_READ_MSR, // Request | 1923 | (__u16)(UMPM_UART1_PORT + port_number), |
2048 | 0, // wValue | 1924 | &edge_port->shadow_msr, 1); |
2049 | (__u16)(UMPM_UART1_PORT + port_number), // wIndex (Address) | ||
2050 | &edge_port->shadow_msr, // TransferBuffer | ||
2051 | 1); // TransferBufferLength | ||
2052 | if (status) { | 1925 | if (status) { |
2053 | dev_err(&port->dev,"%s - cannot send read MSR command, %d\n", __func__, status); | 1926 | dev_err(&port->dev, "%s - cannot send read MSR command, %d\n", |
1927 | __func__, status); | ||
2054 | return status; | 1928 | return status; |
2055 | } | 1929 | } |
2056 | 1930 | ||
2057 | dbg ("ShadowMSR 0x%X", edge_port->shadow_msr); | 1931 | dbg("ShadowMSR 0x%X", edge_port->shadow_msr); |
2058 | 1932 | ||
2059 | /* Set Initial MCR */ | 1933 | /* Set Initial MCR */ |
2060 | edge_port->shadow_mcr = MCR_RTS | MCR_DTR; | 1934 | edge_port->shadow_mcr = MCR_RTS | MCR_DTR; |
2061 | dbg ("ShadowMCR 0x%X", edge_port->shadow_mcr); | 1935 | dbg("ShadowMCR 0x%X", edge_port->shadow_mcr); |
2062 | 1936 | ||
2063 | edge_serial = edge_port->edge_serial; | 1937 | edge_serial = edge_port->edge_serial; |
2064 | if (mutex_lock_interruptible(&edge_serial->es_lock)) | 1938 | if (mutex_lock_interruptible(&edge_serial->es_lock)) |
2065 | return -ERESTARTSYS; | 1939 | return -ERESTARTSYS; |
2066 | if (edge_serial->num_ports_open == 0) { | 1940 | if (edge_serial->num_ports_open == 0) { |
2067 | /* we are the first port to be opened, let's post the interrupt urb */ | 1941 | /* we are the first port to open, post the interrupt urb */ |
2068 | urb = edge_serial->serial->port[0]->interrupt_in_urb; | 1942 | urb = edge_serial->serial->port[0]->interrupt_in_urb; |
2069 | if (!urb) { | 1943 | if (!urb) { |
2070 | dev_err (&port->dev, "%s - no interrupt urb present, exiting\n", __func__); | 1944 | dev_err(&port->dev, |
1945 | "%s - no interrupt urb present, exiting\n", | ||
1946 | __func__); | ||
2071 | status = -EINVAL; | 1947 | status = -EINVAL; |
2072 | goto release_es_lock; | 1948 | goto release_es_lock; |
2073 | } | 1949 | } |
2074 | urb->complete = edge_interrupt_callback; | 1950 | urb->complete = edge_interrupt_callback; |
2075 | urb->context = edge_serial; | 1951 | urb->context = edge_serial; |
2076 | urb->dev = dev; | 1952 | urb->dev = dev; |
2077 | status = usb_submit_urb (urb, GFP_KERNEL); | 1953 | status = usb_submit_urb(urb, GFP_KERNEL); |
2078 | if (status) { | 1954 | if (status) { |
2079 | dev_err (&port->dev, "%s - usb_submit_urb failed with value %d\n", __func__, status); | 1955 | dev_err(&port->dev, |
1956 | "%s - usb_submit_urb failed with value %d\n", | ||
1957 | __func__, status); | ||
2080 | goto release_es_lock; | 1958 | goto release_es_lock; |
2081 | } | 1959 | } |
2082 | } | 1960 | } |
@@ -2085,13 +1963,14 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) | |||
2085 | * reset the data toggle on the bulk endpoints to work around bug in | 1963 | * reset the data toggle on the bulk endpoints to work around bug in |
2086 | * host controllers where things get out of sync some times | 1964 | * host controllers where things get out of sync some times |
2087 | */ | 1965 | */ |
2088 | usb_clear_halt (dev, port->write_urb->pipe); | 1966 | usb_clear_halt(dev, port->write_urb->pipe); |
2089 | usb_clear_halt (dev, port->read_urb->pipe); | 1967 | usb_clear_halt(dev, port->read_urb->pipe); |
2090 | 1968 | ||
2091 | /* start up our bulk read urb */ | 1969 | /* start up our bulk read urb */ |
2092 | urb = port->read_urb; | 1970 | urb = port->read_urb; |
2093 | if (!urb) { | 1971 | if (!urb) { |
2094 | dev_err (&port->dev, "%s - no read urb present, exiting\n", __func__); | 1972 | dev_err(&port->dev, "%s - no read urb present, exiting\n", |
1973 | __func__); | ||
2095 | status = -EINVAL; | 1974 | status = -EINVAL; |
2096 | goto unlink_int_urb; | 1975 | goto unlink_int_urb; |
2097 | } | 1976 | } |
@@ -2099,9 +1978,11 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) | |||
2099 | urb->complete = edge_bulk_in_callback; | 1978 | urb->complete = edge_bulk_in_callback; |
2100 | urb->context = edge_port; | 1979 | urb->context = edge_port; |
2101 | urb->dev = dev; | 1980 | urb->dev = dev; |
2102 | status = usb_submit_urb (urb, GFP_KERNEL); | 1981 | status = usb_submit_urb(urb, GFP_KERNEL); |
2103 | if (status) { | 1982 | if (status) { |
2104 | dev_err (&port->dev, "%s - read bulk usb_submit_urb failed with value %d\n", __func__, status); | 1983 | dev_err(&port->dev, |
1984 | "%s - read bulk usb_submit_urb failed with value %d\n", | ||
1985 | __func__, status); | ||
2105 | goto unlink_int_urb; | 1986 | goto unlink_int_urb; |
2106 | } | 1987 | } |
2107 | 1988 | ||
@@ -2119,7 +2000,7 @@ release_es_lock: | |||
2119 | return status; | 2000 | return status; |
2120 | } | 2001 | } |
2121 | 2002 | ||
2122 | static void edge_close (struct usb_serial_port *port, struct file *filp) | 2003 | static void edge_close(struct usb_serial_port *port, struct file *filp) |
2123 | { | 2004 | { |
2124 | struct edgeport_serial *edge_serial; | 2005 | struct edgeport_serial *edge_serial; |
2125 | struct edgeport_port *edge_port; | 2006 | struct edgeport_port *edge_port; |
@@ -2127,18 +2008,18 @@ static void edge_close (struct usb_serial_port *port, struct file *filp) | |||
2127 | int status; | 2008 | int status; |
2128 | 2009 | ||
2129 | dbg("%s - port %d", __func__, port->number); | 2010 | dbg("%s - port %d", __func__, port->number); |
2130 | 2011 | ||
2131 | edge_serial = usb_get_serial_data(port->serial); | 2012 | edge_serial = usb_get_serial_data(port->serial); |
2132 | edge_port = usb_get_serial_port_data(port); | 2013 | edge_port = usb_get_serial_port_data(port); |
2133 | if ((edge_serial == NULL) || (edge_port == NULL)) | 2014 | if (edge_serial == NULL || edge_port == NULL) |
2134 | return; | 2015 | return; |
2135 | 2016 | ||
2136 | /* The bulkreadcompletion routine will check | 2017 | /* The bulkreadcompletion routine will check |
2137 | * this flag and dump add read data */ | 2018 | * this flag and dump add read data */ |
2138 | edge_port->close_pending = 1; | 2019 | edge_port->close_pending = 1; |
2139 | 2020 | ||
2140 | /* chase the port close and flush */ | 2021 | /* chase the port close and flush */ |
2141 | TIChasePort (edge_port, (HZ*closing_wait)/100, 1); | 2022 | chase_port(edge_port, (HZ * closing_wait) / 100, 1); |
2142 | 2023 | ||
2143 | usb_kill_urb(port->read_urb); | 2024 | usb_kill_urb(port->read_urb); |
2144 | usb_kill_urb(port->write_urb); | 2025 | usb_kill_urb(port->write_urb); |
@@ -2148,7 +2029,7 @@ static void edge_close (struct usb_serial_port *port, struct file *filp) | |||
2148 | * send a close port command to it */ | 2029 | * send a close port command to it */ |
2149 | dbg("%s - send umpc_close_port", __func__); | 2030 | dbg("%s - send umpc_close_port", __func__); |
2150 | port_number = port->number - port->serial->minor; | 2031 | port_number = port->number - port->serial->minor; |
2151 | status = TIWriteCommandSync (port->serial->dev, | 2032 | status = send_cmd(port->serial->dev, |
2152 | UMPC_CLOSE_PORT, | 2033 | UMPC_CLOSE_PORT, |
2153 | (__u8)(UMPM_UART1_PORT + port_number), | 2034 | (__u8)(UMPM_UART1_PORT + port_number), |
2154 | 0, | 2035 | 0, |
@@ -2167,7 +2048,8 @@ static void edge_close (struct usb_serial_port *port, struct file *filp) | |||
2167 | dbg("%s - exited", __func__); | 2048 | dbg("%s - exited", __func__); |
2168 | } | 2049 | } |
2169 | 2050 | ||
2170 | static int edge_write (struct usb_serial_port *port, const unsigned char *data, int count) | 2051 | static int edge_write(struct usb_serial_port *port, const unsigned char *data, |
2052 | int count) | ||
2171 | { | 2053 | { |
2172 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 2054 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
2173 | unsigned long flags; | 2055 | unsigned long flags; |
@@ -2223,11 +2105,12 @@ static void edge_send(struct usb_serial_port *port) | |||
2223 | 2105 | ||
2224 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); | 2106 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); |
2225 | 2107 | ||
2226 | usb_serial_debug_data(debug, &port->dev, __func__, count, port->write_urb->transfer_buffer); | 2108 | usb_serial_debug_data(debug, &port->dev, __func__, count, |
2109 | port->write_urb->transfer_buffer); | ||
2227 | 2110 | ||
2228 | /* set up our urb */ | 2111 | /* set up our urb */ |
2229 | usb_fill_bulk_urb (port->write_urb, port->serial->dev, | 2112 | usb_fill_bulk_urb(port->write_urb, port->serial->dev, |
2230 | usb_sndbulkpipe (port->serial->dev, | 2113 | usb_sndbulkpipe(port->serial->dev, |
2231 | port->bulk_out_endpointAddress), | 2114 | port->bulk_out_endpointAddress), |
2232 | port->write_urb->transfer_buffer, count, | 2115 | port->write_urb->transfer_buffer, count, |
2233 | edge_bulk_out_callback, | 2116 | edge_bulk_out_callback, |
@@ -2236,22 +2119,21 @@ static void edge_send(struct usb_serial_port *port) | |||
2236 | /* send the data out the bulk port */ | 2119 | /* send the data out the bulk port */ |
2237 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 2120 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
2238 | if (result) { | 2121 | if (result) { |
2239 | dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, result); | 2122 | dev_err(&port->dev, |
2123 | "%s - failed submitting write urb, error %d\n", | ||
2124 | __func__, result); | ||
2240 | edge_port->ep_write_urb_in_use = 0; | 2125 | edge_port->ep_write_urb_in_use = 0; |
2241 | // TODO: reschedule edge_send | 2126 | /* TODO: reschedule edge_send */ |
2242 | } else { | 2127 | } else |
2243 | edge_port->icount.tx += count; | 2128 | edge_port->icount.tx += count; |
2244 | } | ||
2245 | 2129 | ||
2246 | /* wakeup any process waiting for writes to complete */ | 2130 | /* wakeup any process waiting for writes to complete */ |
2247 | /* there is now more room in the buffer for new writes */ | 2131 | /* there is now more room in the buffer for new writes */ |
2248 | if (tty) { | 2132 | if (tty) |
2249 | /* let the tty driver wakeup if it has a special write_wakeup function */ | ||
2250 | tty_wakeup(tty); | 2133 | tty_wakeup(tty); |
2251 | } | ||
2252 | } | 2134 | } |
2253 | 2135 | ||
2254 | static int edge_write_room (struct usb_serial_port *port) | 2136 | static int edge_write_room(struct usb_serial_port *port) |
2255 | { | 2137 | { |
2256 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 2138 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
2257 | int room = 0; | 2139 | int room = 0; |
@@ -2260,9 +2142,9 @@ static int edge_write_room (struct usb_serial_port *port) | |||
2260 | dbg("%s - port %d", __func__, port->number); | 2142 | dbg("%s - port %d", __func__, port->number); |
2261 | 2143 | ||
2262 | if (edge_port == NULL) | 2144 | if (edge_port == NULL) |
2263 | return -ENODEV; | 2145 | return 0; |
2264 | if (edge_port->close_pending == 1) | 2146 | if (edge_port->close_pending == 1) |
2265 | return -ENODEV; | 2147 | return 0; |
2266 | 2148 | ||
2267 | spin_lock_irqsave(&edge_port->ep_lock, flags); | 2149 | spin_lock_irqsave(&edge_port->ep_lock, flags); |
2268 | room = edge_buf_space_avail(edge_port->ep_out_buf); | 2150 | room = edge_buf_space_avail(edge_port->ep_out_buf); |
@@ -2272,7 +2154,7 @@ static int edge_write_room (struct usb_serial_port *port) | |||
2272 | return room; | 2154 | return room; |
2273 | } | 2155 | } |
2274 | 2156 | ||
2275 | static int edge_chars_in_buffer (struct usb_serial_port *port) | 2157 | static int edge_chars_in_buffer(struct usb_serial_port *port) |
2276 | { | 2158 | { |
2277 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 2159 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
2278 | int chars = 0; | 2160 | int chars = 0; |
@@ -2281,22 +2163,22 @@ static int edge_chars_in_buffer (struct usb_serial_port *port) | |||
2281 | dbg("%s - port %d", __func__, port->number); | 2163 | dbg("%s - port %d", __func__, port->number); |
2282 | 2164 | ||
2283 | if (edge_port == NULL) | 2165 | if (edge_port == NULL) |
2284 | return -ENODEV; | 2166 | return 0; |
2285 | if (edge_port->close_pending == 1) | 2167 | if (edge_port->close_pending == 1) |
2286 | return -ENODEV; | 2168 | return 0; |
2287 | 2169 | ||
2288 | spin_lock_irqsave(&edge_port->ep_lock, flags); | 2170 | spin_lock_irqsave(&edge_port->ep_lock, flags); |
2289 | chars = edge_buf_data_avail(edge_port->ep_out_buf); | 2171 | chars = edge_buf_data_avail(edge_port->ep_out_buf); |
2290 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); | 2172 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); |
2291 | 2173 | ||
2292 | dbg ("%s - returns %d", __func__, chars); | 2174 | dbg("%s - returns %d", __func__, chars); |
2293 | return chars; | 2175 | return chars; |
2294 | } | 2176 | } |
2295 | 2177 | ||
2296 | static void edge_throttle (struct usb_serial_port *port) | 2178 | static void edge_throttle(struct usb_serial_port *port) |
2297 | { | 2179 | { |
2298 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 2180 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
2299 | struct tty_struct *tty; | 2181 | struct tty_struct *tty = port->tty; |
2300 | int status; | 2182 | int status; |
2301 | 2183 | ||
2302 | dbg("%s - port %d", __func__, port->number); | 2184 | dbg("%s - port %d", __func__, port->number); |
@@ -2304,19 +2186,14 @@ static void edge_throttle (struct usb_serial_port *port) | |||
2304 | if (edge_port == NULL) | 2186 | if (edge_port == NULL) |
2305 | return; | 2187 | return; |
2306 | 2188 | ||
2307 | tty = port->tty; | ||
2308 | if (!tty) { | ||
2309 | dbg ("%s - no tty available", __func__); | ||
2310 | return; | ||
2311 | } | ||
2312 | |||
2313 | /* if we are implementing XON/XOFF, send the stop character */ | 2189 | /* if we are implementing XON/XOFF, send the stop character */ |
2314 | if (I_IXOFF(tty)) { | 2190 | if (I_IXOFF(tty)) { |
2315 | unsigned char stop_char = STOP_CHAR(tty); | 2191 | unsigned char stop_char = STOP_CHAR(tty); |
2316 | status = edge_write (port, &stop_char, 1); | 2192 | status = edge_write(port, &stop_char, 1); |
2317 | if (status <= 0) { | 2193 | if (status <= 0) |
2318 | dev_err(&port->dev, "%s - failed to write stop character, %d\n", __func__, status); | 2194 | dev_err(&port->dev, |
2319 | } | 2195 | "%s - failed to write stop character, %d\n", |
2196 | __func__, status); | ||
2320 | } | 2197 | } |
2321 | 2198 | ||
2322 | /* if we are implementing RTS/CTS, stop reads */ | 2199 | /* if we are implementing RTS/CTS, stop reads */ |
@@ -2326,10 +2203,10 @@ static void edge_throttle (struct usb_serial_port *port) | |||
2326 | 2203 | ||
2327 | } | 2204 | } |
2328 | 2205 | ||
2329 | static void edge_unthrottle (struct usb_serial_port *port) | 2206 | static void edge_unthrottle(struct usb_serial_port *port) |
2330 | { | 2207 | { |
2331 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 2208 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
2332 | struct tty_struct *tty; | 2209 | struct tty_struct *tty = port->tty; |
2333 | int status; | 2210 | int status; |
2334 | 2211 | ||
2335 | dbg("%s - port %d", __func__, port->number); | 2212 | dbg("%s - port %d", __func__, port->number); |
@@ -2337,27 +2214,23 @@ static void edge_unthrottle (struct usb_serial_port *port) | |||
2337 | if (edge_port == NULL) | 2214 | if (edge_port == NULL) |
2338 | return; | 2215 | return; |
2339 | 2216 | ||
2340 | tty = port->tty; | ||
2341 | if (!tty) { | ||
2342 | dbg ("%s - no tty available", __func__); | ||
2343 | return; | ||
2344 | } | ||
2345 | |||
2346 | /* if we are implementing XON/XOFF, send the start character */ | 2217 | /* if we are implementing XON/XOFF, send the start character */ |
2347 | if (I_IXOFF(tty)) { | 2218 | if (I_IXOFF(tty)) { |
2348 | unsigned char start_char = START_CHAR(tty); | 2219 | unsigned char start_char = START_CHAR(tty); |
2349 | status = edge_write (port, &start_char, 1); | 2220 | status = edge_write(port, &start_char, 1); |
2350 | if (status <= 0) { | 2221 | if (status <= 0) |
2351 | dev_err(&port->dev, "%s - failed to write start character, %d\n", __func__, status); | 2222 | dev_err(&port->dev, |
2352 | } | 2223 | "%s - failed to write start character, %d\n", |
2224 | __func__, status); | ||
2353 | } | 2225 | } |
2354 | |||
2355 | /* if we are implementing RTS/CTS, restart reads */ | 2226 | /* if we are implementing RTS/CTS, restart reads */ |
2356 | /* are the Edgeport will assert the RTS line */ | 2227 | /* are the Edgeport will assert the RTS line */ |
2357 | if (C_CRTSCTS(tty)) { | 2228 | if (C_CRTSCTS(tty)) { |
2358 | status = restart_read(edge_port); | 2229 | status = restart_read(edge_port); |
2359 | if (status) | 2230 | if (status) |
2360 | dev_err(&port->dev, "%s - read bulk usb_submit_urb failed with value %d\n", __func__, status); | 2231 | dev_err(&port->dev, |
2232 | "%s - read bulk usb_submit_urb failed: %d\n", | ||
2233 | __func__, status); | ||
2361 | } | 2234 | } |
2362 | 2235 | ||
2363 | } | 2236 | } |
@@ -2398,22 +2271,26 @@ static int restart_read(struct edgeport_port *edge_port) | |||
2398 | return status; | 2271 | return status; |
2399 | } | 2272 | } |
2400 | 2273 | ||
2401 | static void change_port_settings (struct edgeport_port *edge_port, struct ktermios *old_termios) | 2274 | static void change_port_settings(struct edgeport_port *edge_port, |
2275 | struct ktermios *old_termios) | ||
2402 | { | 2276 | { |
2403 | struct ump_uart_config *config; | 2277 | struct ump_uart_config *config; |
2404 | struct tty_struct *tty; | 2278 | struct tty_struct *tty; |
2405 | int baud; | 2279 | int baud; |
2406 | unsigned cflag; | 2280 | unsigned cflag; |
2407 | int status; | 2281 | int status; |
2408 | int port_number = edge_port->port->number - edge_port->port->serial->minor; | 2282 | int port_number = edge_port->port->number - |
2283 | edge_port->port->serial->minor; | ||
2409 | 2284 | ||
2410 | dbg("%s - port %d", __func__, edge_port->port->number); | 2285 | dbg("%s - port %d", __func__, edge_port->port->number); |
2411 | 2286 | ||
2412 | tty = edge_port->port->tty; | 2287 | tty = edge_port->port->tty; |
2413 | 2288 | ||
2414 | config = kmalloc (sizeof (*config), GFP_KERNEL); | 2289 | config = kmalloc(sizeof(*config), GFP_KERNEL); |
2415 | if (!config) { | 2290 | if (!config) { |
2416 | dev_err (&edge_port->port->dev, "%s - out of memory\n", __func__); | 2291 | *tty->termios = *old_termios; |
2292 | dev_err(&edge_port->port->dev, "%s - out of memory\n", | ||
2293 | __func__); | ||
2417 | return; | 2294 | return; |
2418 | } | 2295 | } |
2419 | 2296 | ||
@@ -2427,22 +2304,22 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi | |||
2427 | config->bUartMode = (__u8)(edge_port->bUartMode); | 2304 | config->bUartMode = (__u8)(edge_port->bUartMode); |
2428 | 2305 | ||
2429 | switch (cflag & CSIZE) { | 2306 | switch (cflag & CSIZE) { |
2430 | case CS5: | 2307 | case CS5: |
2431 | config->bDataBits = UMP_UART_CHAR5BITS; | 2308 | config->bDataBits = UMP_UART_CHAR5BITS; |
2432 | dbg ("%s - data bits = 5", __func__); | 2309 | dbg("%s - data bits = 5", __func__); |
2433 | break; | 2310 | break; |
2434 | case CS6: | 2311 | case CS6: |
2435 | config->bDataBits = UMP_UART_CHAR6BITS; | 2312 | config->bDataBits = UMP_UART_CHAR6BITS; |
2436 | dbg ("%s - data bits = 6", __func__); | 2313 | dbg("%s - data bits = 6", __func__); |
2437 | break; | 2314 | break; |
2438 | case CS7: | 2315 | case CS7: |
2439 | config->bDataBits = UMP_UART_CHAR7BITS; | 2316 | config->bDataBits = UMP_UART_CHAR7BITS; |
2440 | dbg ("%s - data bits = 7", __func__); | 2317 | dbg("%s - data bits = 7", __func__); |
2441 | break; | 2318 | break; |
2442 | default: | 2319 | default: |
2443 | case CS8: | 2320 | case CS8: |
2444 | config->bDataBits = UMP_UART_CHAR8BITS; | 2321 | config->bDataBits = UMP_UART_CHAR8BITS; |
2445 | dbg ("%s - data bits = 8", __func__); | 2322 | dbg("%s - data bits = 8", __func__); |
2446 | break; | 2323 | break; |
2447 | } | 2324 | } |
2448 | 2325 | ||
@@ -2457,7 +2334,7 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi | |||
2457 | dbg("%s - parity = even", __func__); | 2334 | dbg("%s - parity = even", __func__); |
2458 | } | 2335 | } |
2459 | } else { | 2336 | } else { |
2460 | config->bParity = UMP_UART_NOPARITY; | 2337 | config->bParity = UMP_UART_NOPARITY; |
2461 | dbg("%s - parity = none", __func__); | 2338 | dbg("%s - parity = none", __func__); |
2462 | } | 2339 | } |
2463 | 2340 | ||
@@ -2480,29 +2357,26 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi | |||
2480 | restart_read(edge_port); | 2357 | restart_read(edge_port); |
2481 | } | 2358 | } |
2482 | 2359 | ||
2483 | /* if we are implementing XON/XOFF, set the start and stop character in the device */ | 2360 | /* if we are implementing XON/XOFF, set the start and stop |
2484 | if (I_IXOFF(tty) || I_IXON(tty)) { | 2361 | character in the device */ |
2485 | config->cXon = START_CHAR(tty); | 2362 | config->cXon = START_CHAR(tty); |
2486 | config->cXoff = STOP_CHAR(tty); | 2363 | config->cXoff = STOP_CHAR(tty); |
2487 | 2364 | ||
2488 | /* if we are implementing INBOUND XON/XOFF */ | 2365 | /* if we are implementing INBOUND XON/XOFF */ |
2489 | if (I_IXOFF(tty)) { | 2366 | if (I_IXOFF(tty)) { |
2490 | config->wFlags |= UMP_MASK_UART_FLAGS_IN_X; | 2367 | config->wFlags |= UMP_MASK_UART_FLAGS_IN_X; |
2491 | dbg ("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", | 2368 | dbg("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", |
2492 | __func__, config->cXon, config->cXoff); | 2369 | __func__, config->cXon, config->cXoff); |
2493 | } else { | 2370 | } else |
2494 | dbg ("%s - INBOUND XON/XOFF is disabled", __func__); | 2371 | dbg("%s - INBOUND XON/XOFF is disabled", __func__); |
2495 | } | ||
2496 | 2372 | ||
2497 | /* if we are implementing OUTBOUND XON/XOFF */ | 2373 | /* if we are implementing OUTBOUND XON/XOFF */ |
2498 | if (I_IXON(tty)) { | 2374 | if (I_IXON(tty)) { |
2499 | config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X; | 2375 | config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X; |
2500 | dbg ("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", | 2376 | dbg("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", |
2501 | __func__, config->cXon, config->cXoff); | 2377 | __func__, config->cXon, config->cXoff); |
2502 | } else { | 2378 | } else |
2503 | dbg ("%s - OUTBOUND XON/XOFF is disabled", __func__); | 2379 | dbg("%s - OUTBOUND XON/XOFF is disabled", __func__); |
2504 | } | ||
2505 | } | ||
2506 | 2380 | ||
2507 | tty->termios->c_cflag &= ~CMSPAR; | 2381 | tty->termios->c_cflag &= ~CMSPAR; |
2508 | 2382 | ||
@@ -2519,62 +2393,52 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi | |||
2519 | 2393 | ||
2520 | /* FIXME: Recompute actual baud from divisor here */ | 2394 | /* FIXME: Recompute actual baud from divisor here */ |
2521 | 2395 | ||
2522 | dbg ("%s - baud rate = %d, wBaudRate = %d", __func__, baud, config->wBaudRate); | 2396 | dbg("%s - baud rate = %d, wBaudRate = %d", __func__, baud, |
2397 | config->wBaudRate); | ||
2523 | 2398 | ||
2524 | dbg ("wBaudRate: %d", (int)(461550L / config->wBaudRate)); | 2399 | dbg("wBaudRate: %d", (int)(461550L / config->wBaudRate)); |
2525 | dbg ("wFlags: 0x%x", config->wFlags); | 2400 | dbg("wFlags: 0x%x", config->wFlags); |
2526 | dbg ("bDataBits: %d", config->bDataBits); | 2401 | dbg("bDataBits: %d", config->bDataBits); |
2527 | dbg ("bParity: %d", config->bParity); | 2402 | dbg("bParity: %d", config->bParity); |
2528 | dbg ("bStopBits: %d", config->bStopBits); | 2403 | dbg("bStopBits: %d", config->bStopBits); |
2529 | dbg ("cXon: %d", config->cXon); | 2404 | dbg("cXon: %d", config->cXon); |
2530 | dbg ("cXoff: %d", config->cXoff); | 2405 | dbg("cXoff: %d", config->cXoff); |
2531 | dbg ("bUartMode: %d", config->bUartMode); | 2406 | dbg("bUartMode: %d", config->bUartMode); |
2532 | 2407 | ||
2533 | /* move the word values into big endian mode */ | 2408 | /* move the word values into big endian mode */ |
2534 | cpu_to_be16s (&config->wFlags); | 2409 | cpu_to_be16s(&config->wFlags); |
2535 | cpu_to_be16s (&config->wBaudRate); | 2410 | cpu_to_be16s(&config->wBaudRate); |
2536 | 2411 | ||
2537 | status = TIWriteCommandSync (edge_port->port->serial->dev, | 2412 | status = send_cmd(edge_port->port->serial->dev, UMPC_SET_CONFIG, |
2538 | UMPC_SET_CONFIG, | ||
2539 | (__u8)(UMPM_UART1_PORT + port_number), | 2413 | (__u8)(UMPM_UART1_PORT + port_number), |
2540 | 0, | 2414 | 0, (__u8 *)config, sizeof(*config)); |
2541 | (__u8 *)config, | 2415 | if (status) |
2542 | sizeof(*config)); | 2416 | dbg("%s - error %d when trying to write config to device", |
2543 | if (status) { | ||
2544 | dbg ("%s - error %d when trying to write config to device", | ||
2545 | __func__, status); | 2417 | __func__, status); |
2546 | } | 2418 | kfree(config); |
2547 | |||
2548 | kfree (config); | ||
2549 | |||
2550 | return; | 2419 | return; |
2551 | } | 2420 | } |
2552 | 2421 | ||
2553 | static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) | 2422 | static void edge_set_termios(struct usb_serial_port *port, |
2423 | struct ktermios *old_termios) | ||
2554 | { | 2424 | { |
2555 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 2425 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
2556 | struct tty_struct *tty = port->tty; | 2426 | struct tty_struct *tty = port->tty; |
2557 | unsigned int cflag; | ||
2558 | |||
2559 | cflag = tty->termios->c_cflag; | ||
2560 | 2427 | ||
2561 | dbg("%s - clfag %08x iflag %08x", __func__, | 2428 | dbg("%s - clfag %08x iflag %08x", __func__, |
2562 | tty->termios->c_cflag, tty->termios->c_iflag); | 2429 | tty->termios->c_cflag, tty->termios->c_iflag); |
2563 | dbg("%s - old clfag %08x old iflag %08x", __func__, | 2430 | dbg("%s - old clfag %08x old iflag %08x", __func__, |
2564 | old_termios->c_cflag, old_termios->c_iflag); | 2431 | old_termios->c_cflag, old_termios->c_iflag); |
2565 | |||
2566 | dbg("%s - port %d", __func__, port->number); | 2432 | dbg("%s - port %d", __func__, port->number); |
2567 | 2433 | ||
2568 | if (edge_port == NULL) | 2434 | if (edge_port == NULL) |
2569 | return; | 2435 | return; |
2570 | |||
2571 | /* change the port settings to the new ones specified */ | 2436 | /* change the port settings to the new ones specified */ |
2572 | change_port_settings (edge_port, old_termios); | 2437 | change_port_settings(edge_port, old_termios); |
2573 | |||
2574 | return; | ||
2575 | } | 2438 | } |
2576 | 2439 | ||
2577 | static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear) | 2440 | static int edge_tiocmset(struct usb_serial_port *port, struct file *file, |
2441 | unsigned int set, unsigned int clear) | ||
2578 | { | 2442 | { |
2579 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 2443 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
2580 | unsigned int mcr; | 2444 | unsigned int mcr; |
@@ -2601,8 +2465,7 @@ static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsig | |||
2601 | edge_port->shadow_mcr = mcr; | 2465 | edge_port->shadow_mcr = mcr; |
2602 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); | 2466 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); |
2603 | 2467 | ||
2604 | TIRestoreMCR (edge_port, mcr); | 2468 | restore_mcr(edge_port, mcr); |
2605 | |||
2606 | return 0; | 2469 | return 0; |
2607 | } | 2470 | } |
2608 | 2471 | ||
@@ -2634,7 +2497,8 @@ static int edge_tiocmget(struct usb_serial_port *port, struct file *file) | |||
2634 | return result; | 2497 | return result; |
2635 | } | 2498 | } |
2636 | 2499 | ||
2637 | static int get_serial_info (struct edgeport_port *edge_port, struct serial_struct __user *retinfo) | 2500 | static int get_serial_info(struct edgeport_port *edge_port, |
2501 | struct serial_struct __user *retinfo) | ||
2638 | { | 2502 | { |
2639 | struct serial_struct tmp; | 2503 | struct serial_struct tmp; |
2640 | 2504 | ||
@@ -2652,17 +2516,14 @@ static int get_serial_info (struct edgeport_port *edge_port, struct serial_struc | |||
2652 | tmp.baud_base = 9600; | 2516 | tmp.baud_base = 9600; |
2653 | tmp.close_delay = 5*HZ; | 2517 | tmp.close_delay = 5*HZ; |
2654 | tmp.closing_wait = closing_wait; | 2518 | tmp.closing_wait = closing_wait; |
2655 | // tmp.custom_divisor = state->custom_divisor; | ||
2656 | // tmp.hub6 = state->hub6; | ||
2657 | // tmp.io_type = state->io_type; | ||
2658 | |||
2659 | 2519 | ||
2660 | if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) | 2520 | if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) |
2661 | return -EFAULT; | 2521 | return -EFAULT; |
2662 | return 0; | 2522 | return 0; |
2663 | } | 2523 | } |
2664 | 2524 | ||
2665 | static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg) | 2525 | static int edge_ioctl(struct usb_serial_port *port, struct file *file, |
2526 | unsigned int cmd, unsigned long arg) | ||
2666 | { | 2527 | { |
2667 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 2528 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
2668 | struct async_icount cnow; | 2529 | struct async_icount cnow; |
@@ -2671,81 +2532,63 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned | |||
2671 | dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); | 2532 | dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); |
2672 | 2533 | ||
2673 | switch (cmd) { | 2534 | switch (cmd) { |
2674 | case TIOCINQ: | 2535 | case TIOCGSERIAL: |
2675 | dbg("%s - (%d) TIOCINQ", __func__, port->number); | 2536 | dbg("%s - (%d) TIOCGSERIAL", __func__, port->number); |
2676 | // return get_number_bytes_avail(edge_port, (unsigned int *) arg); | 2537 | return get_serial_info(edge_port, |
2677 | break; | 2538 | (struct serial_struct __user *) arg); |
2678 | 2539 | case TIOCMIWAIT: | |
2679 | case TIOCSERGETLSR: | 2540 | dbg("%s - (%d) TIOCMIWAIT", __func__, port->number); |
2680 | dbg("%s - (%d) TIOCSERGETLSR", __func__, port->number); | 2541 | cprev = edge_port->icount; |
2681 | // return get_lsr_info(edge_port, (unsigned int *) arg); | 2542 | while (1) { |
2682 | break; | 2543 | interruptible_sleep_on(&edge_port->delta_msr_wait); |
2683 | 2544 | /* see if a signal did it */ | |
2684 | case TIOCGSERIAL: | 2545 | if (signal_pending(current)) |
2685 | dbg("%s - (%d) TIOCGSERIAL", __func__, port->number); | 2546 | return -ERESTARTSYS; |
2686 | return get_serial_info(edge_port, (struct serial_struct __user *) arg); | 2547 | cnow = edge_port->icount; |
2687 | break; | 2548 | if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && |
2688 | 2549 | cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) | |
2689 | case TIOCSSERIAL: | 2550 | return -EIO; /* no change => error */ |
2690 | dbg("%s - (%d) TIOCSSERIAL", __func__, port->number); | 2551 | if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || |
2691 | break; | 2552 | ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || |
2692 | 2553 | ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || | |
2693 | case TIOCMIWAIT: | 2554 | ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) { |
2694 | dbg("%s - (%d) TIOCMIWAIT", __func__, port->number); | 2555 | return 0; |
2695 | cprev = edge_port->icount; | ||
2696 | while (1) { | ||
2697 | interruptible_sleep_on(&edge_port->delta_msr_wait); | ||
2698 | /* see if a signal did it */ | ||
2699 | if (signal_pending(current)) | ||
2700 | return -ERESTARTSYS; | ||
2701 | cnow = edge_port->icount; | ||
2702 | if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && | ||
2703 | cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) | ||
2704 | return -EIO; /* no change => error */ | ||
2705 | if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || | ||
2706 | ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || | ||
2707 | ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || | ||
2708 | ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) { | ||
2709 | return 0; | ||
2710 | } | ||
2711 | cprev = cnow; | ||
2712 | } | 2556 | } |
2713 | /* not reached */ | 2557 | cprev = cnow; |
2714 | break; | 2558 | } |
2715 | 2559 | /* not reached */ | |
2716 | case TIOCGICOUNT: | 2560 | break; |
2717 | dbg ("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, | 2561 | case TIOCGICOUNT: |
2718 | port->number, edge_port->icount.rx, edge_port->icount.tx); | 2562 | dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, |
2719 | if (copy_to_user((void __user *)arg, &edge_port->icount, sizeof(edge_port->icount))) | 2563 | port->number, edge_port->icount.rx, edge_port->icount.tx); |
2720 | return -EFAULT; | 2564 | if (copy_to_user((void __user *)arg, &edge_port->icount, |
2721 | return 0; | 2565 | sizeof(edge_port->icount))) |
2566 | return -EFAULT; | ||
2567 | return 0; | ||
2722 | } | 2568 | } |
2723 | |||
2724 | return -ENOIOCTLCMD; | 2569 | return -ENOIOCTLCMD; |
2725 | } | 2570 | } |
2726 | 2571 | ||
2727 | static void edge_break (struct usb_serial_port *port, int break_state) | 2572 | static void edge_break(struct usb_serial_port *port, int on) |
2728 | { | 2573 | { |
2729 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 2574 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
2730 | int status; | 2575 | int status; |
2576 | int bv = 0; /* Off */ | ||
2731 | 2577 | ||
2732 | dbg ("%s - state = %d", __func__, break_state); | 2578 | dbg("%s - state = %d", __func__, on); |
2733 | 2579 | ||
2734 | /* chase the port close */ | 2580 | /* chase the port close */ |
2735 | TIChasePort (edge_port, 0, 0); | 2581 | chase_port(edge_port, 0, 0); |
2736 | 2582 | ||
2737 | if (break_state == -1) { | 2583 | if (on == -1) |
2738 | status = TISetBreak (edge_port); | 2584 | bv = 1; /* On */ |
2739 | } else { | 2585 | status = ti_do_config(edge_port, UMPC_SET_CLR_BREAK, bv); |
2740 | status = TIClearBreak (edge_port); | 2586 | if (status) |
2741 | } | 2587 | dbg("%s - error %d sending break set/clear command.", |
2742 | if (status) { | ||
2743 | dbg ("%s - error %d sending break set/clear command.", | ||
2744 | __func__, status); | 2588 | __func__, status); |
2745 | } | ||
2746 | } | 2589 | } |
2747 | 2590 | ||
2748 | static int edge_startup (struct usb_serial *serial) | 2591 | static int edge_startup(struct usb_serial *serial) |
2749 | { | 2592 | { |
2750 | struct edgeport_serial *edge_serial; | 2593 | struct edgeport_serial *edge_serial; |
2751 | struct edgeport_port *edge_port; | 2594 | struct edgeport_port *edge_port; |
@@ -2765,9 +2608,9 @@ static int edge_startup (struct usb_serial *serial) | |||
2765 | edge_serial->serial = serial; | 2608 | edge_serial->serial = serial; |
2766 | usb_set_serial_data(serial, edge_serial); | 2609 | usb_set_serial_data(serial, edge_serial); |
2767 | 2610 | ||
2768 | status = TIDownloadFirmware (edge_serial); | 2611 | status = download_fw(edge_serial); |
2769 | if (status) { | 2612 | if (status) { |
2770 | kfree (edge_serial); | 2613 | kfree(edge_serial); |
2771 | return status; | 2614 | return status; |
2772 | } | 2615 | } |
2773 | 2616 | ||
@@ -2775,13 +2618,15 @@ static int edge_startup (struct usb_serial *serial) | |||
2775 | for (i = 0; i < serial->num_ports; ++i) { | 2618 | for (i = 0; i < serial->num_ports; ++i) { |
2776 | edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL); | 2619 | edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL); |
2777 | if (edge_port == NULL) { | 2620 | if (edge_port == NULL) { |
2778 | dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__); | 2621 | dev_err(&serial->dev->dev, "%s - Out of memory\n", |
2622 | __func__); | ||
2779 | goto cleanup; | 2623 | goto cleanup; |
2780 | } | 2624 | } |
2781 | spin_lock_init(&edge_port->ep_lock); | 2625 | spin_lock_init(&edge_port->ep_lock); |
2782 | edge_port->ep_out_buf = edge_buf_alloc(EDGE_OUT_BUF_SIZE); | 2626 | edge_port->ep_out_buf = edge_buf_alloc(EDGE_OUT_BUF_SIZE); |
2783 | if (edge_port->ep_out_buf == NULL) { | 2627 | if (edge_port->ep_out_buf == NULL) { |
2784 | dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__); | 2628 | dev_err(&serial->dev->dev, "%s - Out of memory\n", |
2629 | __func__); | ||
2785 | kfree(edge_port); | 2630 | kfree(edge_port); |
2786 | goto cleanup; | 2631 | goto cleanup; |
2787 | } | 2632 | } |
@@ -2790,27 +2635,27 @@ static int edge_startup (struct usb_serial *serial) | |||
2790 | usb_set_serial_port_data(serial->port[i], edge_port); | 2635 | usb_set_serial_port_data(serial->port[i], edge_port); |
2791 | edge_port->bUartMode = default_uart_mode; | 2636 | edge_port->bUartMode = default_uart_mode; |
2792 | } | 2637 | } |
2793 | 2638 | ||
2794 | return 0; | 2639 | return 0; |
2795 | 2640 | ||
2796 | cleanup: | 2641 | cleanup: |
2797 | for (--i; i>=0; --i) { | 2642 | for (--i; i >= 0; --i) { |
2798 | edge_port = usb_get_serial_port_data(serial->port[i]); | 2643 | edge_port = usb_get_serial_port_data(serial->port[i]); |
2799 | edge_buf_free(edge_port->ep_out_buf); | 2644 | edge_buf_free(edge_port->ep_out_buf); |
2800 | kfree(edge_port); | 2645 | kfree(edge_port); |
2801 | usb_set_serial_port_data(serial->port[i], NULL); | 2646 | usb_set_serial_port_data(serial->port[i], NULL); |
2802 | } | 2647 | } |
2803 | kfree (edge_serial); | 2648 | kfree(edge_serial); |
2804 | usb_set_serial_data(serial, NULL); | 2649 | usb_set_serial_data(serial, NULL); |
2805 | return -ENOMEM; | 2650 | return -ENOMEM; |
2806 | } | 2651 | } |
2807 | 2652 | ||
2808 | static void edge_shutdown (struct usb_serial *serial) | 2653 | static void edge_shutdown(struct usb_serial *serial) |
2809 | { | 2654 | { |
2810 | int i; | 2655 | int i; |
2811 | struct edgeport_port *edge_port; | 2656 | struct edgeport_port *edge_port; |
2812 | 2657 | ||
2813 | dbg ("%s", __func__); | 2658 | dbg("%s", __func__); |
2814 | 2659 | ||
2815 | for (i = 0; i < serial->num_ports; ++i) { | 2660 | for (i = 0; i < serial->num_ports; ++i) { |
2816 | edge_port = usb_get_serial_port_data(serial->port[i]); | 2661 | edge_port = usb_get_serial_port_data(serial->port[i]); |
@@ -2852,7 +2697,8 @@ static ssize_t store_uart_mode(struct device *dev, | |||
2852 | return count; | 2697 | return count; |
2853 | } | 2698 | } |
2854 | 2699 | ||
2855 | static DEVICE_ATTR(uart_mode, S_IWUSR | S_IRUGO, show_uart_mode, store_uart_mode); | 2700 | static DEVICE_ATTR(uart_mode, S_IWUSR | S_IRUGO, show_uart_mode, |
2701 | store_uart_mode); | ||
2856 | 2702 | ||
2857 | static int edge_create_sysfs_attrs(struct usb_serial_port *port) | 2703 | static int edge_create_sysfs_attrs(struct usb_serial_port *port) |
2858 | { | 2704 | { |
@@ -2922,9 +2768,9 @@ static void edge_buf_free(struct edge_buf *eb) | |||
2922 | 2768 | ||
2923 | static void edge_buf_clear(struct edge_buf *eb) | 2769 | static void edge_buf_clear(struct edge_buf *eb) |
2924 | { | 2770 | { |
2925 | if (eb != NULL) | 2771 | if (eb != NULL) |
2926 | eb->buf_get = eb->buf_put; | 2772 | eb->buf_get = eb->buf_put; |
2927 | /* equivalent to a get of all data available */ | 2773 | /* equivalent to a get of all data available */ |
2928 | } | 2774 | } |
2929 | 2775 | ||
2930 | 2776 | ||
@@ -2937,10 +2783,9 @@ static void edge_buf_clear(struct edge_buf *eb) | |||
2937 | 2783 | ||
2938 | static unsigned int edge_buf_data_avail(struct edge_buf *eb) | 2784 | static unsigned int edge_buf_data_avail(struct edge_buf *eb) |
2939 | { | 2785 | { |
2940 | if (eb != NULL) | 2786 | if (eb == NULL) |
2941 | return ((eb->buf_size + eb->buf_put - eb->buf_get) % eb->buf_size); | ||
2942 | else | ||
2943 | return 0; | 2787 | return 0; |
2788 | return ((eb->buf_size + eb->buf_put - eb->buf_get) % eb->buf_size); | ||
2944 | } | 2789 | } |
2945 | 2790 | ||
2946 | 2791 | ||
@@ -2953,10 +2798,9 @@ static unsigned int edge_buf_data_avail(struct edge_buf *eb) | |||
2953 | 2798 | ||
2954 | static unsigned int edge_buf_space_avail(struct edge_buf *eb) | 2799 | static unsigned int edge_buf_space_avail(struct edge_buf *eb) |
2955 | { | 2800 | { |
2956 | if (eb != NULL) | 2801 | if (eb == NULL) |
2957 | return ((eb->buf_size + eb->buf_get - eb->buf_put - 1) % eb->buf_size); | ||
2958 | else | ||
2959 | return 0; | 2802 | return 0; |
2803 | return ((eb->buf_size + eb->buf_get - eb->buf_put - 1) % eb->buf_size); | ||
2960 | } | 2804 | } |
2961 | 2805 | ||
2962 | 2806 | ||
@@ -3113,7 +2957,7 @@ static int __init edgeport_init(void) | |||
3113 | if (retval) | 2957 | if (retval) |
3114 | goto failed_2port_device_register; | 2958 | goto failed_2port_device_register; |
3115 | retval = usb_register(&io_driver); | 2959 | retval = usb_register(&io_driver); |
3116 | if (retval) | 2960 | if (retval) |
3117 | goto failed_usb_register; | 2961 | goto failed_usb_register; |
3118 | info(DRIVER_DESC " " DRIVER_VERSION); | 2962 | info(DRIVER_DESC " " DRIVER_VERSION); |
3119 | return 0; | 2963 | return 0; |
@@ -3125,11 +2969,11 @@ failed_1port_device_register: | |||
3125 | return retval; | 2969 | return retval; |
3126 | } | 2970 | } |
3127 | 2971 | ||
3128 | static void __exit edgeport_exit (void) | 2972 | static void __exit edgeport_exit(void) |
3129 | { | 2973 | { |
3130 | usb_deregister (&io_driver); | 2974 | usb_deregister(&io_driver); |
3131 | usb_serial_deregister (&edgeport_1port_device); | 2975 | usb_serial_deregister(&edgeport_1port_device); |
3132 | usb_serial_deregister (&edgeport_2port_device); | 2976 | usb_serial_deregister(&edgeport_2port_device); |
3133 | } | 2977 | } |
3134 | 2978 | ||
3135 | module_init(edgeport_init); | 2979 | module_init(edgeport_init); |
@@ -3151,8 +2995,8 @@ module_param(closing_wait, int, S_IRUGO | S_IWUSR); | |||
3151 | MODULE_PARM_DESC(closing_wait, "Maximum wait for data to drain, in .01 secs"); | 2995 | MODULE_PARM_DESC(closing_wait, "Maximum wait for data to drain, in .01 secs"); |
3152 | 2996 | ||
3153 | module_param(ignore_cpu_rev, bool, S_IRUGO | S_IWUSR); | 2997 | module_param(ignore_cpu_rev, bool, S_IRUGO | S_IWUSR); |
3154 | MODULE_PARM_DESC(ignore_cpu_rev, "Ignore the cpu revision when connecting to a device"); | 2998 | MODULE_PARM_DESC(ignore_cpu_rev, |
2999 | "Ignore the cpu revision when connecting to a device"); | ||
3155 | 3000 | ||
3156 | module_param(default_uart_mode, int, S_IRUGO | S_IWUSR); | 3001 | module_param(default_uart_mode, int, S_IRUGO | S_IWUSR); |
3157 | MODULE_PARM_DESC(default_uart_mode, "Default uart_mode, 0=RS232, ..."); | 3002 | MODULE_PARM_DESC(default_uart_mode, "Default uart_mode, 0=RS232, ..."); |
3158 | |||
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index d9fb3768a2d7..80d9ec5570d6 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c | |||
@@ -646,12 +646,13 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp) | |||
646 | */ | 646 | */ |
647 | 647 | ||
648 | kfree(port->bulk_in_buffer); | 648 | kfree(port->bulk_in_buffer); |
649 | kfree(port->bulk_out_buffer); | ||
650 | port->bulk_in_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL); | 649 | port->bulk_in_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL); |
651 | if (port->bulk_in_buffer == NULL) { | 650 | if (port->bulk_in_buffer == NULL) { |
652 | port->bulk_out_buffer = NULL; /* prevent double free */ | 651 | port->bulk_out_buffer = NULL; /* prevent double free */ |
653 | goto enomem; | 652 | goto enomem; |
654 | } | 653 | } |
654 | |||
655 | kfree(port->bulk_out_buffer); | ||
655 | port->bulk_out_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL); | 656 | port->bulk_out_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL); |
656 | if (port->bulk_out_buffer == NULL) { | 657 | if (port->bulk_out_buffer == NULL) { |
657 | kfree(port->bulk_in_buffer); | 658 | kfree(port->bulk_in_buffer); |
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c index 004d57385a75..0063c11c8081 100644 --- a/drivers/usb/serial/ir-usb.c +++ b/drivers/usb/serial/ir-usb.c | |||
@@ -19,7 +19,12 @@ | |||
19 | * was written by Roman Weissgaerber <weissg@vienna.at>, Dag Brattli | 19 | * was written by Roman Weissgaerber <weissg@vienna.at>, Dag Brattli |
20 | * <dag@brattli.net>, and Jean Tourrilhes <jt@hpl.hp.com> | 20 | * <dag@brattli.net>, and Jean Tourrilhes <jt@hpl.hp.com> |
21 | * | 21 | * |
22 | * See Documentation/usb/usb-serial.txt for more information on using this driver | 22 | * See Documentation/usb/usb-serial.txt for more information on using this |
23 | * driver | ||
24 | * | ||
25 | * 2008_Jun_02 Felipe Balbi <me@felipebalbi.com> | ||
26 | * Introduced common header to be used also in USB Gadget Framework. | ||
27 | * Still needs some other style fixes. | ||
23 | * | 28 | * |
24 | * 2007_Jun_21 Alan Cox <alan@redhat.com> | 29 | * 2007_Jun_21 Alan Cox <alan@redhat.com> |
25 | * Minimal cleanups for some of the driver problens and tty layer abuse. | 30 | * Minimal cleanups for some of the driver problens and tty layer abuse. |
@@ -59,9 +64,10 @@ | |||
59 | #include <linux/tty_flip.h> | 64 | #include <linux/tty_flip.h> |
60 | #include <linux/module.h> | 65 | #include <linux/module.h> |
61 | #include <linux/spinlock.h> | 66 | #include <linux/spinlock.h> |
62 | #include <asm/uaccess.h> | 67 | #include <linux/uaccess.h> |
63 | #include <linux/usb.h> | 68 | #include <linux/usb.h> |
64 | #include <linux/usb/serial.h> | 69 | #include <linux/usb/serial.h> |
70 | #include <linux/usb/irda.h> | ||
65 | 71 | ||
66 | /* | 72 | /* |
67 | * Version Information | 73 | * Version Information |
@@ -70,100 +76,75 @@ | |||
70 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>" | 76 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>" |
71 | #define DRIVER_DESC "USB IR Dongle driver" | 77 | #define DRIVER_DESC "USB IR Dongle driver" |
72 | 78 | ||
73 | /* USB IrDA class spec information */ | ||
74 | #define USB_CLASS_IRDA 0x02 | ||
75 | #define USB_DT_IRDA 0x21 | ||
76 | #define IU_REQ_GET_CLASS_DESC 0x06 | ||
77 | #define SPEED_2400 0x01 | ||
78 | #define SPEED_9600 0x02 | ||
79 | #define SPEED_19200 0x03 | ||
80 | #define SPEED_38400 0x04 | ||
81 | #define SPEED_57600 0x05 | ||
82 | #define SPEED_115200 0x06 | ||
83 | #define SPEED_576000 0x07 | ||
84 | #define SPEED_1152000 0x08 | ||
85 | #define SPEED_4000000 0x09 | ||
86 | |||
87 | struct irda_class_desc { | ||
88 | u8 bLength; | ||
89 | u8 bDescriptorType; | ||
90 | u16 bcdSpecRevision; | ||
91 | u8 bmDataSize; | ||
92 | u8 bmWindowSize; | ||
93 | u8 bmMinTurnaroundTime; | ||
94 | u16 wBaudRate; | ||
95 | u8 bmAdditionalBOFs; | ||
96 | u8 bIrdaRateSniff; | ||
97 | u8 bMaxUnicastList; | ||
98 | } __attribute__ ((packed)); | ||
99 | |||
100 | static int debug; | 79 | static int debug; |
101 | 80 | ||
102 | /* if overridden by the user, then use their value for the size of the read and | 81 | /* if overridden by the user, then use their value for the size of the read and |
103 | * write urbs */ | 82 | * write urbs */ |
104 | static int buffer_size; | 83 | static int buffer_size; |
84 | |||
105 | /* if overridden by the user, then use the specified number of XBOFs */ | 85 | /* if overridden by the user, then use the specified number of XBOFs */ |
106 | static int xbof = -1; | 86 | static int xbof = -1; |
107 | 87 | ||
108 | static int ir_startup (struct usb_serial *serial); | 88 | static int ir_startup(struct usb_serial *serial); |
109 | static int ir_open (struct usb_serial_port *port, struct file *filep); | 89 | static int ir_open(struct usb_serial_port *port, struct file *filep); |
110 | static void ir_close (struct usb_serial_port *port, struct file *filep); | 90 | static void ir_close(struct usb_serial_port *port, struct file *filep); |
111 | static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int count); | 91 | static int ir_write(struct usb_serial_port *port, |
112 | static void ir_write_bulk_callback (struct urb *urb); | 92 | const unsigned char *buf, int count); |
113 | static void ir_read_bulk_callback (struct urb *urb); | 93 | static void ir_write_bulk_callback(struct urb *urb); |
114 | static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_termios); | 94 | static void ir_read_bulk_callback(struct urb *urb); |
95 | static void ir_set_termios(struct usb_serial_port *port, | ||
96 | struct ktermios *old_termios); | ||
115 | 97 | ||
116 | /* Not that this lot means you can only have one per system */ | 98 | /* Not that this lot means you can only have one per system */ |
117 | static u8 ir_baud = 0; | 99 | static u8 ir_baud; |
118 | static u8 ir_xbof = 0; | 100 | static u8 ir_xbof; |
119 | static u8 ir_add_bof = 0; | 101 | static u8 ir_add_bof; |
120 | 102 | ||
121 | static struct usb_device_id id_table [] = { | 103 | static struct usb_device_id ir_id_table[] = { |
122 | { USB_DEVICE(0x050f, 0x0180) }, /* KC Technology, KC-180 */ | 104 | { USB_DEVICE(0x050f, 0x0180) }, /* KC Technology, KC-180 */ |
123 | { USB_DEVICE(0x08e9, 0x0100) }, /* XTNDAccess */ | 105 | { USB_DEVICE(0x08e9, 0x0100) }, /* XTNDAccess */ |
124 | { USB_DEVICE(0x09c4, 0x0011) }, /* ACTiSys ACT-IR2000U */ | 106 | { USB_DEVICE(0x09c4, 0x0011) }, /* ACTiSys ACT-IR2000U */ |
125 | { USB_INTERFACE_INFO (USB_CLASS_APP_SPEC, USB_CLASS_IRDA, 0) }, | 107 | { USB_INTERFACE_INFO(USB_CLASS_APP_SPEC, USB_SUBCLASS_IRDA, 0) }, |
126 | { } /* Terminating entry */ | 108 | { } /* Terminating entry */ |
127 | }; | 109 | }; |
128 | 110 | ||
129 | MODULE_DEVICE_TABLE (usb, id_table); | 111 | MODULE_DEVICE_TABLE(usb, ir_id_table); |
130 | 112 | ||
131 | static struct usb_driver ir_driver = { | 113 | static struct usb_driver ir_driver = { |
132 | .name = "ir-usb", | 114 | .name = "ir-usb", |
133 | .probe = usb_serial_probe, | 115 | .probe = usb_serial_probe, |
134 | .disconnect = usb_serial_disconnect, | 116 | .disconnect = usb_serial_disconnect, |
135 | .id_table = id_table, | 117 | .id_table = ir_id_table, |
136 | .no_dynamic_id = 1, | 118 | .no_dynamic_id = 1, |
137 | }; | 119 | }; |
138 | 120 | ||
139 | |||
140 | static struct usb_serial_driver ir_device = { | 121 | static struct usb_serial_driver ir_device = { |
141 | .driver = { | 122 | .driver = { |
142 | .owner = THIS_MODULE, | 123 | .owner = THIS_MODULE, |
143 | .name = "ir-usb", | 124 | .name = "ir-usb", |
144 | }, | 125 | }, |
145 | .description = "IR Dongle", | 126 | .description = "IR Dongle", |
146 | .usb_driver = &ir_driver, | 127 | .usb_driver = &ir_driver, |
147 | .id_table = id_table, | 128 | .id_table = ir_id_table, |
148 | .num_ports = 1, | 129 | .num_ports = 1, |
149 | .set_termios = ir_set_termios, | 130 | .set_termios = ir_set_termios, |
150 | .attach = ir_startup, | 131 | .attach = ir_startup, |
151 | .open = ir_open, | 132 | .open = ir_open, |
152 | .close = ir_close, | 133 | .close = ir_close, |
153 | .write = ir_write, | 134 | .write = ir_write, |
154 | .write_bulk_callback = ir_write_bulk_callback, | 135 | .write_bulk_callback = ir_write_bulk_callback, |
155 | .read_bulk_callback = ir_read_bulk_callback, | 136 | .read_bulk_callback = ir_read_bulk_callback, |
156 | }; | 137 | }; |
157 | 138 | ||
158 | static inline void irda_usb_dump_class_desc(struct irda_class_desc *desc) | 139 | static inline void irda_usb_dump_class_desc(struct usb_irda_cs_descriptor *desc) |
159 | { | 140 | { |
160 | dbg("bLength=%x", desc->bLength); | 141 | dbg("bLength=%x", desc->bLength); |
161 | dbg("bDescriptorType=%x", desc->bDescriptorType); | 142 | dbg("bDescriptorType=%x", desc->bDescriptorType); |
162 | dbg("bcdSpecRevision=%x", desc->bcdSpecRevision); | 143 | dbg("bcdSpecRevision=%x", __le16_to_cpu(desc->bcdSpecRevision)); |
163 | dbg("bmDataSize=%x", desc->bmDataSize); | 144 | dbg("bmDataSize=%x", desc->bmDataSize); |
164 | dbg("bmWindowSize=%x", desc->bmWindowSize); | 145 | dbg("bmWindowSize=%x", desc->bmWindowSize); |
165 | dbg("bmMinTurnaroundTime=%d", desc->bmMinTurnaroundTime); | 146 | dbg("bmMinTurnaroundTime=%d", desc->bmMinTurnaroundTime); |
166 | dbg("wBaudRate=%x", desc->wBaudRate); | 147 | dbg("wBaudRate=%x", __le16_to_cpu(desc->wBaudRate)); |
167 | dbg("bmAdditionalBOFs=%x", desc->bmAdditionalBOFs); | 148 | dbg("bmAdditionalBOFs=%x", desc->bmAdditionalBOFs); |
168 | dbg("bIrdaRateSniff=%x", desc->bIrdaRateSniff); | 149 | dbg("bIrdaRateSniff=%x", desc->bIrdaRateSniff); |
169 | dbg("bMaxUnicastList=%x", desc->bMaxUnicastList); | 150 | dbg("bMaxUnicastList=%x", desc->bMaxUnicastList); |
@@ -181,35 +162,37 @@ static inline void irda_usb_dump_class_desc(struct irda_class_desc *desc) | |||
181 | * | 162 | * |
182 | * Based on the same function in drivers/net/irda/irda-usb.c | 163 | * Based on the same function in drivers/net/irda/irda-usb.c |
183 | */ | 164 | */ |
184 | static struct irda_class_desc *irda_usb_find_class_desc(struct usb_device *dev, unsigned int ifnum) | 165 | static struct usb_irda_cs_descriptor * |
166 | irda_usb_find_class_desc(struct usb_device *dev, unsigned int ifnum) | ||
185 | { | 167 | { |
186 | struct irda_class_desc *desc; | 168 | struct usb_irda_cs_descriptor *desc; |
187 | int ret; | 169 | int ret; |
188 | 170 | ||
189 | desc = kzalloc(sizeof (struct irda_class_desc), GFP_KERNEL); | 171 | desc = kzalloc(sizeof(*desc), GFP_KERNEL); |
190 | if (desc == NULL) | 172 | if (!desc) |
191 | return NULL; | 173 | return NULL; |
192 | 174 | ||
193 | ret = usb_control_msg(dev, usb_rcvctrlpipe(dev,0), | 175 | ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), |
194 | IU_REQ_GET_CLASS_DESC, | 176 | USB_REQ_CS_IRDA_GET_CLASS_DESC, |
195 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | 177 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, |
196 | 0, ifnum, desc, sizeof(*desc), 1000); | 178 | 0, ifnum, desc, sizeof(*desc), 1000); |
197 | 179 | ||
198 | dbg("%s - ret=%d", __func__, ret); | 180 | dbg("%s - ret=%d", __func__, ret); |
199 | if (ret < sizeof(*desc)) { | 181 | if (ret < sizeof(*desc)) { |
200 | dbg("%s - class descriptor read %s (%d)", | 182 | dbg("%s - class descriptor read %s (%d)", |
201 | __func__, | 183 | __func__, |
202 | (ret<0) ? "failed" : "too short", | 184 | (ret < 0) ? "failed" : "too short", |
203 | ret); | 185 | ret); |
204 | goto error; | 186 | goto error; |
205 | } | 187 | } |
206 | if (desc->bDescriptorType != USB_DT_IRDA) { | 188 | if (desc->bDescriptorType != USB_DT_CS_IRDA) { |
207 | dbg("%s - bad class descriptor type", __func__); | 189 | dbg("%s - bad class descriptor type", __func__); |
208 | goto error; | 190 | goto error; |
209 | } | 191 | } |
210 | 192 | ||
211 | irda_usb_dump_class_desc(desc); | 193 | irda_usb_dump_class_desc(desc); |
212 | return desc; | 194 | return desc; |
195 | |||
213 | error: | 196 | error: |
214 | kfree(desc); | 197 | kfree(desc); |
215 | return NULL; | 198 | return NULL; |
@@ -219,64 +202,100 @@ error: | |||
219 | static u8 ir_xbof_change(u8 xbof) | 202 | static u8 ir_xbof_change(u8 xbof) |
220 | { | 203 | { |
221 | u8 result; | 204 | u8 result; |
205 | |||
222 | /* reference irda-usb.c */ | 206 | /* reference irda-usb.c */ |
223 | switch(xbof) { | 207 | switch (xbof) { |
224 | case 48: result = 0x10; break; | 208 | case 48: |
225 | case 28: | 209 | result = 0x10; |
226 | case 24: result = 0x20; break; | 210 | break; |
227 | default: | 211 | case 28: |
228 | case 12: result = 0x30; break; | 212 | case 24: |
229 | case 5: | 213 | result = 0x20; |
230 | case 6: result = 0x40; break; | 214 | break; |
231 | case 3: result = 0x50; break; | 215 | default: |
232 | case 2: result = 0x60; break; | 216 | case 12: |
233 | case 1: result = 0x70; break; | 217 | result = 0x30; |
234 | case 0: result = 0x80; break; | 218 | break; |
219 | case 5: | ||
220 | case 6: | ||
221 | result = 0x40; | ||
222 | break; | ||
223 | case 3: | ||
224 | result = 0x50; | ||
225 | break; | ||
226 | case 2: | ||
227 | result = 0x60; | ||
228 | break; | ||
229 | case 1: | ||
230 | result = 0x70; | ||
231 | break; | ||
232 | case 0: | ||
233 | result = 0x80; | ||
234 | break; | ||
235 | } | 235 | } |
236 | |||
236 | return(result); | 237 | return(result); |
237 | } | 238 | } |
238 | 239 | ||
239 | 240 | ||
240 | static int ir_startup (struct usb_serial *serial) | 241 | static int ir_startup(struct usb_serial *serial) |
241 | { | 242 | { |
242 | struct irda_class_desc *irda_desc; | 243 | struct usb_irda_cs_descriptor *irda_desc; |
243 | 244 | ||
244 | irda_desc = irda_usb_find_class_desc (serial->dev, 0); | 245 | irda_desc = irda_usb_find_class_desc(serial->dev, 0); |
245 | if (irda_desc == NULL) { | 246 | if (!irda_desc) { |
246 | dev_err (&serial->dev->dev, "IRDA class descriptor not found, device not bound\n"); | 247 | dev_err(&serial->dev->dev, |
248 | "IRDA class descriptor not found, device not bound\n"); | ||
247 | return -ENODEV; | 249 | return -ENODEV; |
248 | } | 250 | } |
249 | 251 | ||
250 | dbg ("%s - Baud rates supported:%s%s%s%s%s%s%s%s%s", | 252 | dbg("%s - Baud rates supported:%s%s%s%s%s%s%s%s%s", |
251 | __func__, | 253 | __func__, |
252 | (irda_desc->wBaudRate & 0x0001) ? " 2400" : "", | 254 | (irda_desc->wBaudRate & USB_IRDA_BR_2400) ? " 2400" : "", |
253 | (irda_desc->wBaudRate & 0x0002) ? " 9600" : "", | 255 | (irda_desc->wBaudRate & USB_IRDA_BR_9600) ? " 9600" : "", |
254 | (irda_desc->wBaudRate & 0x0004) ? " 19200" : "", | 256 | (irda_desc->wBaudRate & USB_IRDA_BR_19200) ? " 19200" : "", |
255 | (irda_desc->wBaudRate & 0x0008) ? " 38400" : "", | 257 | (irda_desc->wBaudRate & USB_IRDA_BR_38400) ? " 38400" : "", |
256 | (irda_desc->wBaudRate & 0x0010) ? " 57600" : "", | 258 | (irda_desc->wBaudRate & USB_IRDA_BR_57600) ? " 57600" : "", |
257 | (irda_desc->wBaudRate & 0x0020) ? " 115200" : "", | 259 | (irda_desc->wBaudRate & USB_IRDA_BR_115200) ? " 115200" : "", |
258 | (irda_desc->wBaudRate & 0x0040) ? " 576000" : "", | 260 | (irda_desc->wBaudRate & USB_IRDA_BR_576000) ? " 576000" : "", |
259 | (irda_desc->wBaudRate & 0x0080) ? " 1152000" : "", | 261 | (irda_desc->wBaudRate & USB_IRDA_BR_1152000) ? " 1152000" : "", |
260 | (irda_desc->wBaudRate & 0x0100) ? " 4000000" : ""); | 262 | (irda_desc->wBaudRate & USB_IRDA_BR_4000000) ? " 4000000" : ""); |
261 | 263 | ||
262 | switch( irda_desc->bmAdditionalBOFs ) { | 264 | switch (irda_desc->bmAdditionalBOFs) { |
263 | case 0x01: ir_add_bof = 48; break; | 265 | case USB_IRDA_AB_48: |
264 | case 0x02: ir_add_bof = 24; break; | 266 | ir_add_bof = 48; |
265 | case 0x04: ir_add_bof = 12; break; | 267 | break; |
266 | case 0x08: ir_add_bof = 6; break; | 268 | case USB_IRDA_AB_24: |
267 | case 0x10: ir_add_bof = 3; break; | 269 | ir_add_bof = 24; |
268 | case 0x20: ir_add_bof = 2; break; | 270 | break; |
269 | case 0x40: ir_add_bof = 1; break; | 271 | case USB_IRDA_AB_12: |
270 | case 0x80: ir_add_bof = 0; break; | 272 | ir_add_bof = 12; |
271 | default:; | 273 | break; |
274 | case USB_IRDA_AB_6: | ||
275 | ir_add_bof = 6; | ||
276 | break; | ||
277 | case USB_IRDA_AB_3: | ||
278 | ir_add_bof = 3; | ||
279 | break; | ||
280 | case USB_IRDA_AB_2: | ||
281 | ir_add_bof = 2; | ||
282 | break; | ||
283 | case USB_IRDA_AB_1: | ||
284 | ir_add_bof = 1; | ||
285 | break; | ||
286 | case USB_IRDA_AB_0: | ||
287 | ir_add_bof = 0; | ||
288 | break; | ||
289 | default: | ||
290 | break; | ||
272 | } | 291 | } |
273 | 292 | ||
274 | kfree (irda_desc); | 293 | kfree(irda_desc); |
275 | 294 | ||
276 | return 0; | 295 | return 0; |
277 | } | 296 | } |
278 | 297 | ||
279 | static int ir_open (struct usb_serial_port *port, struct file *filp) | 298 | static int ir_open(struct usb_serial_port *port, struct file *filp) |
280 | { | 299 | { |
281 | char *buffer; | 300 | char *buffer; |
282 | int result = 0; | 301 | int result = 0; |
@@ -285,51 +304,55 @@ static int ir_open (struct usb_serial_port *port, struct file *filp) | |||
285 | 304 | ||
286 | if (buffer_size) { | 305 | if (buffer_size) { |
287 | /* override the default buffer sizes */ | 306 | /* override the default buffer sizes */ |
288 | buffer = kmalloc (buffer_size, GFP_KERNEL); | 307 | buffer = kmalloc(buffer_size, GFP_KERNEL); |
289 | if (!buffer) { | 308 | if (!buffer) { |
290 | dev_err (&port->dev, "%s - out of memory.\n", __func__); | 309 | dev_err(&port->dev, "%s - out of memory.\n", __func__); |
291 | return -ENOMEM; | 310 | return -ENOMEM; |
292 | } | 311 | } |
293 | kfree (port->read_urb->transfer_buffer); | 312 | kfree(port->read_urb->transfer_buffer); |
294 | port->read_urb->transfer_buffer = buffer; | 313 | port->read_urb->transfer_buffer = buffer; |
295 | port->read_urb->transfer_buffer_length = buffer_size; | 314 | port->read_urb->transfer_buffer_length = buffer_size; |
296 | 315 | ||
297 | buffer = kmalloc (buffer_size, GFP_KERNEL); | 316 | buffer = kmalloc(buffer_size, GFP_KERNEL); |
298 | if (!buffer) { | 317 | if (!buffer) { |
299 | dev_err (&port->dev, "%s - out of memory.\n", __func__); | 318 | dev_err(&port->dev, "%s - out of memory.\n", __func__); |
300 | return -ENOMEM; | 319 | return -ENOMEM; |
301 | } | 320 | } |
302 | kfree (port->write_urb->transfer_buffer); | 321 | kfree(port->write_urb->transfer_buffer); |
303 | port->write_urb->transfer_buffer = buffer; | 322 | port->write_urb->transfer_buffer = buffer; |
304 | port->write_urb->transfer_buffer_length = buffer_size; | 323 | port->write_urb->transfer_buffer_length = buffer_size; |
305 | port->bulk_out_size = buffer_size; | 324 | port->bulk_out_size = buffer_size; |
306 | } | 325 | } |
307 | 326 | ||
308 | /* Start reading from the device */ | 327 | /* Start reading from the device */ |
309 | usb_fill_bulk_urb ( | 328 | usb_fill_bulk_urb( |
310 | port->read_urb, | 329 | port->read_urb, |
311 | port->serial->dev, | 330 | port->serial->dev, |
312 | usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), | 331 | usb_rcvbulkpipe(port->serial->dev, |
332 | port->bulk_in_endpointAddress), | ||
313 | port->read_urb->transfer_buffer, | 333 | port->read_urb->transfer_buffer, |
314 | port->read_urb->transfer_buffer_length, | 334 | port->read_urb->transfer_buffer_length, |
315 | ir_read_bulk_callback, | 335 | ir_read_bulk_callback, |
316 | port); | 336 | port); |
317 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); | 337 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); |
318 | if (result) | 338 | if (result) |
319 | dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result); | 339 | dev_err(&port->dev, |
340 | "%s - failed submitting read urb, error %d\n", | ||
341 | __func__, result); | ||
320 | 342 | ||
321 | return result; | 343 | return result; |
322 | } | 344 | } |
323 | 345 | ||
324 | static void ir_close (struct usb_serial_port *port, struct file * filp) | 346 | static void ir_close(struct usb_serial_port *port, struct file *filp) |
325 | { | 347 | { |
326 | dbg("%s - port %d", __func__, port->number); | 348 | dbg("%s - port %d", __func__, port->number); |
327 | 349 | ||
328 | /* shutdown our bulk read */ | 350 | /* shutdown our bulk read */ |
329 | usb_kill_urb(port->read_urb); | 351 | usb_kill_urb(port->read_urb); |
330 | } | 352 | } |
331 | 353 | ||
332 | static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int count) | 354 | static int ir_write(struct usb_serial_port *port, |
355 | const unsigned char *buf, int count) | ||
333 | { | 356 | { |
334 | unsigned char *transfer_buffer; | 357 | unsigned char *transfer_buffer; |
335 | int result; | 358 | int result; |
@@ -338,7 +361,7 @@ static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int | |||
338 | dbg("%s - port = %d, count = %d", __func__, port->number, count); | 361 | dbg("%s - port = %d, count = %d", __func__, port->number, count); |
339 | 362 | ||
340 | if (!port->tty) { | 363 | if (!port->tty) { |
341 | dev_err (&port->dev, "%s - no tty???\n", __func__); | 364 | dev_err(&port->dev, "%s - no tty???\n", __func__); |
342 | return 0; | 365 | return 0; |
343 | } | 366 | } |
344 | 367 | ||
@@ -359,7 +382,7 @@ static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int | |||
359 | 382 | ||
360 | /* | 383 | /* |
361 | * The first byte of the packet we send to the device contains an | 384 | * The first byte of the packet we send to the device contains an |
362 | * inband header which indicates an additional number of BOFs and | 385 | * inbound header which indicates an additional number of BOFs and |
363 | * a baud rate change. | 386 | * a baud rate change. |
364 | * | 387 | * |
365 | * See section 5.4.2.2 of the USB IrDA spec. | 388 | * See section 5.4.2.2 of the USB IrDA spec. |
@@ -367,9 +390,9 @@ static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int | |||
367 | *transfer_buffer = ir_xbof | ir_baud; | 390 | *transfer_buffer = ir_xbof | ir_baud; |
368 | ++transfer_buffer; | 391 | ++transfer_buffer; |
369 | 392 | ||
370 | memcpy (transfer_buffer, buf, transfer_size); | 393 | memcpy(transfer_buffer, buf, transfer_size); |
371 | 394 | ||
372 | usb_fill_bulk_urb ( | 395 | usb_fill_bulk_urb( |
373 | port->write_urb, | 396 | port->write_urb, |
374 | port->serial->dev, | 397 | port->serial->dev, |
375 | usb_sndbulkpipe(port->serial->dev, | 398 | usb_sndbulkpipe(port->serial->dev, |
@@ -381,17 +404,19 @@ static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int | |||
381 | 404 | ||
382 | port->write_urb->transfer_flags = URB_ZERO_PACKET; | 405 | port->write_urb->transfer_flags = URB_ZERO_PACKET; |
383 | 406 | ||
384 | result = usb_submit_urb (port->write_urb, GFP_ATOMIC); | 407 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
385 | if (result) { | 408 | if (result) { |
386 | port->write_urb_busy = 0; | 409 | port->write_urb_busy = 0; |
387 | dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, result); | 410 | dev_err(&port->dev, |
411 | "%s - failed submitting write urb, error %d\n", | ||
412 | __func__, result); | ||
388 | } else | 413 | } else |
389 | result = transfer_size; | 414 | result = transfer_size; |
390 | 415 | ||
391 | return result; | 416 | return result; |
392 | } | 417 | } |
393 | 418 | ||
394 | static void ir_write_bulk_callback (struct urb *urb) | 419 | static void ir_write_bulk_callback(struct urb *urb) |
395 | { | 420 | { |
396 | struct usb_serial_port *port = urb->context; | 421 | struct usb_serial_port *port = urb->context; |
397 | int status = urb->status; | 422 | int status = urb->status; |
@@ -405,7 +430,7 @@ static void ir_write_bulk_callback (struct urb *urb) | |||
405 | return; | 430 | return; |
406 | } | 431 | } |
407 | 432 | ||
408 | usb_serial_debug_data ( | 433 | usb_serial_debug_data( |
409 | debug, | 434 | debug, |
410 | &port->dev, | 435 | &port->dev, |
411 | __func__, | 436 | __func__, |
@@ -415,7 +440,7 @@ static void ir_write_bulk_callback (struct urb *urb) | |||
415 | usb_serial_port_softint(port); | 440 | usb_serial_port_softint(port); |
416 | } | 441 | } |
417 | 442 | ||
418 | static void ir_read_bulk_callback (struct urb *urb) | 443 | static void ir_read_bulk_callback(struct urb *urb) |
419 | { | 444 | { |
420 | struct usb_serial_port *port = urb->context; | 445 | struct usb_serial_port *port = urb->context; |
421 | struct tty_struct *tty; | 446 | struct tty_struct *tty; |
@@ -431,68 +456,69 @@ static void ir_read_bulk_callback (struct urb *urb) | |||
431 | } | 456 | } |
432 | 457 | ||
433 | switch (status) { | 458 | switch (status) { |
434 | case 0: /* Successful */ | 459 | case 0: /* Successful */ |
435 | 460 | ||
436 | /* | 461 | /* |
437 | * The first byte of the packet we get from the device | 462 | * The first byte of the packet we get from the device |
438 | * contains a busy indicator and baud rate change. | 463 | * contains a busy indicator and baud rate change. |
439 | * See section 5.4.1.2 of the USB IrDA spec. | 464 | * See section 5.4.1.2 of the USB IrDA spec. |
440 | */ | 465 | */ |
441 | if ((*data & 0x0f) > 0) | 466 | if ((*data & 0x0f) > 0) |
442 | ir_baud = *data & 0x0f; | 467 | ir_baud = *data & 0x0f; |
443 | 468 | ||
444 | usb_serial_debug_data ( | 469 | usb_serial_debug_data( |
445 | debug, | 470 | debug, |
446 | &port->dev, | 471 | &port->dev, |
447 | __func__, | 472 | __func__, |
448 | urb->actual_length, | 473 | urb->actual_length, |
449 | data); | 474 | data); |
450 | 475 | ||
451 | tty = port->tty; | 476 | tty = port->tty; |
452 | 477 | ||
453 | if (tty_buffer_request_room(tty, urb->actual_length - 1)) { | 478 | if (tty_buffer_request_room(tty, urb->actual_length - 1)) { |
454 | tty_insert_flip_string(tty, data+1, urb->actual_length - 1); | 479 | tty_insert_flip_string(tty, data + 1, |
455 | tty_flip_buffer_push(tty); | 480 | urb->actual_length - 1); |
456 | } | 481 | tty_flip_buffer_push(tty); |
457 | 482 | } | |
458 | /* | ||
459 | * No break here. | ||
460 | * We want to resubmit the urb so we can read | ||
461 | * again. | ||
462 | */ | ||
463 | |||
464 | case -EPROTO: /* taking inspiration from pl2303.c */ | ||
465 | |||
466 | /* Continue trying to always read */ | ||
467 | usb_fill_bulk_urb ( | ||
468 | port->read_urb, | ||
469 | port->serial->dev, | ||
470 | usb_rcvbulkpipe(port->serial->dev, | ||
471 | port->bulk_in_endpointAddress), | ||
472 | port->read_urb->transfer_buffer, | ||
473 | port->read_urb->transfer_buffer_length, | ||
474 | ir_read_bulk_callback, | ||
475 | port); | ||
476 | |||
477 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | ||
478 | if (result) | ||
479 | dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", | ||
480 | __func__, result); | ||
481 | |||
482 | break ; | ||
483 | |||
484 | default: | ||
485 | dbg("%s - nonzero read bulk status received: %d", | ||
486 | __func__, | ||
487 | status); | ||
488 | break ; | ||
489 | 483 | ||
484 | /* | ||
485 | * No break here. | ||
486 | * We want to resubmit the urb so we can read | ||
487 | * again. | ||
488 | */ | ||
489 | |||
490 | case -EPROTO: /* taking inspiration from pl2303.c */ | ||
491 | |||
492 | /* Continue trying to always read */ | ||
493 | usb_fill_bulk_urb( | ||
494 | port->read_urb, | ||
495 | port->serial->dev, | ||
496 | usb_rcvbulkpipe(port->serial->dev, | ||
497 | port->bulk_in_endpointAddress), | ||
498 | port->read_urb->transfer_buffer, | ||
499 | port->read_urb->transfer_buffer_length, | ||
500 | ir_read_bulk_callback, | ||
501 | port); | ||
502 | |||
503 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | ||
504 | if (result) | ||
505 | dev_err(&port->dev, | ||
506 | "%s - failed resubmitting read urb, error %d\n", | ||
507 | __func__, result); | ||
508 | break; | ||
509 | |||
510 | default: | ||
511 | dbg("%s - nonzero read bulk status received: %d", | ||
512 | __func__, | ||
513 | status); | ||
514 | break; | ||
490 | } | 515 | } |
491 | 516 | ||
492 | return; | 517 | return; |
493 | } | 518 | } |
494 | 519 | ||
495 | static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) | 520 | static void ir_set_termios(struct usb_serial_port *port, |
521 | struct ktermios *old_termios) | ||
496 | { | 522 | { |
497 | unsigned char *transfer_buffer; | 523 | unsigned char *transfer_buffer; |
498 | int result; | 524 | int result; |
@@ -510,19 +536,36 @@ static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_t | |||
510 | */ | 536 | */ |
511 | 537 | ||
512 | switch (baud) { | 538 | switch (baud) { |
513 | case 2400: ir_baud = SPEED_2400; break; | 539 | case 2400: |
514 | case 9600: ir_baud = SPEED_9600; break; | 540 | ir_baud = USB_IRDA_BR_2400; |
515 | case 19200: ir_baud = SPEED_19200; break; | 541 | break; |
516 | case 38400: ir_baud = SPEED_38400; break; | 542 | case 9600: |
517 | case 57600: ir_baud = SPEED_57600; break; | 543 | ir_baud = USB_IRDA_BR_9600; |
518 | case 115200: ir_baud = SPEED_115200; break; | 544 | break; |
519 | case 576000: ir_baud = SPEED_576000; break; | 545 | case 19200: |
520 | case 1152000: ir_baud = SPEED_1152000; break; | 546 | ir_baud = USB_IRDA_BR_19200; |
521 | case 4000000: ir_baud = SPEED_4000000; break; | 547 | break; |
522 | break; | 548 | case 38400: |
523 | default: | 549 | ir_baud = USB_IRDA_BR_38400; |
524 | ir_baud = SPEED_9600; | 550 | break; |
525 | baud = 9600; | 551 | case 57600: |
552 | ir_baud = USB_IRDA_BR_57600; | ||
553 | break; | ||
554 | case 115200: | ||
555 | ir_baud = USB_IRDA_BR_115200; | ||
556 | break; | ||
557 | case 576000: | ||
558 | ir_baud = USB_IRDA_BR_576000; | ||
559 | break; | ||
560 | case 1152000: | ||
561 | ir_baud = USB_IRDA_BR_1152000; | ||
562 | break; | ||
563 | case 4000000: | ||
564 | ir_baud = USB_IRDA_BR_4000000; | ||
565 | break; | ||
566 | default: | ||
567 | ir_baud = USB_IRDA_BR_9600; | ||
568 | baud = 9600; | ||
526 | } | 569 | } |
527 | 570 | ||
528 | if (xbof == -1) | 571 | if (xbof == -1) |
@@ -538,10 +581,11 @@ static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_t | |||
538 | transfer_buffer = port->write_urb->transfer_buffer; | 581 | transfer_buffer = port->write_urb->transfer_buffer; |
539 | *transfer_buffer = ir_xbof | ir_baud; | 582 | *transfer_buffer = ir_xbof | ir_baud; |
540 | 583 | ||
541 | usb_fill_bulk_urb ( | 584 | usb_fill_bulk_urb( |
542 | port->write_urb, | 585 | port->write_urb, |
543 | port->serial->dev, | 586 | port->serial->dev, |
544 | usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress), | 587 | usb_sndbulkpipe(port->serial->dev, |
588 | port->bulk_out_endpointAddress), | ||
545 | port->write_urb->transfer_buffer, | 589 | port->write_urb->transfer_buffer, |
546 | 1, | 590 | 1, |
547 | ir_write_bulk_callback, | 591 | ir_write_bulk_callback, |
@@ -549,38 +593,44 @@ static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_t | |||
549 | 593 | ||
550 | port->write_urb->transfer_flags = URB_ZERO_PACKET; | 594 | port->write_urb->transfer_flags = URB_ZERO_PACKET; |
551 | 595 | ||
552 | result = usb_submit_urb (port->write_urb, GFP_KERNEL); | 596 | result = usb_submit_urb(port->write_urb, GFP_KERNEL); |
553 | if (result) | 597 | if (result) |
554 | dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, result); | 598 | dev_err(&port->dev, |
599 | "%s - failed submitting write urb, error %d\n", | ||
600 | __func__, result); | ||
555 | 601 | ||
556 | /* Only speed changes are supported */ | 602 | /* Only speed changes are supported */ |
557 | tty_termios_copy_hw(port->tty->termios, old_termios); | 603 | tty_termios_copy_hw(port->tty->termios, old_termios); |
558 | tty_encode_baud_rate(port->tty, baud, baud); | 604 | tty_encode_baud_rate(port->tty, baud, baud); |
559 | } | 605 | } |
560 | 606 | ||
561 | 607 | static int __init ir_init(void) | |
562 | static int __init ir_init (void) | ||
563 | { | 608 | { |
564 | int retval; | 609 | int retval; |
610 | |||
565 | retval = usb_serial_register(&ir_device); | 611 | retval = usb_serial_register(&ir_device); |
566 | if (retval) | 612 | if (retval) |
567 | goto failed_usb_serial_register; | 613 | goto failed_usb_serial_register; |
614 | |||
568 | retval = usb_register(&ir_driver); | 615 | retval = usb_register(&ir_driver); |
569 | if (retval) | 616 | if (retval) |
570 | goto failed_usb_register; | 617 | goto failed_usb_register; |
618 | |||
571 | info(DRIVER_DESC " " DRIVER_VERSION); | 619 | info(DRIVER_DESC " " DRIVER_VERSION); |
620 | |||
572 | return 0; | 621 | return 0; |
622 | |||
573 | failed_usb_register: | 623 | failed_usb_register: |
574 | usb_serial_deregister(&ir_device); | 624 | usb_serial_deregister(&ir_device); |
625 | |||
575 | failed_usb_serial_register: | 626 | failed_usb_serial_register: |
576 | return retval; | 627 | return retval; |
577 | } | 628 | } |
578 | 629 | ||
579 | 630 | static void __exit ir_exit(void) | |
580 | static void __exit ir_exit (void) | ||
581 | { | 631 | { |
582 | usb_deregister (&ir_driver); | 632 | usb_deregister(&ir_driver); |
583 | usb_serial_deregister (&ir_device); | 633 | usb_serial_deregister(&ir_device); |
584 | } | 634 | } |
585 | 635 | ||
586 | 636 | ||
diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h index b52fb657a244..8bf72639b148 100644 --- a/drivers/usb/serial/keyspan.h +++ b/drivers/usb/serial/keyspan.h | |||
@@ -138,7 +138,8 @@ static int keyspan_usa67_send_setup (struct usb_serial *serial, | |||
138 | 138 | ||
139 | /* Product IDs post-renumeration. Note that the 28x and 28xb | 139 | /* Product IDs post-renumeration. Note that the 28x and 28xb |
140 | have the same id's post-renumeration but behave identically | 140 | have the same id's post-renumeration but behave identically |
141 | so it's not an issue. */ | 141 | so it's not an issue. As such, the 28xb is not listed in any |
142 | of the device tables. */ | ||
142 | #define keyspan_usa18x_product_id 0x0112 | 143 | #define keyspan_usa18x_product_id 0x0112 |
143 | #define keyspan_usa19_product_id 0x0107 | 144 | #define keyspan_usa19_product_id 0x0107 |
144 | #define keyspan_usa19qi_product_id 0x010c | 145 | #define keyspan_usa19qi_product_id 0x010c |
@@ -482,7 +483,6 @@ static struct usb_device_id keyspan_ids_combined[] = { | |||
482 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_product_id) }, | 483 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_product_id) }, |
483 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_product_id) }, | 484 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_product_id) }, |
484 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_product_id) }, | 485 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_product_id) }, |
485 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xb_product_id) }, | ||
486 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xg_product_id) }, | 486 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xg_product_id) }, |
487 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_product_id)}, | 487 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_product_id)}, |
488 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_product_id)}, | 488 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_product_id)}, |
@@ -532,7 +532,6 @@ static struct usb_device_id keyspan_2port_ids[] = { | |||
532 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_product_id) }, | 532 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_product_id) }, |
533 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_product_id) }, | 533 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_product_id) }, |
534 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_product_id) }, | 534 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_product_id) }, |
535 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xb_product_id) }, | ||
536 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xg_product_id) }, | 535 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xg_product_id) }, |
537 | { } /* Terminating entry */ | 536 | { } /* Terminating entry */ |
538 | }; | 537 | }; |
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index 644a1eaaa376..60b3e22bd633 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c | |||
@@ -408,7 +408,7 @@ static int keyspan_pda_get_modem_info(struct usb_serial *serial, | |||
408 | 3, /* get pins */ | 408 | 3, /* get pins */ |
409 | USB_TYPE_VENDOR|USB_RECIP_INTERFACE|USB_DIR_IN, | 409 | USB_TYPE_VENDOR|USB_RECIP_INTERFACE|USB_DIR_IN, |
410 | 0, 0, &data, 1, 2000); | 410 | 0, 0, &data, 1, 2000); |
411 | if (rc > 0) | 411 | if (rc >= 0) |
412 | *value = data; | 412 | *value = data; |
413 | return rc; | 413 | return rc; |
414 | } | 414 | } |
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index f328948d74e3..79787eda9524 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c | |||
@@ -236,7 +236,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, | |||
236 | if (rc < 0) | 236 | if (rc < 0) |
237 | err("Reading line status failed (error = %d)", rc); | 237 | err("Reading line status failed (error = %d)", rc); |
238 | else { | 238 | else { |
239 | status = le16_to_cpu(get_unaligned((__le16 *)status_buf)); | 239 | status = get_unaligned_le16(status_buf); |
240 | 240 | ||
241 | info("%s - read status %x %x", __func__, | 241 | info("%s - read status %x %x", __func__, |
242 | status_buf[0], status_buf[1]); | 242 | status_buf[0], status_buf[1]); |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index a73420dd052a..1e936a1cbe0b 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -173,6 +173,7 @@ static int option_send_setup(struct usb_serial_port *port); | |||
173 | #define DELL_VENDOR_ID 0x413C | 173 | #define DELL_VENDOR_ID 0x413C |
174 | 174 | ||
175 | #define KYOCERA_VENDOR_ID 0x0c88 | 175 | #define KYOCERA_VENDOR_ID 0x0c88 |
176 | #define KYOCERA_PRODUCT_KPC650 0x17da | ||
176 | #define KYOCERA_PRODUCT_KPC680 0x180a | 177 | #define KYOCERA_PRODUCT_KPC680 0x180a |
177 | 178 | ||
178 | #define ANYDATA_VENDOR_ID 0x16d5 | 179 | #define ANYDATA_VENDOR_ID 0x16d5 |
@@ -305,6 +306,7 @@ static struct usb_device_id option_ids[] = { | |||
305 | { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_ET502HS) }, | 306 | { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_ET502HS) }, |
306 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, | 307 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, |
307 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, | 308 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, |
309 | { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) }, | ||
308 | { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, | 310 | { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, |
309 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */ | 311 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */ |
310 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ | 312 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ |
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 0cb0d77dc429..353798631903 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -283,7 +283,10 @@ static void serial_close(struct tty_struct *tty, struct file * filp) | |||
283 | } | 283 | } |
284 | 284 | ||
285 | if (port->open_count == 0) { | 285 | if (port->open_count == 0) { |
286 | usb_autopm_put_interface(port->serial->interface); | 286 | mutex_lock(&port->serial->disc_mutex); |
287 | if (!port->serial->disconnected) | ||
288 | usb_autopm_put_interface(port->serial->interface); | ||
289 | mutex_unlock(&port->serial->disc_mutex); | ||
287 | module_put(port->serial->type->driver.owner); | 290 | module_put(port->serial->type->driver.owner); |
288 | } | 291 | } |
289 | 292 | ||
@@ -505,7 +508,7 @@ static void port_release(struct device *dev) | |||
505 | { | 508 | { |
506 | struct usb_serial_port *port = to_usb_serial_port(dev); | 509 | struct usb_serial_port *port = to_usb_serial_port(dev); |
507 | 510 | ||
508 | dbg ("%s - %s", __func__, dev->bus_id); | 511 | dbg ("%s - %s", __func__, dev_name(dev)); |
509 | port_free(port); | 512 | port_free(port); |
510 | } | 513 | } |
511 | 514 | ||
@@ -625,7 +628,7 @@ int usb_serial_probe(struct usb_interface *interface, | |||
625 | struct usb_endpoint_descriptor *bulk_out_endpoint[MAX_NUM_PORTS]; | 628 | struct usb_endpoint_descriptor *bulk_out_endpoint[MAX_NUM_PORTS]; |
626 | struct usb_serial_driver *type = NULL; | 629 | struct usb_serial_driver *type = NULL; |
627 | int retval; | 630 | int retval; |
628 | int minor; | 631 | unsigned int minor; |
629 | int buffer_size; | 632 | int buffer_size; |
630 | int i; | 633 | int i; |
631 | int num_interrupt_in = 0; | 634 | int num_interrupt_in = 0; |
@@ -938,8 +941,8 @@ int usb_serial_probe(struct usb_interface *interface, | |||
938 | port->dev.bus = &usb_serial_bus_type; | 941 | port->dev.bus = &usb_serial_bus_type; |
939 | port->dev.release = &port_release; | 942 | port->dev.release = &port_release; |
940 | 943 | ||
941 | snprintf (&port->dev.bus_id[0], sizeof(port->dev.bus_id), "ttyUSB%d", port->number); | 944 | dev_set_name(&port->dev, "ttyUSB%d", port->number); |
942 | dbg ("%s - registering %s", __func__, port->dev.bus_id); | 945 | dbg ("%s - registering %s", __func__, dev_name(&port->dev)); |
943 | retval = device_register(&port->dev); | 946 | retval = device_register(&port->dev); |
944 | if (retval) | 947 | if (retval) |
945 | dev_err(&port->dev, "Error registering port device, " | 948 | dev_err(&port->dev, "Error registering port device, " |
diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c index f9fc926b56d8..9ca4d4db1ddd 100644 --- a/drivers/usb/serial/usb_debug.c +++ b/drivers/usb/serial/usb_debug.c | |||
@@ -15,6 +15,8 @@ | |||
15 | #include <linux/usb.h> | 15 | #include <linux/usb.h> |
16 | #include <linux/usb/serial.h> | 16 | #include <linux/usb/serial.h> |
17 | 17 | ||
18 | #define USB_DEBUG_MAX_PACKET_SIZE 8 | ||
19 | |||
18 | static struct usb_device_id id_table [] = { | 20 | static struct usb_device_id id_table [] = { |
19 | { USB_DEVICE(0x0525, 0x127a) }, | 21 | { USB_DEVICE(0x0525, 0x127a) }, |
20 | { }, | 22 | { }, |
@@ -29,6 +31,12 @@ static struct usb_driver debug_driver = { | |||
29 | .no_dynamic_id = 1, | 31 | .no_dynamic_id = 1, |
30 | }; | 32 | }; |
31 | 33 | ||
34 | int usb_debug_open(struct usb_serial_port *port, struct file *filp) | ||
35 | { | ||
36 | port->bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE; | ||
37 | return usb_serial_generic_open(port, filp); | ||
38 | } | ||
39 | |||
32 | static struct usb_serial_driver debug_device = { | 40 | static struct usb_serial_driver debug_device = { |
33 | .driver = { | 41 | .driver = { |
34 | .owner = THIS_MODULE, | 42 | .owner = THIS_MODULE, |
@@ -36,6 +44,7 @@ static struct usb_serial_driver debug_device = { | |||
36 | }, | 44 | }, |
37 | .id_table = id_table, | 45 | .id_table = id_table, |
38 | .num_ports = 1, | 46 | .num_ports = 1, |
47 | .open = usb_debug_open, | ||
39 | }; | 48 | }; |
40 | 49 | ||
41 | static int __init debug_init(void) | 50 | static int __init debug_init(void) |