]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/usb/serial/iuu_phoenix.c
Merge tag 'spi-v4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
[mirror_ubuntu-artful-kernel.git] / drivers / usb / serial / iuu_phoenix.c
CommitLineData
60a8fc01
AD
1/*
2 * Infinity Unlimited USB Phoenix driver
3 *
89b54397
JCD
4 * Copyright (C) 2010 James Courtier-Dutton (James@superbug.co.uk)
5
60a8fc01
AD
6 * Copyright (C) 2007 Alain Degreffe (eczema@ecze.com)
7 *
8 * Original code taken from iuutool (Copyright (C) 2006 Juan Carlos Borrás)
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * And tested with help of WB Electronics
16 *
17 */
18#include <linux/kernel.h>
19#include <linux/errno.h>
60a8fc01
AD
20#include <linux/slab.h>
21#include <linux/tty.h>
22#include <linux/tty_driver.h>
23#include <linux/tty_flip.h>
24#include <linux/serial.h>
25#include <linux/module.h>
26#include <linux/moduleparam.h>
27#include <linux/spinlock.h>
28#include <linux/uaccess.h>
29#include <linux/usb.h>
30#include <linux/usb/serial.h>
31#include "iuu_phoenix.h"
32#include <linux/random.h>
33
60a8fc01
AD
34#define DRIVER_DESC "Infinity USB Unlimited Phoenix driver"
35
7d40d7e8 36static const struct usb_device_id id_table[] = {
60a8fc01
AD
37 {USB_DEVICE(IUU_USB_VENDOR_ID, IUU_USB_PRODUCT_ID)},
38 {} /* Terminating entry */
39};
40MODULE_DEVICE_TABLE(usb, id_table);
41
60a8fc01
AD
42/* turbo parameter */
43static int boost = 100;
44static int clockmode = 1;
45static int cdmode = 1;
46static int iuu_cardin;
47static int iuu_cardout;
90ab5ee9 48static bool xmas;
e55c6d06 49static int vcc_default = 5;
60a8fc01 50
0978c949
JH
51static int iuu_create_sysfs_attrs(struct usb_serial_port *port);
52static int iuu_remove_sysfs_attrs(struct usb_serial_port *port);
60a8fc01
AD
53static void read_rxcmd_callback(struct urb *urb);
54
55struct iuu_private {
56 spinlock_t lock; /* store irq state */
60a8fc01 57 u8 line_status;
60a8fc01
AD
58 int tiostatus; /* store IUART SIGNAL for tiocmget call */
59 u8 reset; /* if 1 reset is needed */
60 int poll; /* number of poll */
61 u8 *writebuf; /* buffer for writing to device */
62 int writelen; /* num of byte to write to device */
63 u8 *buf; /* used for initialize speed */
60a8fc01 64 u8 len;
20eda943 65 int vcc; /* vcc (either 3 or 5 V) */
89b54397
JCD
66 u32 baud;
67 u32 boost;
68 u32 clk;
60a8fc01
AD
69};
70
90507d54
JH
71static int iuu_attach(struct usb_serial *serial)
72{
73 unsigned char num_ports = serial->num_ports;
74
75 if (serial->num_bulk_in < num_ports || serial->num_bulk_out < num_ports)
76 return -ENODEV;
77
78 return 0;
79}
80
53636555 81static int iuu_port_probe(struct usb_serial_port *port)
60a8fc01
AD
82{
83 struct iuu_private *priv;
0978c949 84 int ret;
2621cee1 85
60a8fc01 86 priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL);
60a8fc01
AD
87 if (!priv)
88 return -ENOMEM;
53636555
JH
89
90 priv->buf = kzalloc(256, GFP_KERNEL);
91 if (!priv->buf) {
60a8fc01
AD
92 kfree(priv);
93 return -ENOMEM;
94 }
53636555
JH
95
96 priv->writebuf = kzalloc(256, GFP_KERNEL);
97 if (!priv->writebuf) {
98 kfree(priv->buf);
99 kfree(priv);
100 return -ENOMEM;
101 }
102
e55c6d06 103 priv->vcc = vcc_default;
60a8fc01 104 spin_lock_init(&priv->lock);
53636555
JH
105
106 usb_set_serial_port_data(port, priv);
107
0978c949
JH
108 ret = iuu_create_sysfs_attrs(port);
109 if (ret) {
110 kfree(priv->writebuf);
111 kfree(priv->buf);
112 kfree(priv);
113 return ret;
114 }
115
60a8fc01
AD
116 return 0;
117}
118
53636555 119static int iuu_port_remove(struct usb_serial_port *port)
60a8fc01 120{
60a8fc01 121 struct iuu_private *priv = usb_get_serial_port_data(port);
60a8fc01 122
0978c949 123 iuu_remove_sysfs_attrs(port);
53636555
JH
124 kfree(priv->writebuf);
125 kfree(priv->buf);
126 kfree(priv);
60a8fc01 127
53636555 128 return 0;
60a8fc01
AD
129}
130
20b9d177 131static int iuu_tiocmset(struct tty_struct *tty,
60a8fc01
AD
132 unsigned int set, unsigned int clear)
133{
95da310e 134 struct usb_serial_port *port = tty->driver_data;
60a8fc01 135 struct iuu_private *priv = usb_get_serial_port_data(port);
7b1fc8bc 136 unsigned long flags;
60a8fc01 137
7b1fc8bc 138 /* FIXME: locking on tiomstatus */
2621cee1
GKH
139 dev_dbg(&port->dev, "%s msg : SET = 0x%04x, CLEAR = 0x%04x\n",
140 __func__, set, clear);
7b1fc8bc
AC
141
142 spin_lock_irqsave(&priv->lock, flags);
60a8fc01 143
89b54397 144 if ((set & TIOCM_RTS) && !(priv->tiostatus == TIOCM_RTS)) {
2621cee1 145 dev_dbg(&port->dev, "%s TIOCMSET RESET called !!!\n", __func__);
60a8fc01 146 priv->reset = 1;
60a8fc01 147 }
89b54397
JCD
148 if (set & TIOCM_RTS)
149 priv->tiostatus = TIOCM_RTS;
150
7b1fc8bc 151 spin_unlock_irqrestore(&priv->lock, flags);
60a8fc01
AD
152 return 0;
153}
154
155/* This is used to provide a carrier detect mechanism
156 * When a card is present, the response is 0x00
157 * When no card , the reader respond with TIOCM_CD
158 * This is known as CD autodetect mechanism
159 */
60b33c13 160static int iuu_tiocmget(struct tty_struct *tty)
60a8fc01 161{
95da310e 162 struct usb_serial_port *port = tty->driver_data;
60a8fc01 163 struct iuu_private *priv = usb_get_serial_port_data(port);
7b1fc8bc
AC
164 unsigned long flags;
165 int rc;
166
167 spin_lock_irqsave(&priv->lock, flags);
168 rc = priv->tiostatus;
169 spin_unlock_irqrestore(&priv->lock, flags);
170
171 return rc;
60a8fc01
AD
172}
173
174static void iuu_rxcmd(struct urb *urb)
175{
cdc97792 176 struct usb_serial_port *port = urb->context;
60a8fc01 177 int result;
50de36f7
GKH
178 int status = urb->status;
179
50de36f7 180 if (status) {
2621cee1 181 dev_dbg(&port->dev, "%s - status = %d\n", __func__, status);
60a8fc01
AD
182 /* error stop all */
183 return;
184 }
185
186
187 memset(port->write_urb->transfer_buffer, IUU_UART_RX, 1);
188 usb_fill_bulk_urb(port->write_urb, port->serial->dev,
189 usb_sndbulkpipe(port->serial->dev,
190 port->bulk_out_endpointAddress),
191 port->write_urb->transfer_buffer, 1,
192 read_rxcmd_callback, port);
193 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
194}
195
196static int iuu_reset(struct usb_serial_port *port, u8 wt)
197{
198 struct iuu_private *priv = usb_get_serial_port_data(port);
199 int result;
200 char *buf_ptr = port->write_urb->transfer_buffer;
60a8fc01
AD
201
202 /* Prepare the reset sequence */
203
204 *buf_ptr++ = IUU_RST_SET;
205 *buf_ptr++ = IUU_DELAY_MS;
206 *buf_ptr++ = wt;
207 *buf_ptr = IUU_RST_CLEAR;
208
209 /* send the sequence */
210
211 usb_fill_bulk_urb(port->write_urb,
212 port->serial->dev,
213 usb_sndbulkpipe(port->serial->dev,
214 port->bulk_out_endpointAddress),
215 port->write_urb->transfer_buffer, 4, iuu_rxcmd, port);
216 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
217 priv->reset = 0;
218 return result;
219}
220
221/* Status Function
222 * Return value is
223 * 0x00 = no card
224 * 0x01 = smartcard
225 * 0x02 = sim card
226 */
227static void iuu_update_status_callback(struct urb *urb)
228{
cdc97792 229 struct usb_serial_port *port = urb->context;
60a8fc01
AD
230 struct iuu_private *priv = usb_get_serial_port_data(port);
231 u8 *st;
50de36f7
GKH
232 int status = urb->status;
233
50de36f7 234 if (status) {
2621cee1 235 dev_dbg(&port->dev, "%s - status = %d\n", __func__, status);
60a8fc01
AD
236 /* error stop all */
237 return;
238 }
239
240 st = urb->transfer_buffer;
2621cee1 241 dev_dbg(&port->dev, "%s - enter\n", __func__);
60a8fc01
AD
242 if (urb->actual_length == 1) {
243 switch (st[0]) {
244 case 0x1:
245 priv->tiostatus = iuu_cardout;
246 break;
247 case 0x0:
248 priv->tiostatus = iuu_cardin;
249 break;
250 default:
251 priv->tiostatus = iuu_cardin;
252 }
253 }
254 iuu_rxcmd(urb);
255}
256
257static void iuu_status_callback(struct urb *urb)
258{
cdc97792 259 struct usb_serial_port *port = urb->context;
60a8fc01 260 int result;
50de36f7 261 int status = urb->status;
60a8fc01 262
2621cee1 263 dev_dbg(&port->dev, "%s - status = %d\n", __func__, status);
60a8fc01
AD
264 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
265 usb_rcvbulkpipe(port->serial->dev,
266 port->bulk_in_endpointAddress),
267 port->read_urb->transfer_buffer, 256,
268 iuu_update_status_callback, port);
269 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
270}
271
272static int iuu_status(struct usb_serial_port *port)
273{
274 int result;
275
60a8fc01
AD
276 memset(port->write_urb->transfer_buffer, IUU_GET_STATE_REGISTER, 1);
277 usb_fill_bulk_urb(port->write_urb, port->serial->dev,
278 usb_sndbulkpipe(port->serial->dev,
279 port->bulk_out_endpointAddress),
280 port->write_urb->transfer_buffer, 1,
281 iuu_status_callback, port);
282 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
283 return result;
284
285}
286
287static int bulk_immediate(struct usb_serial_port *port, u8 *buf, u8 count)
288{
289 int status;
290 struct usb_serial *serial = port->serial;
291 int actual = 0;
292
60a8fc01
AD
293 /* send the data out the bulk port */
294
295 status =
296 usb_bulk_msg(serial->dev,
297 usb_sndbulkpipe(serial->dev,
298 port->bulk_out_endpointAddress), buf,
6c13ff68 299 count, &actual, 1000);
60a8fc01 300
9e8e2d2a 301 if (status != IUU_OPERATION_OK)
2621cee1 302 dev_dbg(&port->dev, "%s - error = %2x\n", __func__, status);
9e8e2d2a 303 else
2621cee1 304 dev_dbg(&port->dev, "%s - write OK !\n", __func__);
60a8fc01
AD
305 return status;
306}
307
308static int read_immediate(struct usb_serial_port *port, u8 *buf, u8 count)
309{
310 int status;
311 struct usb_serial *serial = port->serial;
312 int actual = 0;
313
60a8fc01 314 /* send the data out the bulk port */
60a8fc01
AD
315 status =
316 usb_bulk_msg(serial->dev,
317 usb_rcvbulkpipe(serial->dev,
318 port->bulk_in_endpointAddress), buf,
6c13ff68 319 count, &actual, 1000);
60a8fc01 320
9e8e2d2a 321 if (status != IUU_OPERATION_OK)
2621cee1 322 dev_dbg(&port->dev, "%s - error = %2x\n", __func__, status);
9e8e2d2a 323 else
2621cee1 324 dev_dbg(&port->dev, "%s - read OK !\n", __func__);
60a8fc01
AD
325 return status;
326}
327
328static int iuu_led(struct usb_serial_port *port, unsigned int R,
329 unsigned int G, unsigned int B, u8 f)
330{
331 int status;
332 u8 *buf;
333 buf = kmalloc(8, GFP_KERNEL);
334 if (!buf)
335 return -ENOMEM;
336
60a8fc01
AD
337 buf[0] = IUU_SET_LED;
338 buf[1] = R & 0xFF;
339 buf[2] = (R >> 8) & 0xFF;
340 buf[3] = G & 0xFF;
341 buf[4] = (G >> 8) & 0xFF;
342 buf[5] = B & 0xFF;
343 buf[6] = (B >> 8) & 0xFF;
344 buf[7] = f;
345 status = bulk_immediate(port, buf, 8);
346 kfree(buf);
347 if (status != IUU_OPERATION_OK)
2621cee1 348 dev_dbg(&port->dev, "%s - led error status = %2x\n", __func__, status);
60a8fc01 349 else
2621cee1 350 dev_dbg(&port->dev, "%s - led OK !\n", __func__);
60a8fc01
AD
351 return IUU_OPERATION_OK;
352}
353
354static void iuu_rgbf_fill_buffer(u8 *buf, u8 r1, u8 r2, u8 g1, u8 g2, u8 b1,
355 u8 b2, u8 freq)
356{
357 *buf++ = IUU_SET_LED;
358 *buf++ = r1;
359 *buf++ = r2;
360 *buf++ = g1;
361 *buf++ = g2;
362 *buf++ = b1;
363 *buf++ = b2;
364 *buf = freq;
365}
366
367static void iuu_led_activity_on(struct urb *urb)
368{
cdc97792 369 struct usb_serial_port *port = urb->context;
60a8fc01
AD
370 int result;
371 char *buf_ptr = port->write_urb->transfer_buffer;
372 *buf_ptr++ = IUU_SET_LED;
ce9d8562 373 if (xmas) {
60a8fc01
AD
374 get_random_bytes(buf_ptr, 6);
375 *(buf_ptr+7) = 1;
376 } else {
377 iuu_rgbf_fill_buffer(buf_ptr, 255, 255, 0, 0, 0, 0, 255);
378 }
379
380 usb_fill_bulk_urb(port->write_urb, port->serial->dev,
381 usb_sndbulkpipe(port->serial->dev,
382 port->bulk_out_endpointAddress),
383 port->write_urb->transfer_buffer, 8 ,
384 iuu_rxcmd, port);
385 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
386}
387
388static void iuu_led_activity_off(struct urb *urb)
389{
cdc97792 390 struct usb_serial_port *port = urb->context;
60a8fc01
AD
391 int result;
392 char *buf_ptr = port->write_urb->transfer_buffer;
ce9d8562 393 if (xmas) {
60a8fc01
AD
394 iuu_rxcmd(urb);
395 return;
396 } else {
397 *buf_ptr++ = IUU_SET_LED;
398 iuu_rgbf_fill_buffer(buf_ptr, 0, 0, 255, 255, 0, 0, 255);
399 }
400 usb_fill_bulk_urb(port->write_urb, port->serial->dev,
401 usb_sndbulkpipe(port->serial->dev,
402 port->bulk_out_endpointAddress),
403 port->write_urb->transfer_buffer, 8 ,
404 iuu_rxcmd, port);
405 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
406}
407
408
409
410static int iuu_clk(struct usb_serial_port *port, int dwFrq)
411{
412 int status;
413 struct iuu_private *priv = usb_get_serial_port_data(port);
414 int Count = 0;
415 u8 FrqGenAdr = 0x69;
416 u8 DIV = 0; /* 8bit */
417 u8 XDRV = 0; /* 8bit */
418 u8 PUMP = 0; /* 3bit */
419 u8 PBmsb = 0; /* 2bit */
420 u8 PBlsb = 0; /* 8bit */
421 u8 PO = 0; /* 1bit */
422 u8 Q = 0; /* 7bit */
423 /* 24bit = 3bytes */
424 unsigned int P = 0;
425 unsigned int P2 = 0;
426 int frq = (int)dwFrq;
427
60a8fc01
AD
428 if (frq == 0) {
429 priv->buf[Count++] = IUU_UART_WRITE_I2C;
430 priv->buf[Count++] = FrqGenAdr << 1;
431 priv->buf[Count++] = 0x09;
432 priv->buf[Count++] = 0x00;
433
434 status = bulk_immediate(port, (u8 *) priv->buf, Count);
435 if (status != 0) {
2621cee1 436 dev_dbg(&port->dev, "%s - write error\n", __func__);
60a8fc01
AD
437 return status;
438 }
439 } else if (frq == 3579000) {
440 DIV = 100;
441 P = 1193;
442 Q = 40;
443 XDRV = 0;
444 } else if (frq == 3680000) {
445 DIV = 105;
446 P = 161;
447 Q = 5;
448 XDRV = 0;
449 } else if (frq == 6000000) {
450 DIV = 66;
451 P = 66;
452 Q = 2;
453 XDRV = 0x28;
454 } else {
455 unsigned int result = 0;
456 unsigned int tmp = 0;
457 unsigned int check;
458 unsigned int check2;
459 char found = 0x00;
460 unsigned int lQ = 2;
461 unsigned int lP = 2055;
462 unsigned int lDiv = 4;
463
464 for (lQ = 2; lQ <= 47 && !found; lQ++)
465 for (lP = 2055; lP >= 8 && !found; lP--)
466 for (lDiv = 4; lDiv <= 127 && !found; lDiv++) {
467 tmp = (12000000 / lDiv) * (lP / lQ);
468 if (abs((int)(tmp - frq)) <
469 abs((int)(frq - result))) {
470 check2 = (12000000 / lQ);
471 if (check2 < 250000)
472 continue;
473 check = (12000000 / lQ) * lP;
474 if (check > 400000000)
475 continue;
476 if (check < 100000000)
477 continue;
478 if (lDiv < 4 || lDiv > 127)
479 continue;
480 result = tmp;
481 P = lP;
482 DIV = lDiv;
483 Q = lQ;
484 if (result == frq)
485 found = 0x01;
486 }
487 }
488 }
489 P2 = ((P - PO) / 2) - 4;
490 DIV = DIV;
491 PUMP = 0x04;
492 PBmsb = (P2 >> 8 & 0x03);
493 PBlsb = P2 & 0xFF;
494 PO = (P >> 10) & 0x01;
495 Q = Q - 2;
496
497 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
498 priv->buf[Count++] = FrqGenAdr << 1;
499 priv->buf[Count++] = 0x09;
500 priv->buf[Count++] = 0x20; /* Adr = 0x09 */
501 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
502 priv->buf[Count++] = FrqGenAdr << 1;
503 priv->buf[Count++] = 0x0C;
504 priv->buf[Count++] = DIV; /* Adr = 0x0C */
505 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
506 priv->buf[Count++] = FrqGenAdr << 1;
507 priv->buf[Count++] = 0x12;
508 priv->buf[Count++] = XDRV; /* Adr = 0x12 */
509 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
510 priv->buf[Count++] = FrqGenAdr << 1;
511 priv->buf[Count++] = 0x13;
512 priv->buf[Count++] = 0x6B; /* Adr = 0x13 */
513 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
514 priv->buf[Count++] = FrqGenAdr << 1;
515 priv->buf[Count++] = 0x40;
516 priv->buf[Count++] = (0xC0 | ((PUMP & 0x07) << 2)) |
517 (PBmsb & 0x03); /* Adr = 0x40 */
518 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
519 priv->buf[Count++] = FrqGenAdr << 1;
520 priv->buf[Count++] = 0x41;
521 priv->buf[Count++] = PBlsb; /* Adr = 0x41 */
522 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
523 priv->buf[Count++] = FrqGenAdr << 1;
524 priv->buf[Count++] = 0x42;
525 priv->buf[Count++] = Q | (((PO & 0x01) << 7)); /* Adr = 0x42 */
526 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
527 priv->buf[Count++] = FrqGenAdr << 1;
528 priv->buf[Count++] = 0x44;
529 priv->buf[Count++] = (char)0xFF; /* Adr = 0x44 */
530 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
531 priv->buf[Count++] = FrqGenAdr << 1;
532 priv->buf[Count++] = 0x45;
533 priv->buf[Count++] = (char)0xFE; /* Adr = 0x45 */
534 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
535 priv->buf[Count++] = FrqGenAdr << 1;
536 priv->buf[Count++] = 0x46;
537 priv->buf[Count++] = 0x7F; /* Adr = 0x46 */
538 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
539 priv->buf[Count++] = FrqGenAdr << 1;
540 priv->buf[Count++] = 0x47;
541 priv->buf[Count++] = (char)0x84; /* Adr = 0x47 */
542
543 status = bulk_immediate(port, (u8 *) priv->buf, Count);
544 if (status != IUU_OPERATION_OK)
2621cee1 545 dev_dbg(&port->dev, "%s - write error\n", __func__);
60a8fc01
AD
546 return status;
547}
548
549static int iuu_uart_flush(struct usb_serial_port *port)
550{
2621cee1 551 struct device *dev = &port->dev;
60a8fc01
AD
552 int i;
553 int status;
554 u8 rxcmd = IUU_UART_RX;
555 struct iuu_private *priv = usb_get_serial_port_data(port);
556
60a8fc01
AD
557 if (iuu_led(port, 0xF000, 0, 0, 0xFF) < 0)
558 return -EIO;
559
560 for (i = 0; i < 2; i++) {
561 status = bulk_immediate(port, &rxcmd, 1);
562 if (status != IUU_OPERATION_OK) {
2621cee1 563 dev_dbg(dev, "%s - uart_flush_write error\n", __func__);
60a8fc01
AD
564 return status;
565 }
566
567 status = read_immediate(port, &priv->len, 1);
568 if (status != IUU_OPERATION_OK) {
2621cee1 569 dev_dbg(dev, "%s - uart_flush_read error\n", __func__);
60a8fc01
AD
570 return status;
571 }
572
573 if (priv->len > 0) {
2621cee1 574 dev_dbg(dev, "%s - uart_flush datalen is : %i\n", __func__, priv->len);
60a8fc01
AD
575 status = read_immediate(port, priv->buf, priv->len);
576 if (status != IUU_OPERATION_OK) {
2621cee1 577 dev_dbg(dev, "%s - uart_flush_read error\n", __func__);
60a8fc01
AD
578 return status;
579 }
580 }
581 }
2621cee1 582 dev_dbg(dev, "%s - uart_flush_read OK!\n", __func__);
60a8fc01
AD
583 iuu_led(port, 0, 0xF000, 0, 0xFF);
584 return status;
585}
586
587static void read_buf_callback(struct urb *urb)
588{
cdc97792 589 struct usb_serial_port *port = urb->context;
60a8fc01 590 unsigned char *data = urb->transfer_buffer;
50de36f7 591 int status = urb->status;
60a8fc01 592
50de36f7
GKH
593 if (status) {
594 if (status == -EPROTO) {
60a8fc01
AD
595 /* reschedule needed */
596 }
597 return;
598 }
599
2621cee1 600 dev_dbg(&port->dev, "%s - %i chars to write\n", __func__, urb->actual_length);
60a8fc01 601 if (data == NULL)
2621cee1 602 dev_dbg(&port->dev, "%s - data is NULL !!!\n", __func__);
2e124b4a 603 if (urb->actual_length && data) {
05c7cd39 604 tty_insert_flip_string(&port->port, data, urb->actual_length);
2e124b4a 605 tty_flip_buffer_push(&port->port);
60a8fc01
AD
606 }
607 iuu_led_activity_on(urb);
608}
609
610static int iuu_bulk_write(struct usb_serial_port *port)
611{
612 struct iuu_private *priv = usb_get_serial_port_data(port);
8594303a 613 unsigned long flags;
60a8fc01 614 int result;
5fcf62b0 615 int buf_len;
60a8fc01 616 char *buf_ptr = port->write_urb->transfer_buffer;
60a8fc01 617
5fcf62b0 618 spin_lock_irqsave(&priv->lock, flags);
60a8fc01
AD
619 *buf_ptr++ = IUU_UART_ESC;
620 *buf_ptr++ = IUU_UART_TX;
621 *buf_ptr++ = priv->writelen;
622
5fcf62b0
OB
623 memcpy(buf_ptr, priv->writebuf, priv->writelen);
624 buf_len = priv->writelen;
625 priv->writelen = 0;
626 spin_unlock_irqrestore(&priv->lock, flags);
2621cee1
GKH
627 dev_dbg(&port->dev, "%s - writing %i chars : %*ph\n", __func__,
628 buf_len, buf_len, buf_ptr);
60a8fc01
AD
629 usb_fill_bulk_urb(port->write_urb, port->serial->dev,
630 usb_sndbulkpipe(port->serial->dev,
631 port->bulk_out_endpointAddress),
5fcf62b0 632 port->write_urb->transfer_buffer, buf_len + 3,
60a8fc01
AD
633 iuu_rxcmd, port);
634 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
60a8fc01
AD
635 usb_serial_port_softint(port);
636 return result;
637}
638
639static int iuu_read_buf(struct usb_serial_port *port, int len)
640{
641 int result;
60a8fc01
AD
642
643 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
644 usb_rcvbulkpipe(port->serial->dev,
645 port->bulk_in_endpointAddress),
646 port->read_urb->transfer_buffer, len,
647 read_buf_callback, port);
648 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
649 return result;
650}
651
652static void iuu_uart_read_callback(struct urb *urb)
653{
cdc97792 654 struct usb_serial_port *port = urb->context;
60a8fc01 655 struct iuu_private *priv = usb_get_serial_port_data(port);
8594303a 656 unsigned long flags;
50de36f7 657 int status = urb->status;
60a8fc01
AD
658 int error = 0;
659 int len = 0;
660 unsigned char *data = urb->transfer_buffer;
661 priv->poll++;
662
50de36f7 663 if (status) {
2621cee1 664 dev_dbg(&port->dev, "%s - status = %d\n", __func__, status);
60a8fc01
AD
665 /* error stop all */
666 return;
667 }
668 if (data == NULL)
2621cee1 669 dev_dbg(&port->dev, "%s - data is NULL !!!\n", __func__);
60a8fc01
AD
670
671 if (urb->actual_length == 1 && data != NULL)
672 len = (int) data[0];
673
674 if (urb->actual_length > 1) {
2621cee1 675 dev_dbg(&port->dev, "%s - urb->actual_length = %i\n", __func__,
60a8fc01
AD
676 urb->actual_length);
677 error = 1;
678 return;
679 }
680 /* if len > 0 call readbuf */
681
682 if (len > 0 && error == 0) {
2621cee1 683 dev_dbg(&port->dev, "%s - call read buf - len to read is %i\n",
441b62c1 684 __func__, len);
60a8fc01
AD
685 status = iuu_read_buf(port, len);
686 return;
687 }
688 /* need to update status ? */
689 if (priv->poll > 99) {
690 status = iuu_status(port);
691 priv->poll = 0;
692 return;
693 }
694
695 /* reset waiting ? */
696
697 if (priv->reset == 1) {
698 status = iuu_reset(port, 0xC);
699 return;
700 }
701 /* Writebuf is waiting */
702 spin_lock_irqsave(&priv->lock, flags);
703 if (priv->writelen > 0) {
704 spin_unlock_irqrestore(&priv->lock, flags);
705 status = iuu_bulk_write(port);
706 return;
707 }
708 spin_unlock_irqrestore(&priv->lock, flags);
709 /* if nothing to write call again rxcmd */
2621cee1 710 dev_dbg(&port->dev, "%s - rxcmd recall\n", __func__);
60a8fc01 711 iuu_led_activity_off(urb);
60a8fc01
AD
712}
713
95da310e
AC
714static int iuu_uart_write(struct tty_struct *tty, struct usb_serial_port *port,
715 const u8 *buf, int count)
60a8fc01
AD
716{
717 struct iuu_private *priv = usb_get_serial_port_data(port);
8594303a 718 unsigned long flags;
60a8fc01
AD
719
720 if (count > 256)
721 return -ENOMEM;
722
723 spin_lock_irqsave(&priv->lock, flags);
5fcf62b0 724
60a8fc01 725 /* fill the buffer */
5fcf62b0
OB
726 memcpy(priv->writebuf + priv->writelen, buf, count);
727 priv->writelen += count;
60a8fc01
AD
728 spin_unlock_irqrestore(&priv->lock, flags);
729
9e8e2d2a 730 return count;
60a8fc01
AD
731}
732
733static void read_rxcmd_callback(struct urb *urb)
734{
cdc97792 735 struct usb_serial_port *port = urb->context;
60a8fc01 736 int result;
50de36f7 737 int status = urb->status;
60a8fc01 738
50de36f7 739 if (status) {
60a8fc01
AD
740 /* error stop all */
741 return;
742 }
743
744 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
745 usb_rcvbulkpipe(port->serial->dev,
746 port->bulk_in_endpointAddress),
747 port->read_urb->transfer_buffer, 256,
748 iuu_uart_read_callback, port);
749 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
2621cee1 750 dev_dbg(&port->dev, "%s - submit result = %d\n", __func__, result);
60a8fc01
AD
751}
752
753static int iuu_uart_on(struct usb_serial_port *port)
754{
755 int status;
756 u8 *buf;
757
758 buf = kmalloc(sizeof(u8) * 4, GFP_KERNEL);
759
760 if (!buf)
761 return -ENOMEM;
762
763 buf[0] = IUU_UART_ENABLE;
764 buf[1] = (u8) ((IUU_BAUD_9600 >> 8) & 0x00FF);
765 buf[2] = (u8) (0x00FF & IUU_BAUD_9600);
cc3447d1 766 buf[3] = (u8) (0x0F0 & IUU_ONE_STOP_BIT) | (0x07 & IUU_PARITY_EVEN);
60a8fc01
AD
767
768 status = bulk_immediate(port, buf, 4);
769 if (status != IUU_OPERATION_OK) {
2621cee1 770 dev_dbg(&port->dev, "%s - uart_on error\n", __func__);
60a8fc01
AD
771 goto uart_enable_failed;
772 }
773 /* iuu_reset() the card after iuu_uart_on() */
774 status = iuu_uart_flush(port);
775 if (status != IUU_OPERATION_OK)
2621cee1 776 dev_dbg(&port->dev, "%s - uart_flush error\n", __func__);
60a8fc01
AD
777uart_enable_failed:
778 kfree(buf);
779 return status;
780}
781
cd8c5053 782/* Disables the IUU UART (a.k.a. the Phoenix voiderface) */
60a8fc01
AD
783static int iuu_uart_off(struct usb_serial_port *port)
784{
785 int status;
786 u8 *buf;
787 buf = kmalloc(1, GFP_KERNEL);
788 if (!buf)
789 return -ENOMEM;
790 buf[0] = IUU_UART_DISABLE;
791
792 status = bulk_immediate(port, buf, 1);
793 if (status != IUU_OPERATION_OK)
2621cee1 794 dev_dbg(&port->dev, "%s - uart_off error\n", __func__);
60a8fc01
AD
795
796 kfree(buf);
797 return status;
798}
799
89b54397 800static int iuu_uart_baud(struct usb_serial_port *port, u32 baud_base,
60a8fc01
AD
801 u32 *actual, u8 parity)
802{
803 int status;
89b54397 804 u32 baud;
60a8fc01
AD
805 u8 *dataout;
806 u8 DataCount = 0;
807 u8 T1Frekvens = 0;
808 u8 T1reload = 0;
809 unsigned int T1FrekvensHZ = 0;
810
2621cee1 811 dev_dbg(&port->dev, "%s - enter baud_base=%d\n", __func__, baud_base);
60a8fc01
AD
812 dataout = kmalloc(sizeof(u8) * 5, GFP_KERNEL);
813
814 if (!dataout)
815 return -ENOMEM;
89b54397
JCD
816 /*baud = (((priv->clk / 35) * baud_base) / 100000); */
817 baud = baud_base;
60a8fc01
AD
818
819 if (baud < 1200 || baud > 230400) {
820 kfree(dataout);
821 return IUU_INVALID_PARAMETER;
822 }
823 if (baud > 977) {
824 T1Frekvens = 3;
825 T1FrekvensHZ = 500000;
826 }
827
828 if (baud > 3906) {
829 T1Frekvens = 2;
830 T1FrekvensHZ = 2000000;
831 }
832
833 if (baud > 11718) {
834 T1Frekvens = 1;
835 T1FrekvensHZ = 6000000;
836 }
837
838 if (baud > 46875) {
839 T1Frekvens = 0;
840 T1FrekvensHZ = 24000000;
841 }
842
843 T1reload = 256 - (u8) (T1FrekvensHZ / (baud * 2));
844
845 /* magic number here: ENTER_FIRMWARE_UPDATE; */
846 dataout[DataCount++] = IUU_UART_ESC;
847 /* magic number here: CHANGE_BAUD; */
848 dataout[DataCount++] = IUU_UART_CHANGE;
849 dataout[DataCount++] = T1Frekvens;
850 dataout[DataCount++] = T1reload;
851
852 *actual = (T1FrekvensHZ / (256 - T1reload)) / 2;
853
854 switch (parity & 0x0F) {
855 case IUU_PARITY_NONE:
856 dataout[DataCount++] = 0x00;
857 break;
858 case IUU_PARITY_EVEN:
859 dataout[DataCount++] = 0x01;
860 break;
861 case IUU_PARITY_ODD:
862 dataout[DataCount++] = 0x02;
863 break;
864 case IUU_PARITY_MARK:
865 dataout[DataCount++] = 0x03;
866 break;
867 case IUU_PARITY_SPACE:
868 dataout[DataCount++] = 0x04;
869 break;
870 default:
871 kfree(dataout);
872 return IUU_INVALID_PARAMETER;
873 break;
874 }
875
876 switch (parity & 0xF0) {
877 case IUU_ONE_STOP_BIT:
878 dataout[DataCount - 1] |= IUU_ONE_STOP_BIT;
879 break;
880
881 case IUU_TWO_STOP_BITS:
882 dataout[DataCount - 1] |= IUU_TWO_STOP_BITS;
883 break;
884 default:
885 kfree(dataout);
886 return IUU_INVALID_PARAMETER;
887 break;
888 }
889
890 status = bulk_immediate(port, dataout, DataCount);
891 if (status != IUU_OPERATION_OK)
2621cee1 892 dev_dbg(&port->dev, "%s - uart_off error\n", __func__);
60a8fc01
AD
893 kfree(dataout);
894 return status;
895}
896
96dab77e
OB
897static void iuu_set_termios(struct tty_struct *tty,
898 struct usb_serial_port *port, struct ktermios *old_termios)
899{
900 const u32 supported_mask = CMSPAR|PARENB|PARODD;
89b54397 901 struct iuu_private *priv = usb_get_serial_port_data(port);
adc8d746 902 unsigned int cflag = tty->termios.c_cflag;
96dab77e
OB
903 int status;
904 u32 actual;
905 u32 parity;
906 int csize = CS7;
89b54397 907 int baud;
96dab77e
OB
908 u32 newval = cflag & supported_mask;
909
89b54397 910 /* Just use the ospeed. ispeed should be the same. */
adc8d746 911 baud = tty->termios.c_ospeed;
89b54397 912
2621cee1 913 dev_dbg(&port->dev, "%s - enter c_ospeed or baud=%d\n", __func__, baud);
89b54397 914
96dab77e
OB
915 /* compute the parity parameter */
916 parity = 0;
917 if (cflag & CMSPAR) { /* Using mark space */
918 if (cflag & PARODD)
919 parity |= IUU_PARITY_SPACE;
920 else
921 parity |= IUU_PARITY_MARK;
922 } else if (!(cflag & PARENB)) {
923 parity |= IUU_PARITY_NONE;
924 csize = CS8;
925 } else if (cflag & PARODD)
926 parity |= IUU_PARITY_ODD;
927 else
928 parity |= IUU_PARITY_EVEN;
929
930 parity |= (cflag & CSTOPB ? IUU_TWO_STOP_BITS : IUU_ONE_STOP_BIT);
931
932 /* set it */
933 status = iuu_uart_baud(port,
89b54397 934 baud * priv->boost / 100,
96dab77e
OB
935 &actual, parity);
936
937 /* set the termios value to the real one, so the user now what has
938 * changed. We support few fields so its easies to copy the old hw
939 * settings back over and then adjust them
940 */
89b54397 941 if (old_termios)
adc8d746 942 tty_termios_copy_hw(&tty->termios, old_termios);
96dab77e
OB
943 if (status != 0) /* Set failed - return old bits */
944 return;
945 /* Re-encode speed, parity and csize */
946 tty_encode_baud_rate(tty, baud, baud);
adc8d746
AC
947 tty->termios.c_cflag &= ~(supported_mask|CSIZE);
948 tty->termios.c_cflag |= newval | csize;
96dab77e
OB
949}
950
335f8514 951static void iuu_close(struct usb_serial_port *port)
60a8fc01
AD
952{
953 /* iuu_led (port,255,0,0,0); */
60a8fc01 954
60a8fc01 955 iuu_uart_off(port);
853127fa
JH
956
957 usb_kill_urb(port->write_urb);
958 usb_kill_urb(port->read_urb);
959
960 iuu_led(port, 0, 0, 0xF000, 0xFF);
60a8fc01
AD
961}
962
fe1ae7fd
AC
963static void iuu_init_termios(struct tty_struct *tty)
964{
adc8d746
AC
965 tty->termios = tty_std_termios;
966 tty->termios.c_cflag = CLOCAL | CREAD | CS8 | B9600
fe1ae7fd 967 | TIOCM_CTS | CSTOPB | PARENB;
adc8d746
AC
968 tty->termios.c_ispeed = 9600;
969 tty->termios.c_ospeed = 9600;
970 tty->termios.c_lflag = 0;
971 tty->termios.c_oflag = 0;
972 tty->termios.c_iflag = 0;
fe1ae7fd
AC
973}
974
a509a7e4 975static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port)
60a8fc01
AD
976{
977 struct usb_serial *serial = port->serial;
2621cee1 978 struct device *dev = &port->dev;
60a8fc01
AD
979 u8 *buf;
980 int result;
89b54397 981 int baud;
60a8fc01 982 u32 actual;
60a8fc01
AD
983 struct iuu_private *priv = usb_get_serial_port_data(port);
984
adc8d746
AC
985 baud = tty->termios.c_ospeed;
986 tty->termios.c_ispeed = baud;
89b54397
JCD
987 /* Re-encode speed */
988 tty_encode_baud_rate(tty, baud, baud);
989
2621cee1 990 dev_dbg(dev, "%s - baud %d\n", __func__, baud);
60a8fc01
AD
991 usb_clear_halt(serial->dev, port->write_urb->pipe);
992 usb_clear_halt(serial->dev, port->read_urb->pipe);
993
994 buf = kmalloc(10, GFP_KERNEL);
995 if (buf == NULL)
996 return -ENOMEM;
997
fe1ae7fd 998 priv->poll = 0;
60a8fc01
AD
999
1000 /* initialize writebuf */
1001#define FISH(a, b, c, d) do { \
1002 result = usb_control_msg(port->serial->dev, \
1003 usb_rcvctrlpipe(port->serial->dev, 0), \
1004 b, a, c, d, buf, 1, 1000); \
2621cee1 1005 dev_dbg(dev, "0x%x:0x%x:0x%x:0x%x %d - %x\n", a, b, c, d, result, \
60a8fc01
AD
1006 buf[0]); } while (0);
1007
1008#define SOUP(a, b, c, d) do { \
1009 result = usb_control_msg(port->serial->dev, \
1010 usb_sndctrlpipe(port->serial->dev, 0), \
1011 b, a, c, d, NULL, 0, 1000); \
2621cee1 1012 dev_dbg(dev, "0x%x:0x%x:0x%x:0x%x %d\n", a, b, c, d, result); } while (0)
60a8fc01
AD
1013
1014 /* This is not UART related but IUU USB driver related or something */
1015 /* like that. Basically no IUU will accept any commands from the USB */
1016 /* host unless it has received the following message */
1017 /* sprintf(buf ,"%c%c%c%c",0x03,0x02,0x02,0x0); */
1018
1019 SOUP(0x03, 0x02, 0x02, 0x0);
1020 kfree(buf);
1021 iuu_led(port, 0xF000, 0xF000, 0, 0xFF);
1022 iuu_uart_on(port);
1023 if (boost < 100)
1024 boost = 100;
89b54397
JCD
1025 priv->boost = boost;
1026 priv->baud = baud;
60a8fc01
AD
1027 switch (clockmode) {
1028 case 2: /* 3.680 Mhz */
89b54397 1029 priv->clk = IUU_CLK_3680000;
60a8fc01
AD
1030 iuu_clk(port, IUU_CLK_3680000 * boost / 100);
1031 result =
89b54397 1032 iuu_uart_baud(port, baud * boost / 100, &actual,
60a8fc01
AD
1033 IUU_PARITY_EVEN);
1034 break;
1035 case 3: /* 6.00 Mhz */
1036 iuu_clk(port, IUU_CLK_6000000 * boost / 100);
89b54397
JCD
1037 priv->clk = IUU_CLK_6000000;
1038 /* Ratio of 6000000 to 3500000 for baud 9600 */
60a8fc01
AD
1039 result =
1040 iuu_uart_baud(port, 16457 * boost / 100, &actual,
1041 IUU_PARITY_EVEN);
1042 break;
1043 default: /* 3.579 Mhz */
1044 iuu_clk(port, IUU_CLK_3579000 * boost / 100);
89b54397 1045 priv->clk = IUU_CLK_3579000;
60a8fc01 1046 result =
89b54397 1047 iuu_uart_baud(port, baud * boost / 100, &actual,
60a8fc01
AD
1048 IUU_PARITY_EVEN);
1049 }
1050
1051 /* set the cardin cardout signals */
1052 switch (cdmode) {
1053 case 0:
1054 iuu_cardin = 0;
1055 iuu_cardout = 0;
1056 break;
1057 case 1:
1058 iuu_cardin = TIOCM_CD;
1059 iuu_cardout = 0;
1060 break;
1061 case 2:
1062 iuu_cardin = 0;
1063 iuu_cardout = TIOCM_CD;
1064 break;
1065 case 3:
1066 iuu_cardin = TIOCM_DSR;
1067 iuu_cardout = 0;
1068 break;
1069 case 4:
1070 iuu_cardin = 0;
1071 iuu_cardout = TIOCM_DSR;
1072 break;
1073 case 5:
1074 iuu_cardin = TIOCM_CTS;
1075 iuu_cardout = 0;
1076 break;
1077 case 6:
1078 iuu_cardin = 0;
1079 iuu_cardout = TIOCM_CTS;
1080 break;
1081 case 7:
1082 iuu_cardin = TIOCM_RNG;
1083 iuu_cardout = 0;
1084 break;
1085 case 8:
1086 iuu_cardin = 0;
1087 iuu_cardout = TIOCM_RNG;
1088 }
1089
1090 iuu_uart_flush(port);
1091
2621cee1 1092 dev_dbg(dev, "%s - initialization done\n", __func__);
60a8fc01
AD
1093
1094 memset(port->write_urb->transfer_buffer, IUU_UART_RX, 1);
1095 usb_fill_bulk_urb(port->write_urb, port->serial->dev,
1096 usb_sndbulkpipe(port->serial->dev,
1097 port->bulk_out_endpointAddress),
1098 port->write_urb->transfer_buffer, 1,
1099 read_rxcmd_callback, port);
1100 result = usb_submit_urb(port->write_urb, GFP_KERNEL);
60a8fc01 1101 if (result) {
2621cee1 1102 dev_err(dev, "%s - failed submitting read urb, error %d\n", __func__, result);
335f8514 1103 iuu_close(port);
60a8fc01 1104 } else {
2621cee1 1105 dev_dbg(dev, "%s - rxcmd OK\n", __func__);
60a8fc01 1106 }
b58a6462 1107
60a8fc01
AD
1108 return result;
1109}
1110
20eda943
OB
1111/* how to change VCC */
1112static int iuu_vcc_set(struct usb_serial_port *port, unsigned int vcc)
1113{
1114 int status;
1115 u8 *buf;
1116
1117 buf = kmalloc(5, GFP_KERNEL);
1118 if (!buf)
1119 return -ENOMEM;
1120
20eda943
OB
1121 buf[0] = IUU_SET_VCC;
1122 buf[1] = vcc & 0xFF;
1123 buf[2] = (vcc >> 8) & 0xFF;
1124 buf[3] = (vcc >> 16) & 0xFF;
1125 buf[4] = (vcc >> 24) & 0xFF;
1126
1127 status = bulk_immediate(port, buf, 5);
1128 kfree(buf);
1129
1130 if (status != IUU_OPERATION_OK)
2621cee1 1131 dev_dbg(&port->dev, "%s - vcc error status = %2x\n", __func__, status);
20eda943 1132 else
2621cee1 1133 dev_dbg(&port->dev, "%s - vcc OK !\n", __func__);
20eda943
OB
1134
1135 return status;
1136}
1137
1138/*
1139 * Sysfs Attributes
1140 */
1141
154547c4 1142static ssize_t vcc_mode_show(struct device *dev,
20eda943
OB
1143 struct device_attribute *attr, char *buf)
1144{
1145 struct usb_serial_port *port = to_usb_serial_port(dev);
1146 struct iuu_private *priv = usb_get_serial_port_data(port);
1147
1148 return sprintf(buf, "%d\n", priv->vcc);
1149}
1150
154547c4 1151static ssize_t vcc_mode_store(struct device *dev,
20eda943
OB
1152 struct device_attribute *attr, const char *buf, size_t count)
1153{
1154 struct usb_serial_port *port = to_usb_serial_port(dev);
1155 struct iuu_private *priv = usb_get_serial_port_data(port);
1156 unsigned long v;
1157
487c151a 1158 if (kstrtoul(buf, 10, &v)) {
20eda943
OB
1159 dev_err(dev, "%s - vcc_mode: %s is not a unsigned long\n",
1160 __func__, buf);
1161 goto fail_store_vcc_mode;
1162 }
1163
d9a38a87 1164 dev_dbg(dev, "%s: setting vcc_mode = %ld\n", __func__, v);
20eda943
OB
1165
1166 if ((v != 3) && (v != 5)) {
1167 dev_err(dev, "%s - vcc_mode %ld is invalid\n", __func__, v);
1168 } else {
1169 iuu_vcc_set(port, v);
1170 priv->vcc = v;
1171 }
1172fail_store_vcc_mode:
1173 return count;
1174}
154547c4 1175static DEVICE_ATTR_RW(vcc_mode);
20eda943
OB
1176
1177static int iuu_create_sysfs_attrs(struct usb_serial_port *port)
1178{
20eda943
OB
1179 return device_create_file(&port->dev, &dev_attr_vcc_mode);
1180}
1181
1182static int iuu_remove_sysfs_attrs(struct usb_serial_port *port)
1183{
20eda943
OB
1184 device_remove_file(&port->dev, &dev_attr_vcc_mode);
1185 return 0;
1186}
1187
1188/*
1189 * End Sysfs Attributes
1190 */
1191
60a8fc01
AD
1192static struct usb_serial_driver iuu_device = {
1193 .driver = {
1194 .owner = THIS_MODULE,
1195 .name = "iuu_phoenix",
1196 },
1197 .id_table = id_table,
60a8fc01 1198 .num_ports = 1,
bbcb2b90
JH
1199 .bulk_in_size = 512,
1200 .bulk_out_size = 512,
60a8fc01
AD
1201 .open = iuu_open,
1202 .close = iuu_close,
1203 .write = iuu_uart_write,
1204 .read_bulk_callback = iuu_uart_read_callback,
1205 .tiocmget = iuu_tiocmget,
1206 .tiocmset = iuu_tiocmset,
96dab77e 1207 .set_termios = iuu_set_termios,
fe1ae7fd 1208 .init_termios = iuu_init_termios,
90507d54 1209 .attach = iuu_attach,
53636555
JH
1210 .port_probe = iuu_port_probe,
1211 .port_remove = iuu_port_remove,
60a8fc01
AD
1212};
1213
7dbe2460
AS
1214static struct usb_serial_driver * const serial_drivers[] = {
1215 &iuu_device, NULL
1216};
1217
68e24113 1218module_usb_serial_driver(serial_drivers, id_table);
60a8fc01
AD
1219
1220MODULE_AUTHOR("Alain Degreffe eczema@ecze.com");
1221
1222MODULE_DESCRIPTION(DRIVER_DESC);
1223MODULE_LICENSE("GPL");
1224
60a8fc01 1225module_param(xmas, bool, S_IRUGO | S_IWUSR);
8844a32d 1226MODULE_PARM_DESC(xmas, "Xmas colors enabled or not");
60a8fc01
AD
1227
1228module_param(boost, int, S_IRUGO | S_IWUSR);
8844a32d 1229MODULE_PARM_DESC(boost, "Card overclock boost (in percent 100-500)");
60a8fc01
AD
1230
1231module_param(clockmode, int, S_IRUGO | S_IWUSR);
8844a32d
OB
1232MODULE_PARM_DESC(clockmode, "Card clock mode (1=3.579 MHz, 2=3.680 MHz, "
1233 "3=6 Mhz)");
60a8fc01
AD
1234
1235module_param(cdmode, int, S_IRUGO | S_IWUSR);
8844a32d
OB
1236MODULE_PARM_DESC(cdmode, "Card detect mode (0=none, 1=CD, 2=!CD, 3=DSR, "
1237 "4=!DSR, 5=CTS, 6=!CTS, 7=RING, 8=!RING)");
e55c6d06
OB
1238
1239module_param(vcc_default, int, S_IRUGO | S_IWUSR);
1240MODULE_PARM_DESC(vcc_default, "Set default VCC (either 3 for 3.3V or 5 "
1241 "for 5V). Default to 5.");