Lines Matching +full:port +full:- +full:1

1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright (C) 2010 James Courtier-Dutton (James@superbug.co.uk)
39 static int clockmode = 1;
40 static int cdmode = 1;
46 static int iuu_create_sysfs_attrs(struct usb_serial_port *port);
47 static int iuu_remove_sysfs_attrs(struct usb_serial_port *port);
54 u8 reset; /* if 1 reset is needed */
65 static int iuu_port_probe(struct usb_serial_port *port) in iuu_port_probe() argument
72 return -ENOMEM; in iuu_port_probe()
74 priv->buf = kzalloc(256, GFP_KERNEL); in iuu_port_probe()
75 if (!priv->buf) { in iuu_port_probe()
77 return -ENOMEM; in iuu_port_probe()
80 priv->writebuf = kzalloc(256, GFP_KERNEL); in iuu_port_probe()
81 if (!priv->writebuf) { in iuu_port_probe()
82 kfree(priv->buf); in iuu_port_probe()
84 return -ENOMEM; in iuu_port_probe()
87 priv->vcc = vcc_default; in iuu_port_probe()
88 spin_lock_init(&priv->lock); in iuu_port_probe()
90 usb_set_serial_port_data(port, priv); in iuu_port_probe()
92 ret = iuu_create_sysfs_attrs(port); in iuu_port_probe()
94 kfree(priv->writebuf); in iuu_port_probe()
95 kfree(priv->buf); in iuu_port_probe()
103 static int iuu_port_remove(struct usb_serial_port *port) in iuu_port_remove() argument
105 struct iuu_private *priv = usb_get_serial_port_data(port); in iuu_port_remove()
107 iuu_remove_sysfs_attrs(port); in iuu_port_remove()
108 kfree(priv->writebuf); in iuu_port_remove()
109 kfree(priv->buf); in iuu_port_remove()
118 struct usb_serial_port *port = tty->driver_data; in iuu_tiocmset() local
119 struct iuu_private *priv = usb_get_serial_port_data(port); in iuu_tiocmset()
123 dev_dbg(&port->dev, "%s msg : SET = 0x%04x, CLEAR = 0x%04x\n", in iuu_tiocmset()
126 spin_lock_irqsave(&priv->lock, flags); in iuu_tiocmset()
128 if ((set & TIOCM_RTS) && !(priv->tiostatus == TIOCM_RTS)) { in iuu_tiocmset()
129 dev_dbg(&port->dev, "%s TIOCMSET RESET called !!!\n", __func__); in iuu_tiocmset()
130 priv->reset = 1; in iuu_tiocmset()
133 priv->tiostatus = TIOCM_RTS; in iuu_tiocmset()
135 spin_unlock_irqrestore(&priv->lock, flags); in iuu_tiocmset()
146 struct usb_serial_port *port = tty->driver_data; in iuu_tiocmget() local
147 struct iuu_private *priv = usb_get_serial_port_data(port); in iuu_tiocmget()
151 spin_lock_irqsave(&priv->lock, flags); in iuu_tiocmget()
152 rc = priv->tiostatus; in iuu_tiocmget()
153 spin_unlock_irqrestore(&priv->lock, flags); in iuu_tiocmget()
160 struct usb_serial_port *port = urb->context; in iuu_rxcmd() local
161 int status = urb->status; in iuu_rxcmd()
164 dev_dbg(&port->dev, "%s - status = %d\n", __func__, status); in iuu_rxcmd()
170 memset(port->write_urb->transfer_buffer, IUU_UART_RX, 1); in iuu_rxcmd()
171 usb_fill_bulk_urb(port->write_urb, port->serial->dev, in iuu_rxcmd()
172 usb_sndbulkpipe(port->serial->dev, in iuu_rxcmd()
173 port->bulk_out_endpointAddress), in iuu_rxcmd()
174 port->write_urb->transfer_buffer, 1, in iuu_rxcmd()
175 read_rxcmd_callback, port); in iuu_rxcmd()
176 usb_submit_urb(port->write_urb, GFP_ATOMIC); in iuu_rxcmd()
179 static int iuu_reset(struct usb_serial_port *port, u8 wt) in iuu_reset() argument
181 struct iuu_private *priv = usb_get_serial_port_data(port); in iuu_reset()
183 char *buf_ptr = port->write_urb->transfer_buffer; in iuu_reset()
194 usb_fill_bulk_urb(port->write_urb, in iuu_reset()
195 port->serial->dev, in iuu_reset()
196 usb_sndbulkpipe(port->serial->dev, in iuu_reset()
197 port->bulk_out_endpointAddress), in iuu_reset()
198 port->write_urb->transfer_buffer, 4, iuu_rxcmd, port); in iuu_reset()
199 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); in iuu_reset()
200 priv->reset = 0; in iuu_reset()
212 struct usb_serial_port *port = urb->context; in iuu_update_status_callback() local
213 struct iuu_private *priv = usb_get_serial_port_data(port); in iuu_update_status_callback()
215 int status = urb->status; in iuu_update_status_callback()
218 dev_dbg(&port->dev, "%s - status = %d\n", __func__, status); in iuu_update_status_callback()
223 st = urb->transfer_buffer; in iuu_update_status_callback()
224 dev_dbg(&port->dev, "%s - enter\n", __func__); in iuu_update_status_callback()
225 if (urb->actual_length == 1) { in iuu_update_status_callback()
228 priv->tiostatus = iuu_cardout; in iuu_update_status_callback()
231 priv->tiostatus = iuu_cardin; in iuu_update_status_callback()
234 priv->tiostatus = iuu_cardin; in iuu_update_status_callback()
242 struct usb_serial_port *port = urb->context; in iuu_status_callback() local
243 int status = urb->status; in iuu_status_callback()
245 dev_dbg(&port->dev, "%s - status = %d\n", __func__, status); in iuu_status_callback()
246 usb_fill_bulk_urb(port->read_urb, port->serial->dev, in iuu_status_callback()
247 usb_rcvbulkpipe(port->serial->dev, in iuu_status_callback()
248 port->bulk_in_endpointAddress), in iuu_status_callback()
249 port->read_urb->transfer_buffer, 256, in iuu_status_callback()
250 iuu_update_status_callback, port); in iuu_status_callback()
251 usb_submit_urb(port->read_urb, GFP_ATOMIC); in iuu_status_callback()
254 static int iuu_status(struct usb_serial_port *port) in iuu_status() argument
258 memset(port->write_urb->transfer_buffer, IUU_GET_STATE_REGISTER, 1); in iuu_status()
259 usb_fill_bulk_urb(port->write_urb, port->serial->dev, in iuu_status()
260 usb_sndbulkpipe(port->serial->dev, in iuu_status()
261 port->bulk_out_endpointAddress), in iuu_status()
262 port->write_urb->transfer_buffer, 1, in iuu_status()
263 iuu_status_callback, port); in iuu_status()
264 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); in iuu_status()
269 static int bulk_immediate(struct usb_serial_port *port, u8 *buf, u8 count) in bulk_immediate() argument
272 struct usb_serial *serial = port->serial; in bulk_immediate()
275 /* send the data out the bulk port */ in bulk_immediate()
278 usb_bulk_msg(serial->dev, in bulk_immediate()
279 usb_sndbulkpipe(serial->dev, in bulk_immediate()
280 port->bulk_out_endpointAddress), buf, in bulk_immediate()
284 dev_dbg(&port->dev, "%s - error = %2x\n", __func__, status); in bulk_immediate()
286 dev_dbg(&port->dev, "%s - write OK !\n", __func__); in bulk_immediate()
290 static int read_immediate(struct usb_serial_port *port, u8 *buf, u8 count) in read_immediate() argument
293 struct usb_serial *serial = port->serial; in read_immediate()
296 /* send the data out the bulk port */ in read_immediate()
298 usb_bulk_msg(serial->dev, in read_immediate()
299 usb_rcvbulkpipe(serial->dev, in read_immediate()
300 port->bulk_in_endpointAddress), buf, in read_immediate()
304 dev_dbg(&port->dev, "%s - error = %2x\n", __func__, status); in read_immediate()
306 dev_dbg(&port->dev, "%s - read OK !\n", __func__); in read_immediate()
310 static int iuu_led(struct usb_serial_port *port, unsigned int R, in iuu_led() argument
317 return -ENOMEM; in iuu_led()
320 buf[1] = R & 0xFF; in iuu_led()
327 status = bulk_immediate(port, buf, 8); in iuu_led()
330 dev_dbg(&port->dev, "%s - led error status = %2x\n", __func__, status); in iuu_led()
332 dev_dbg(&port->dev, "%s - led OK !\n", __func__); in iuu_led()
351 struct usb_serial_port *port = urb->context; in iuu_led_activity_on() local
352 char *buf_ptr = port->write_urb->transfer_buffer; in iuu_led_activity_on()
356 get_random_bytes(buf_ptr + 1, 6); in iuu_led_activity_on()
357 buf_ptr[7] = 1; in iuu_led_activity_on()
362 usb_fill_bulk_urb(port->write_urb, port->serial->dev, in iuu_led_activity_on()
363 usb_sndbulkpipe(port->serial->dev, in iuu_led_activity_on()
364 port->bulk_out_endpointAddress), in iuu_led_activity_on()
365 port->write_urb->transfer_buffer, 8 , in iuu_led_activity_on()
366 iuu_rxcmd, port); in iuu_led_activity_on()
367 usb_submit_urb(port->write_urb, GFP_ATOMIC); in iuu_led_activity_on()
372 struct usb_serial_port *port = urb->context; in iuu_led_activity_off() local
373 char *buf_ptr = port->write_urb->transfer_buffer; in iuu_led_activity_off()
382 usb_fill_bulk_urb(port->write_urb, port->serial->dev, in iuu_led_activity_off()
383 usb_sndbulkpipe(port->serial->dev, in iuu_led_activity_off()
384 port->bulk_out_endpointAddress), in iuu_led_activity_off()
385 port->write_urb->transfer_buffer, 8 , in iuu_led_activity_off()
386 iuu_rxcmd, port); in iuu_led_activity_off()
387 usb_submit_urb(port->write_urb, GFP_ATOMIC); in iuu_led_activity_off()
392 static int iuu_clk(struct usb_serial_port *port, int dwFrq) in iuu_clk() argument
395 struct iuu_private *priv = usb_get_serial_port_data(port); in iuu_clk()
403 u8 PO = 0; /* 1bit */ in iuu_clk()
411 priv->buf[Count++] = IUU_UART_WRITE_I2C; in iuu_clk()
412 priv->buf[Count++] = FrqGenAdr << 1; in iuu_clk()
413 priv->buf[Count++] = 0x09; in iuu_clk()
414 priv->buf[Count++] = 0x00; in iuu_clk()
416 status = bulk_immediate(port, (u8 *) priv->buf, Count); in iuu_clk()
418 dev_dbg(&port->dev, "%s - write error\n", __func__); in iuu_clk()
447 for (lP = 2055; lP >= 8 && !found; lP--) in iuu_clk()
450 if (abs((int)(tmp - frq)) < in iuu_clk()
451 abs((int)(frq - result))) { in iuu_clk()
471 P2 = ((P - PO) / 2) - 4; in iuu_clk()
476 Q = Q - 2; in iuu_clk()
478 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ in iuu_clk()
479 priv->buf[Count++] = FrqGenAdr << 1; in iuu_clk()
480 priv->buf[Count++] = 0x09; in iuu_clk()
481 priv->buf[Count++] = 0x20; /* Adr = 0x09 */ in iuu_clk()
482 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ in iuu_clk()
483 priv->buf[Count++] = FrqGenAdr << 1; in iuu_clk()
484 priv->buf[Count++] = 0x0C; in iuu_clk()
485 priv->buf[Count++] = DIV; /* Adr = 0x0C */ in iuu_clk()
486 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ in iuu_clk()
487 priv->buf[Count++] = FrqGenAdr << 1; in iuu_clk()
488 priv->buf[Count++] = 0x12; in iuu_clk()
489 priv->buf[Count++] = XDRV; /* Adr = 0x12 */ in iuu_clk()
490 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ in iuu_clk()
491 priv->buf[Count++] = FrqGenAdr << 1; in iuu_clk()
492 priv->buf[Count++] = 0x13; in iuu_clk()
493 priv->buf[Count++] = 0x6B; /* Adr = 0x13 */ in iuu_clk()
494 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ in iuu_clk()
495 priv->buf[Count++] = FrqGenAdr << 1; in iuu_clk()
496 priv->buf[Count++] = 0x40; in iuu_clk()
497 priv->buf[Count++] = (0xC0 | ((PUMP & 0x07) << 2)) | in iuu_clk()
499 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ in iuu_clk()
500 priv->buf[Count++] = FrqGenAdr << 1; in iuu_clk()
501 priv->buf[Count++] = 0x41; in iuu_clk()
502 priv->buf[Count++] = PBlsb; /* Adr = 0x41 */ in iuu_clk()
503 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ in iuu_clk()
504 priv->buf[Count++] = FrqGenAdr << 1; in iuu_clk()
505 priv->buf[Count++] = 0x42; in iuu_clk()
506 priv->buf[Count++] = Q | (((PO & 0x01) << 7)); /* Adr = 0x42 */ in iuu_clk()
507 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ in iuu_clk()
508 priv->buf[Count++] = FrqGenAdr << 1; in iuu_clk()
509 priv->buf[Count++] = 0x44; in iuu_clk()
510 priv->buf[Count++] = (char)0xFF; /* Adr = 0x44 */ in iuu_clk()
511 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ in iuu_clk()
512 priv->buf[Count++] = FrqGenAdr << 1; in iuu_clk()
513 priv->buf[Count++] = 0x45; in iuu_clk()
514 priv->buf[Count++] = (char)0xFE; /* Adr = 0x45 */ in iuu_clk()
515 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ in iuu_clk()
516 priv->buf[Count++] = FrqGenAdr << 1; in iuu_clk()
517 priv->buf[Count++] = 0x46; in iuu_clk()
518 priv->buf[Count++] = 0x7F; /* Adr = 0x46 */ in iuu_clk()
519 priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ in iuu_clk()
520 priv->buf[Count++] = FrqGenAdr << 1; in iuu_clk()
521 priv->buf[Count++] = 0x47; in iuu_clk()
522 priv->buf[Count++] = (char)0x84; /* Adr = 0x47 */ in iuu_clk()
524 status = bulk_immediate(port, (u8 *) priv->buf, Count); in iuu_clk()
526 dev_dbg(&port->dev, "%s - write error\n", __func__); in iuu_clk()
530 static int iuu_uart_flush(struct usb_serial_port *port) in iuu_uart_flush() argument
532 struct device *dev = &port->dev; in iuu_uart_flush()
536 struct iuu_private *priv = usb_get_serial_port_data(port); in iuu_uart_flush()
538 if (iuu_led(port, 0xF000, 0, 0, 0xFF) < 0) in iuu_uart_flush()
539 return -EIO; in iuu_uart_flush()
542 status = bulk_immediate(port, &rxcmd, 1); in iuu_uart_flush()
544 dev_dbg(dev, "%s - uart_flush_write error\n", __func__); in iuu_uart_flush()
548 status = read_immediate(port, &priv->len, 1); in iuu_uart_flush()
550 dev_dbg(dev, "%s - uart_flush_read error\n", __func__); in iuu_uart_flush()
554 if (priv->len > 0) { in iuu_uart_flush()
555 dev_dbg(dev, "%s - uart_flush datalen is : %i\n", __func__, priv->len); in iuu_uart_flush()
556 status = read_immediate(port, priv->buf, priv->len); in iuu_uart_flush()
558 dev_dbg(dev, "%s - uart_flush_read error\n", __func__); in iuu_uart_flush()
563 dev_dbg(dev, "%s - uart_flush_read OK!\n", __func__); in iuu_uart_flush()
564 iuu_led(port, 0, 0xF000, 0, 0xFF); in iuu_uart_flush()
570 struct usb_serial_port *port = urb->context; in read_buf_callback() local
571 unsigned char *data = urb->transfer_buffer; in read_buf_callback()
572 int status = urb->status; in read_buf_callback()
575 if (status == -EPROTO) { in read_buf_callback()
581 dev_dbg(&port->dev, "%s - %i chars to write\n", __func__, urb->actual_length); in read_buf_callback()
583 if (urb->actual_length) { in read_buf_callback()
584 tty_insert_flip_string(&port->port, data, urb->actual_length); in read_buf_callback()
585 tty_flip_buffer_push(&port->port); in read_buf_callback()
590 static int iuu_bulk_write(struct usb_serial_port *port) in iuu_bulk_write() argument
592 struct iuu_private *priv = usb_get_serial_port_data(port); in iuu_bulk_write()
596 char *buf_ptr = port->write_urb->transfer_buffer; in iuu_bulk_write()
598 spin_lock_irqsave(&priv->lock, flags); in iuu_bulk_write()
601 *buf_ptr++ = priv->writelen; in iuu_bulk_write()
603 memcpy(buf_ptr, priv->writebuf, priv->writelen); in iuu_bulk_write()
604 buf_len = priv->writelen; in iuu_bulk_write()
605 priv->writelen = 0; in iuu_bulk_write()
606 spin_unlock_irqrestore(&priv->lock, flags); in iuu_bulk_write()
607 dev_dbg(&port->dev, "%s - writing %i chars : %*ph\n", __func__, in iuu_bulk_write()
609 usb_fill_bulk_urb(port->write_urb, port->serial->dev, in iuu_bulk_write()
610 usb_sndbulkpipe(port->serial->dev, in iuu_bulk_write()
611 port->bulk_out_endpointAddress), in iuu_bulk_write()
612 port->write_urb->transfer_buffer, buf_len + 3, in iuu_bulk_write()
613 iuu_rxcmd, port); in iuu_bulk_write()
614 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); in iuu_bulk_write()
615 usb_serial_port_softint(port); in iuu_bulk_write()
619 static int iuu_read_buf(struct usb_serial_port *port, int len) in iuu_read_buf() argument
623 usb_fill_bulk_urb(port->read_urb, port->serial->dev, in iuu_read_buf()
624 usb_rcvbulkpipe(port->serial->dev, in iuu_read_buf()
625 port->bulk_in_endpointAddress), in iuu_read_buf()
626 port->read_urb->transfer_buffer, len, in iuu_read_buf()
627 read_buf_callback, port); in iuu_read_buf()
628 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); in iuu_read_buf()
634 struct usb_serial_port *port = urb->context; in iuu_uart_read_callback() local
635 struct iuu_private *priv = usb_get_serial_port_data(port); in iuu_uart_read_callback()
637 int status = urb->status; in iuu_uart_read_callback()
640 unsigned char *data = urb->transfer_buffer; in iuu_uart_read_callback()
641 priv->poll++; in iuu_uart_read_callback()
644 dev_dbg(&port->dev, "%s - status = %d\n", __func__, status); in iuu_uart_read_callback()
649 if (urb->actual_length == 1) in iuu_uart_read_callback()
652 if (urb->actual_length > 1) { in iuu_uart_read_callback()
653 dev_dbg(&port->dev, "%s - urb->actual_length = %i\n", __func__, in iuu_uart_read_callback()
654 urb->actual_length); in iuu_uart_read_callback()
655 error = 1; in iuu_uart_read_callback()
661 dev_dbg(&port->dev, "%s - call read buf - len to read is %i\n", in iuu_uart_read_callback()
663 status = iuu_read_buf(port, len); in iuu_uart_read_callback()
667 if (priv->poll > 99) { in iuu_uart_read_callback()
668 status = iuu_status(port); in iuu_uart_read_callback()
669 priv->poll = 0; in iuu_uart_read_callback()
675 if (priv->reset == 1) { in iuu_uart_read_callback()
676 status = iuu_reset(port, 0xC); in iuu_uart_read_callback()
680 spin_lock_irqsave(&priv->lock, flags); in iuu_uart_read_callback()
681 if (priv->writelen > 0) { in iuu_uart_read_callback()
682 spin_unlock_irqrestore(&priv->lock, flags); in iuu_uart_read_callback()
683 status = iuu_bulk_write(port); in iuu_uart_read_callback()
686 spin_unlock_irqrestore(&priv->lock, flags); in iuu_uart_read_callback()
688 dev_dbg(&port->dev, "%s - rxcmd recall\n", __func__); in iuu_uart_read_callback()
692 static int iuu_uart_write(struct tty_struct *tty, struct usb_serial_port *port, in iuu_uart_write() argument
695 struct iuu_private *priv = usb_get_serial_port_data(port); in iuu_uart_write()
698 spin_lock_irqsave(&priv->lock, flags); in iuu_uart_write()
700 count = min(count, 256 - priv->writelen); in iuu_uart_write()
705 memcpy(priv->writebuf + priv->writelen, buf, count); in iuu_uart_write()
706 priv->writelen += count; in iuu_uart_write()
708 spin_unlock_irqrestore(&priv->lock, flags); in iuu_uart_write()
715 struct usb_serial_port *port = urb->context; in read_rxcmd_callback() local
717 int status = urb->status; in read_rxcmd_callback()
724 usb_fill_bulk_urb(port->read_urb, port->serial->dev, in read_rxcmd_callback()
725 usb_rcvbulkpipe(port->serial->dev, in read_rxcmd_callback()
726 port->bulk_in_endpointAddress), in read_rxcmd_callback()
727 port->read_urb->transfer_buffer, 256, in read_rxcmd_callback()
728 iuu_uart_read_callback, port); in read_rxcmd_callback()
729 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); in read_rxcmd_callback()
730 dev_dbg(&port->dev, "%s - submit result = %d\n", __func__, result); in read_rxcmd_callback()
733 static int iuu_uart_on(struct usb_serial_port *port) in iuu_uart_on() argument
741 return -ENOMEM; in iuu_uart_on()
744 buf[1] = (u8) ((IUU_BAUD_9600 >> 8) & 0x00FF); in iuu_uart_on()
748 status = bulk_immediate(port, buf, 4); in iuu_uart_on()
750 dev_dbg(&port->dev, "%s - uart_on error\n", __func__); in iuu_uart_on()
754 status = iuu_uart_flush(port); in iuu_uart_on()
756 dev_dbg(&port->dev, "%s - uart_flush error\n", __func__); in iuu_uart_on()
763 static int iuu_uart_off(struct usb_serial_port *port) in iuu_uart_off() argument
767 buf = kmalloc(1, GFP_KERNEL); in iuu_uart_off()
769 return -ENOMEM; in iuu_uart_off()
772 status = bulk_immediate(port, buf, 1); in iuu_uart_off()
774 dev_dbg(&port->dev, "%s - uart_off error\n", __func__); in iuu_uart_off()
780 static int iuu_uart_baud(struct usb_serial_port *port, u32 baud_base, in iuu_uart_baud() argument
791 dev_dbg(&port->dev, "%s - enter baud_base=%d\n", __func__, baud_base); in iuu_uart_baud()
795 return -ENOMEM; in iuu_uart_baud()
796 /*baud = (((priv->clk / 35) * baud_base) / 100000); */ in iuu_uart_baud()
814 T1Frekvens = 1; in iuu_uart_baud()
823 T1reload = 256 - (u8) (T1FrekvensHZ / (baud * 2)); in iuu_uart_baud()
832 *actual = (T1FrekvensHZ / (256 - T1reload)) / 2; in iuu_uart_baud()
858 dataout[DataCount - 1] |= IUU_ONE_STOP_BIT; in iuu_uart_baud()
862 dataout[DataCount - 1] |= IUU_TWO_STOP_BITS; in iuu_uart_baud()
870 status = bulk_immediate(port, dataout, DataCount); in iuu_uart_baud()
872 dev_dbg(&port->dev, "%s - uart_off error\n", __func__); in iuu_uart_baud()
878 struct usb_serial_port *port, struct ktermios *old_termios) in iuu_set_termios() argument
881 struct iuu_private *priv = usb_get_serial_port_data(port); in iuu_set_termios()
882 unsigned int cflag = tty->termios.c_cflag; in iuu_set_termios()
891 baud = tty->termios.c_ospeed; in iuu_set_termios()
893 dev_dbg(&port->dev, "%s - enter c_ospeed or baud=%d\n", __func__, baud); in iuu_set_termios()
913 status = iuu_uart_baud(port, in iuu_set_termios()
914 baud * priv->boost / 100, in iuu_set_termios()
922 tty_termios_copy_hw(&tty->termios, old_termios); in iuu_set_termios()
923 if (status != 0) /* Set failed - return old bits */ in iuu_set_termios()
925 /* Re-encode speed, parity and csize */ in iuu_set_termios()
927 tty->termios.c_cflag &= ~(supported_mask|CSIZE); in iuu_set_termios()
928 tty->termios.c_cflag |= newval | csize; in iuu_set_termios()
931 static void iuu_close(struct usb_serial_port *port) in iuu_close() argument
933 /* iuu_led (port,255,0,0,0); */ in iuu_close()
935 iuu_uart_off(port); in iuu_close()
937 usb_kill_urb(port->write_urb); in iuu_close()
938 usb_kill_urb(port->read_urb); in iuu_close()
940 iuu_led(port, 0, 0, 0xF000, 0xFF); in iuu_close()
945 tty->termios.c_cflag = B9600 | CS8 | CSTOPB | CREAD | PARENB | CLOCAL; in iuu_init_termios()
946 tty->termios.c_ispeed = 9600; in iuu_init_termios()
947 tty->termios.c_ospeed = 9600; in iuu_init_termios()
948 tty->termios.c_lflag = 0; in iuu_init_termios()
949 tty->termios.c_oflag = 0; in iuu_init_termios()
950 tty->termios.c_iflag = 0; in iuu_init_termios()
953 static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port) in iuu_open() argument
955 struct usb_serial *serial = port->serial; in iuu_open()
956 struct device *dev = &port->dev; in iuu_open()
960 struct iuu_private *priv = usb_get_serial_port_data(port); in iuu_open()
962 baud = tty->termios.c_ospeed; in iuu_open()
964 dev_dbg(dev, "%s - baud %d\n", __func__, baud); in iuu_open()
965 usb_clear_halt(serial->dev, port->write_urb->pipe); in iuu_open()
966 usb_clear_halt(serial->dev, port->read_urb->pipe); in iuu_open()
968 priv->poll = 0; in iuu_open()
971 result = usb_control_msg(port->serial->dev, \ in iuu_open()
972 usb_sndctrlpipe(port->serial->dev, 0), \ in iuu_open()
983 iuu_led(port, 0xF000, 0xF000, 0, 0xFF); in iuu_open()
984 iuu_uart_on(port); in iuu_open()
987 priv->boost = boost; in iuu_open()
990 priv->clk = IUU_CLK_3680000; in iuu_open()
991 iuu_clk(port, IUU_CLK_3680000 * boost / 100); in iuu_open()
993 iuu_uart_baud(port, baud * boost / 100, &actual, in iuu_open()
997 iuu_clk(port, IUU_CLK_6000000 * boost / 100); in iuu_open()
998 priv->clk = IUU_CLK_6000000; in iuu_open()
1001 iuu_uart_baud(port, 16457 * boost / 100, &actual, in iuu_open()
1005 iuu_clk(port, IUU_CLK_3579000 * boost / 100); in iuu_open()
1006 priv->clk = IUU_CLK_3579000; in iuu_open()
1008 iuu_uart_baud(port, baud * boost / 100, &actual, in iuu_open()
1018 case 1: in iuu_open()
1051 iuu_uart_flush(port); in iuu_open()
1053 dev_dbg(dev, "%s - initialization done\n", __func__); in iuu_open()
1055 memset(port->write_urb->transfer_buffer, IUU_UART_RX, 1); in iuu_open()
1056 usb_fill_bulk_urb(port->write_urb, port->serial->dev, in iuu_open()
1057 usb_sndbulkpipe(port->serial->dev, in iuu_open()
1058 port->bulk_out_endpointAddress), in iuu_open()
1059 port->write_urb->transfer_buffer, 1, in iuu_open()
1060 read_rxcmd_callback, port); in iuu_open()
1061 result = usb_submit_urb(port->write_urb, GFP_KERNEL); in iuu_open()
1063 dev_err(dev, "%s - failed submitting read urb, error %d\n", __func__, result); in iuu_open()
1064 iuu_close(port); in iuu_open()
1066 dev_dbg(dev, "%s - rxcmd OK\n", __func__); in iuu_open()
1073 static int iuu_vcc_set(struct usb_serial_port *port, unsigned int vcc) in iuu_vcc_set() argument
1080 return -ENOMEM; in iuu_vcc_set()
1083 buf[1] = vcc & 0xFF; in iuu_vcc_set()
1088 status = bulk_immediate(port, buf, 5); in iuu_vcc_set()
1092 dev_dbg(&port->dev, "%s - vcc error status = %2x\n", __func__, status); in iuu_vcc_set()
1094 dev_dbg(&port->dev, "%s - vcc OK !\n", __func__); in iuu_vcc_set()
1106 struct usb_serial_port *port = to_usb_serial_port(dev); in vcc_mode_show() local
1107 struct iuu_private *priv = usb_get_serial_port_data(port); in vcc_mode_show()
1109 return sprintf(buf, "%d\n", priv->vcc); in vcc_mode_show()
1115 struct usb_serial_port *port = to_usb_serial_port(dev); in vcc_mode_store() local
1116 struct iuu_private *priv = usb_get_serial_port_data(port); in vcc_mode_store()
1120 dev_err(dev, "%s - vcc_mode: %s is not a unsigned long\n", in vcc_mode_store()
1128 dev_err(dev, "%s - vcc_mode %ld is invalid\n", __func__, v); in vcc_mode_store()
1130 iuu_vcc_set(port, v); in vcc_mode_store()
1131 priv->vcc = v; in vcc_mode_store()
1138 static int iuu_create_sysfs_attrs(struct usb_serial_port *port) in iuu_create_sysfs_attrs() argument
1140 return device_create_file(&port->dev, &dev_attr_vcc_mode); in iuu_create_sysfs_attrs()
1143 static int iuu_remove_sysfs_attrs(struct usb_serial_port *port) in iuu_remove_sysfs_attrs() argument
1145 device_remove_file(&port->dev, &dev_attr_vcc_mode); in iuu_remove_sysfs_attrs()
1159 .num_ports = 1,
1160 .num_bulk_in = 1,
1161 .num_bulk_out = 1,
1191 MODULE_PARM_DESC(boost, "Card overclock boost (in percent 100-500)");
1194 MODULE_PARM_DESC(clockmode, "Card clock mode (1=3.579 MHz, 2=3.680 MHz, "
1198 MODULE_PARM_DESC(cdmode, "Card detect mode (0=none, 1=CD, 2=!CD, 3=DSR, "