Lines Matching +full:serial +full:- +full:number
1 // SPDX-License-Identifier: GPL-2.0
4 * Controls the Moschip 7720 usb to dual port serial converter
14 * Greg Kroah-Hartman <gregkh@suse.de>
16 * Originally based on drivers/usb/serial/io_edgeport.c which is:
18 * Copyright (C) 2001-2002 Greg Kroah-Hartman <greg@kroah.com>
28 #include <linux/serial.h>
31 #include <linux/usb/serial.h>
36 #define DRIVER_DESC "Moschip USB Serial Driver"
55 /* This structure holds all of the local serial port information */
85 PPF = 2<<5, /* moschip calls this 'CB-FIFO mode */
94 struct usb_serial *serial; /* back to containing struct */ member
97 atomic_t shadowDSR; /* updated in int-in callback */
108 MOS7720_THR, /* serial port regs */
125 MOS7720_SP2_REG, /* serial port 2 (7720 only) */
174 else /* serial port reg */ in get_reg_value()
181 * not specific to a particular serial port.
183 static int write_mos_reg(struct usb_serial *serial, unsigned int serial_portnum, in write_mos_reg() argument
186 struct usb_device *usbdev = serial->dev; in write_mos_reg()
195 dev_err(&usbdev->dev, in write_mos_reg()
203 * ignored for registers that are not specific to a particular serial port.
205 static int read_mos_reg(struct usb_serial *serial, unsigned int serial_portnum, in read_mos_reg() argument
208 struct usb_device *usbdev = serial->dev; in read_mos_reg()
220 return -ENOMEM; in read_mos_reg()
228 dev_err(&usbdev->dev, in read_mos_reg()
231 status = -EIO; in read_mos_reg()
245 mos_parport->shadowECR = mode; in mos7715_change_mode()
246 write_mos_reg(mos_parport->serial, dummy, MOS7720_ECR, in mos7715_change_mode()
247 mos_parport->shadowECR); in mos7715_change_mode()
265 * not called the release function yet because someone has a serial port open.
276 mos_parport = pp->private_data; in parport_prologue()
280 return -1; in parport_prologue()
282 mos_parport->msg_pending = true; /* synch usb call pending */ in parport_prologue()
283 reinit_completion(&mos_parport->syncmsg_compl); in parport_prologue()
287 if (work_pending(&mos_parport->work)) in parport_prologue()
288 flush_work(&mos_parport->work); in parport_prologue()
290 mutex_lock(&mos_parport->serial->disc_mutex); in parport_prologue()
291 if (mos_parport->serial->disconnected) { in parport_prologue()
293 mutex_unlock(&mos_parport->serial->disc_mutex); in parport_prologue()
294 mos_parport->msg_pending = false; in parport_prologue()
295 complete(&mos_parport->syncmsg_compl); in parport_prologue()
296 return -1; in parport_prologue()
308 struct mos7715_parport *mos_parport = pp->private_data; in parport_epilogue()
309 mutex_unlock(&mos_parport->serial->disc_mutex); in parport_epilogue()
310 mos_parport->msg_pending = false; in parport_epilogue()
311 complete(&mos_parport->syncmsg_compl); in parport_epilogue()
320 mutex_lock(&mos_parport->serial->disc_mutex); in deferred_restore_writes()
323 if (mos_parport->serial->disconnected) in deferred_restore_writes()
326 write_mos_reg(mos_parport->serial, dummy, MOS7720_DCR, in deferred_restore_writes()
327 mos_parport->shadowDCR); in deferred_restore_writes()
328 write_mos_reg(mos_parport->serial, dummy, MOS7720_ECR, in deferred_restore_writes()
329 mos_parport->shadowECR); in deferred_restore_writes()
331 mutex_unlock(&mos_parport->serial->disc_mutex); in deferred_restore_writes()
336 struct mos7715_parport *mos_parport = pp->private_data; in parport_mos7715_write_data()
341 write_mos_reg(mos_parport->serial, dummy, MOS7720_DPR, (__u8)d); in parport_mos7715_write_data()
347 struct mos7715_parport *mos_parport = pp->private_data; in parport_mos7715_read_data()
352 read_mos_reg(mos_parport->serial, dummy, MOS7720_DPR, &d); in parport_mos7715_read_data()
359 struct mos7715_parport *mos_parport = pp->private_data; in parport_mos7715_write_control()
364 data = ((__u8)d & 0x0f) | (mos_parport->shadowDCR & 0xf0); in parport_mos7715_write_control()
365 write_mos_reg(mos_parport->serial, dummy, MOS7720_DCR, data); in parport_mos7715_write_control()
366 mos_parport->shadowDCR = data; in parport_mos7715_write_control()
376 mos_parport = pp->private_data; in parport_mos7715_read_control()
381 dcr = mos_parport->shadowDCR & 0x0f; in parport_mos7715_read_control()
390 struct mos7715_parport *mos_parport = pp->private_data; in parport_mos7715_frob_control()
397 mos_parport->shadowDCR = (mos_parport->shadowDCR & (~mask)) ^ val; in parport_mos7715_frob_control()
398 write_mos_reg(mos_parport->serial, dummy, MOS7720_DCR, in parport_mos7715_frob_control()
399 mos_parport->shadowDCR); in parport_mos7715_frob_control()
400 dcr = mos_parport->shadowDCR & 0x0f; in parport_mos7715_frob_control()
411 mos_parport = pp->private_data; in parport_mos7715_read_status()
416 status = atomic_read(&mos_parport->shadowDSR) & 0xf8; in parport_mos7715_read_status()
431 struct mos7715_parport *mos_parport = pp->private_data; in parport_mos7715_data_forward()
436 mos_parport->shadowDCR &= ~0x20; in parport_mos7715_data_forward()
437 write_mos_reg(mos_parport->serial, dummy, MOS7720_DCR, in parport_mos7715_data_forward()
438 mos_parport->shadowDCR); in parport_mos7715_data_forward()
444 struct mos7715_parport *mos_parport = pp->private_data; in parport_mos7715_data_reverse()
449 mos_parport->shadowDCR |= 0x20; in parport_mos7715_data_reverse()
450 write_mos_reg(mos_parport->serial, dummy, MOS7720_DCR, in parport_mos7715_data_reverse()
451 mos_parport->shadowDCR); in parport_mos7715_data_reverse()
458 s->u.pc.ctr = DCR_INIT_VAL; in parport_mos7715_init_state()
459 s->u.pc.ecr = ECR_INIT_VAL; in parport_mos7715_init_state()
469 mos_parport = pp->private_data; in parport_mos7715_save_state()
474 s->u.pc.ctr = mos_parport->shadowDCR; in parport_mos7715_save_state()
475 s->u.pc.ecr = mos_parport->shadowECR; in parport_mos7715_save_state()
486 mos_parport = pp->private_data; in parport_mos7715_restore_state()
491 mos_parport->shadowDCR = s->u.pc.ctr; in parport_mos7715_restore_state()
492 mos_parport->shadowECR = s->u.pc.ecr; in parport_mos7715_restore_state()
494 schedule_work(&mos_parport->work); in parport_mos7715_restore_state()
503 struct mos7715_parport *mos_parport = pp->private_data; in parport_mos7715_write_compat()
509 retval = usb_bulk_msg(mos_parport->serial->dev, in parport_mos7715_write_compat()
510 usb_sndbulkpipe(mos_parport->serial->dev, 2), in parport_mos7715_write_compat()
515 dev_err(&mos_parport->serial->dev->dev, in parport_mos7715_write_compat()
553 static int mos7715_parport_init(struct usb_serial *serial) in mos7715_parport_init() argument
560 return -ENOMEM; in mos7715_parport_init()
562 mos_parport->msg_pending = false; in mos7715_parport_init()
563 kref_init(&mos_parport->ref_count); in mos7715_parport_init()
564 usb_set_serial_data(serial, mos_parport); /* hijack private pointer */ in mos7715_parport_init()
565 mos_parport->serial = serial; in mos7715_parport_init()
566 INIT_WORK(&mos_parport->work, deferred_restore_writes); in mos7715_parport_init()
567 init_completion(&mos_parport->syncmsg_compl); in mos7715_parport_init()
570 write_mos_reg(mos_parport->serial, dummy, MOS7720_PP_REG, (__u8)0x80); in mos7715_parport_init()
571 write_mos_reg(mos_parport->serial, dummy, MOS7720_PP_REG, (__u8)0x00); in mos7715_parport_init()
574 mos_parport->shadowDCR = DCR_INIT_VAL; in mos7715_parport_init()
575 write_mos_reg(mos_parport->serial, dummy, MOS7720_DCR, in mos7715_parport_init()
576 mos_parport->shadowDCR); in mos7715_parport_init()
577 mos_parport->shadowECR = ECR_INIT_VAL; in mos7715_parport_init()
578 write_mos_reg(mos_parport->serial, dummy, MOS7720_ECR, in mos7715_parport_init()
579 mos_parport->shadowECR); in mos7715_parport_init()
582 mos_parport->pp = parport_register_port(0, PARPORT_IRQ_NONE, in mos7715_parport_init()
585 if (mos_parport->pp == NULL) { in mos7715_parport_init()
586 dev_err(&serial->interface->dev, in mos7715_parport_init()
588 kref_put(&mos_parport->ref_count, destroy_mos_parport); in mos7715_parport_init()
589 return -EIO; in mos7715_parport_init()
591 mos_parport->pp->private_data = mos_parport; in mos7715_parport_init()
592 mos_parport->pp->modes = PARPORT_MODE_COMPAT | PARPORT_MODE_PCSPP; in mos7715_parport_init()
593 mos_parport->pp->dev = &serial->interface->dev; in mos7715_parport_init()
594 parport_announce_port(mos_parport->pp); in mos7715_parport_init()
609 int status = urb->status; in mos7720_interrupt_callback()
610 struct device *dev = &urb->dev->dev; in mos7720_interrupt_callback()
619 case -ECONNRESET: in mos7720_interrupt_callback()
620 case -ENOENT: in mos7720_interrupt_callback()
621 case -ESHUTDOWN: in mos7720_interrupt_callback()
623 dev_dbg(dev, "%s - urb shutting down with status: %d\n", __func__, status); in mos7720_interrupt_callback()
626 dev_dbg(dev, "%s - nonzero urb status received: %d\n", __func__, status); in mos7720_interrupt_callback()
630 length = urb->actual_length; in mos7720_interrupt_callback()
631 data = urb->transfer_buffer; in mos7720_interrupt_callback()
634 * Byte 1 IIR Port 1 (port.number is 0) in mos7720_interrupt_callback()
635 * Byte 2 IIR Port 2 (port.number is 1) in mos7720_interrupt_callback()
636 * Byte 3 -------------- in mos7720_interrupt_callback()
640 * oneukum 2007-03-14 */ in mos7720_interrupt_callback()
656 dev_dbg(dev, "Serial Port 1: Receiver status error or address bit detected in 9-bit mode\n"); in mos7720_interrupt_callback()
659 dev_dbg(dev, "Serial Port 1: Receiver time out\n"); in mos7720_interrupt_callback()
662 /* dev_dbg(dev, "Serial Port 1: Modem status change\n"); */ in mos7720_interrupt_callback()
668 dev_dbg(dev, "Serial Port 2: Receiver status error or address bit detected in 9-bit mode\n"); in mos7720_interrupt_callback()
671 dev_dbg(dev, "Serial Port 2: Receiver time out\n"); in mos7720_interrupt_callback()
674 /* dev_dbg(dev, "Serial Port 2: Modem status change\n"); */ in mos7720_interrupt_callback()
682 dev_err(dev, "%s - Error %d submitting control urb\n", __func__, result); in mos7720_interrupt_callback()
694 int status = urb->status; in mos7715_interrupt_callback()
695 struct device *dev = &urb->dev->dev; in mos7715_interrupt_callback()
703 case -ECONNRESET: in mos7715_interrupt_callback()
704 case -ENOENT: in mos7715_interrupt_callback()
705 case -ESHUTDOWN: in mos7715_interrupt_callback()
706 case -ENODEV: in mos7715_interrupt_callback()
708 dev_dbg(dev, "%s - urb shutting down with status: %d\n", __func__, status); in mos7715_interrupt_callback()
711 dev_dbg(dev, "%s - nonzero urb status received: %d\n", __func__, status); in mos7715_interrupt_callback()
715 length = urb->actual_length; in mos7715_interrupt_callback()
716 data = urb->transfer_buffer; in mos7715_interrupt_callback()
719 * Byte 1: IIR serial Port in mos7715_interrupt_callback()
730 if (!(iir & 0x01)) { /* serial port interrupt pending */ in mos7715_interrupt_callback()
733 dev_dbg(dev, "Serial Port: Receiver status error or address bit detected in 9-bit mode\n"); in mos7715_interrupt_callback()
736 dev_dbg(dev, "Serial Port: Receiver time out\n"); in mos7715_interrupt_callback()
739 /* dev_dbg(dev, "Serial Port: Modem status change\n"); */ in mos7715_interrupt_callback()
746 struct usb_serial_port *port = urb->context; in mos7715_interrupt_callback()
747 struct mos7715_parport *mos_parport = port->serial->private; in mos7715_interrupt_callback()
750 atomic_set(&mos_parport->shadowDSR, data[2]); in mos7715_interrupt_callback()
757 dev_err(dev, "%s - Error %d submitting control urb\n", __func__, result); in mos7715_interrupt_callback()
770 int status = urb->status; in mos7720_bulk_in_callback()
773 dev_dbg(&urb->dev->dev, "nonzero read bulk status received: %d\n", status); in mos7720_bulk_in_callback()
777 port = urb->context; in mos7720_bulk_in_callback()
779 dev_dbg(&port->dev, "Entering...%s\n", __func__); in mos7720_bulk_in_callback()
781 data = urb->transfer_buffer; in mos7720_bulk_in_callback()
783 if (urb->actual_length) { in mos7720_bulk_in_callback()
784 tty_insert_flip_string(&port->port, data, urb->actual_length); in mos7720_bulk_in_callback()
785 tty_flip_buffer_push(&port->port); in mos7720_bulk_in_callback()
788 if (port->read_urb->status != -EINPROGRESS) { in mos7720_bulk_in_callback()
789 retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); in mos7720_bulk_in_callback()
791 dev_dbg(&port->dev, "usb_submit_urb(read bulk) failed, retval = %d\n", retval); in mos7720_bulk_in_callback()
797 * this is the callback function for when we have finished sending serial
803 int status = urb->status; in mos7720_bulk_out_data_callback()
806 dev_dbg(&urb->dev->dev, "nonzero write bulk status received:%d\n", status); in mos7720_bulk_out_data_callback()
810 mos7720_port = urb->context; in mos7720_bulk_out_data_callback()
812 dev_dbg(&urb->dev->dev, "NULL mos7720_port pointer\n"); in mos7720_bulk_out_data_callback()
816 if (mos7720_port->open) in mos7720_bulk_out_data_callback()
817 tty_port_tty_wakeup(&mos7720_port->port->port); in mos7720_bulk_out_data_callback()
820 static int mos77xx_calc_num_ports(struct usb_serial *serial, in mos77xx_calc_num_ports() argument
823 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct); in mos77xx_calc_num_ports()
828 * parallel port, and the second for the serial port. We swap in mos77xx_calc_num_ports()
830 * only registered port structure uses the serial-port in mos77xx_calc_num_ports()
833 swap(epds->bulk_in[0], epds->bulk_in[1]); in mos77xx_calc_num_ports()
834 swap(epds->bulk_out[0], epds->bulk_out[1]); in mos77xx_calc_num_ports()
844 struct usb_serial *serial; in mos7720_open() local
853 serial = port->serial; in mos7720_open()
857 return -ENODEV; in mos7720_open()
859 usb_clear_halt(serial->dev, port->write_urb->pipe); in mos7720_open()
860 usb_clear_halt(serial->dev, port->read_urb->pipe); in mos7720_open()
865 mos7720_port->write_urb_pool[j] = urb; in mos7720_open()
869 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, in mos7720_open()
871 if (!urb->transfer_buffer) { in mos7720_open()
872 usb_free_urb(mos7720_port->write_urb_pool[j]); in mos7720_open()
873 mos7720_port->write_urb_pool[j] = NULL; in mos7720_open()
880 return -ENOMEM; in mos7720_open()
882 /* Initialize MCS7720 -- Write Init values to corresponding Registers in mos7720_open()
896 port_number = port->port_number; in mos7720_open()
897 read_mos_reg(serial, port_number, MOS7720_LSR, &data); in mos7720_open()
899 dev_dbg(&port->dev, "SS::%p LSR:%x\n", mos7720_port, data); in mos7720_open()
901 write_mos_reg(serial, dummy, MOS7720_SP1_REG, 0x02); in mos7720_open()
902 write_mos_reg(serial, dummy, MOS7720_SP2_REG, 0x02); in mos7720_open()
904 write_mos_reg(serial, port_number, MOS7720_IER, 0x00); in mos7720_open()
905 write_mos_reg(serial, port_number, MOS7720_FCR, 0x00); in mos7720_open()
907 write_mos_reg(serial, port_number, MOS7720_FCR, 0xcf); in mos7720_open()
908 mos7720_port->shadowLCR = 0x03; in mos7720_open()
909 write_mos_reg(serial, port_number, MOS7720_LCR, in mos7720_open()
910 mos7720_port->shadowLCR); in mos7720_open()
911 mos7720_port->shadowMCR = 0x0b; in mos7720_open()
912 write_mos_reg(serial, port_number, MOS7720_MCR, in mos7720_open()
913 mos7720_port->shadowMCR); in mos7720_open()
915 write_mos_reg(serial, port_number, MOS7720_SP_CONTROL_REG, 0x00); in mos7720_open()
916 read_mos_reg(serial, dummy, MOS7720_SP_CONTROL_REG, &data); in mos7720_open()
917 data = data | (port->port_number + 1); in mos7720_open()
918 write_mos_reg(serial, dummy, MOS7720_SP_CONTROL_REG, data); in mos7720_open()
919 mos7720_port->shadowLCR = 0x83; in mos7720_open()
920 write_mos_reg(serial, port_number, MOS7720_LCR, in mos7720_open()
921 mos7720_port->shadowLCR); in mos7720_open()
922 write_mos_reg(serial, port_number, MOS7720_THR, 0x0c); in mos7720_open()
923 write_mos_reg(serial, port_number, MOS7720_IER, 0x00); in mos7720_open()
924 mos7720_port->shadowLCR = 0x03; in mos7720_open()
925 write_mos_reg(serial, port_number, MOS7720_LCR, in mos7720_open()
926 mos7720_port->shadowLCR); in mos7720_open()
927 write_mos_reg(serial, port_number, MOS7720_IER, 0x0c); in mos7720_open()
929 response = usb_submit_urb(port->read_urb, GFP_KERNEL); in mos7720_open()
931 dev_err(&port->dev, "%s - Error %d submitting read urb\n", in mos7720_open()
935 mos7720_port->shadowMCR = UART_MCR_OUT2; /* Must set to enable ints! */ in mos7720_open()
938 mos7720_port->open = 1; in mos7720_open()
951 struct usb_serial_port *port = tty->driver_data; in mos7720_chars_in_buffer()
957 if (mos7720_port->write_urb_pool[i] && in mos7720_chars_in_buffer()
958 mos7720_port->write_urb_pool[i]->status == -EINPROGRESS) in mos7720_chars_in_buffer()
961 dev_dbg(&port->dev, "%s - returns %u\n", __func__, chars); in mos7720_chars_in_buffer()
967 struct usb_serial *serial; in mos7720_close() local
971 serial = port->serial; in mos7720_close()
978 usb_kill_urb(mos7720_port->write_urb_pool[j]); in mos7720_close()
982 if (mos7720_port->write_urb_pool[j]) { in mos7720_close()
983 kfree(mos7720_port->write_urb_pool[j]->transfer_buffer); in mos7720_close()
984 usb_free_urb(mos7720_port->write_urb_pool[j]); in mos7720_close()
990 usb_kill_urb(port->write_urb); in mos7720_close()
991 usb_kill_urb(port->read_urb); in mos7720_close()
993 write_mos_reg(serial, port->port_number, MOS7720_MCR, 0x00); in mos7720_close()
994 write_mos_reg(serial, port->port_number, MOS7720_IER, 0x00); in mos7720_close()
996 mos7720_port->open = 0; in mos7720_close()
1001 struct usb_serial_port *port = tty->driver_data; in mos7720_break()
1003 struct usb_serial *serial; in mos7720_break() local
1006 serial = port->serial; in mos7720_break()
1010 return -ENODEV; in mos7720_break()
1012 if (break_state == -1) in mos7720_break()
1013 data = mos7720_port->shadowLCR | UART_LCR_SBC; in mos7720_break()
1015 data = mos7720_port->shadowLCR & ~UART_LCR_SBC; in mos7720_break()
1017 mos7720_port->shadowLCR = data; in mos7720_break()
1019 return write_mos_reg(serial, port->port_number, MOS7720_LCR, in mos7720_break()
1020 mos7720_port->shadowLCR); in mos7720_break()
1030 struct usb_serial_port *port = tty->driver_data; in mos7720_write_room()
1037 if (mos7720_port->write_urb_pool[i] && in mos7720_write_room()
1038 mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) in mos7720_write_room()
1042 dev_dbg(&port->dev, "%s - returns %u\n", __func__, room); in mos7720_write_room()
1055 struct usb_serial *serial; in mos7720_write() local
1059 serial = port->serial; in mos7720_write()
1063 return -ENODEV; in mos7720_write()
1069 if (mos7720_port->write_urb_pool[i] && in mos7720_write()
1070 mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) { in mos7720_write()
1071 urb = mos7720_port->write_urb_pool[i]; in mos7720_write()
1072 dev_dbg(&port->dev, "URB:%d\n", i); in mos7720_write()
1078 dev_dbg(&port->dev, "%s - no more free urbs\n", __func__); in mos7720_write()
1082 if (urb->transfer_buffer == NULL) { in mos7720_write()
1083 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, in mos7720_write()
1085 if (!urb->transfer_buffer) { in mos7720_write()
1086 bytes_sent = -ENOMEM; in mos7720_write()
1092 memcpy(urb->transfer_buffer, current_position, transfer_size); in mos7720_write()
1093 usb_serial_debug_data(&port->dev, __func__, transfer_size, in mos7720_write()
1094 urb->transfer_buffer); in mos7720_write()
1097 usb_fill_bulk_urb(urb, serial->dev, in mos7720_write()
1098 usb_sndbulkpipe(serial->dev, in mos7720_write()
1099 port->bulk_out_endpointAddress), in mos7720_write()
1100 urb->transfer_buffer, transfer_size, in mos7720_write()
1106 dev_err_console(port, "%s - usb_submit_urb(write bulk) failed " in mos7720_write()
1119 struct usb_serial_port *port = tty->driver_data; in mos7720_throttle()
1128 if (!mos7720_port->open) { in mos7720_throttle()
1129 dev_dbg(&port->dev, "%s - port not opened\n", __func__); in mos7720_throttle()
1143 mos7720_port->shadowMCR &= ~UART_MCR_RTS; in mos7720_throttle()
1144 write_mos_reg(port->serial, port->port_number, MOS7720_MCR, in mos7720_throttle()
1145 mos7720_port->shadowMCR); in mos7720_throttle()
1151 struct usb_serial_port *port = tty->driver_data; in mos7720_unthrottle()
1158 if (!mos7720_port->open) { in mos7720_unthrottle()
1159 dev_dbg(&port->dev, "%s - port not opened\n", __func__); in mos7720_unthrottle()
1173 mos7720_port->shadowMCR |= UART_MCR_RTS; in mos7720_unthrottle()
1174 write_mos_reg(port->serial, port->port_number, MOS7720_MCR, in mos7720_unthrottle()
1175 mos7720_port->shadowMCR); in mos7720_unthrottle()
1184 struct usb_serial *serial; in set_higher_rates() local
1188 return -EINVAL; in set_higher_rates()
1190 port = mos7720_port->port; in set_higher_rates()
1191 serial = port->serial; in set_higher_rates()
1196 dev_dbg(&port->dev, "Sending Setting Commands ..........\n"); in set_higher_rates()
1197 port_number = port->port_number; in set_higher_rates()
1199 write_mos_reg(serial, port_number, MOS7720_IER, 0x00); in set_higher_rates()
1200 write_mos_reg(serial, port_number, MOS7720_FCR, 0x00); in set_higher_rates()
1201 write_mos_reg(serial, port_number, MOS7720_FCR, 0xcf); in set_higher_rates()
1202 mos7720_port->shadowMCR = 0x0b; in set_higher_rates()
1203 write_mos_reg(serial, port_number, MOS7720_MCR, in set_higher_rates()
1204 mos7720_port->shadowMCR); in set_higher_rates()
1205 write_mos_reg(serial, dummy, MOS7720_SP_CONTROL_REG, 0x00); in set_higher_rates()
1215 write_mos_reg(serial, dummy, sp_reg, baud * 0x10); in set_higher_rates()
1216 write_mos_reg(serial, dummy, MOS7720_SP_CONTROL_REG, 0x03); in set_higher_rates()
1217 mos7720_port->shadowMCR = 0x2b; in set_higher_rates()
1218 write_mos_reg(serial, port_number, MOS7720_MCR, in set_higher_rates()
1219 mos7720_port->shadowMCR); in set_higher_rates()
1224 mos7720_port->shadowLCR = mos7720_port->shadowLCR | UART_LCR_DLAB; in set_higher_rates()
1225 write_mos_reg(serial, port_number, MOS7720_LCR, in set_higher_rates()
1226 mos7720_port->shadowLCR); in set_higher_rates()
1227 write_mos_reg(serial, port_number, MOS7720_DLL, 0x01); in set_higher_rates()
1228 write_mos_reg(serial, port_number, MOS7720_DLM, 0x00); in set_higher_rates()
1229 mos7720_port->shadowLCR = mos7720_port->shadowLCR & ~UART_LCR_DLAB; in set_higher_rates()
1230 write_mos_reg(serial, port_number, MOS7720_LCR, in set_higher_rates()
1231 mos7720_port->shadowLCR); in set_higher_rates()
1277 dev_dbg(&port->dev, "%s - %d\n", __func__, baudrate); in calc_baud_rate_divisor()
1294 round = (__u16)(round1 - (custom * 10)); in calc_baud_rate_divisor()
1299 dev_dbg(&port->dev, "Baud %d = %d\n", baudrate, custom); in calc_baud_rate_divisor()
1303 dev_dbg(&port->dev, "Baud calculation Failed...\n"); in calc_baud_rate_divisor()
1304 return -EINVAL; in calc_baud_rate_divisor()
1316 struct usb_serial *serial; in send_cmd_write_baud_rate() local
1319 unsigned char number; in send_cmd_write_baud_rate() local
1322 return -1; in send_cmd_write_baud_rate()
1324 port = mos7720_port->port; in send_cmd_write_baud_rate()
1325 serial = port->serial; in send_cmd_write_baud_rate()
1327 number = port->port_number; in send_cmd_write_baud_rate()
1328 dev_dbg(&port->dev, "%s - baud = %d\n", __func__, baudrate); in send_cmd_write_baud_rate()
1333 dev_err(&port->dev, "%s - bad baud rate\n", __func__); in send_cmd_write_baud_rate()
1338 mos7720_port->shadowLCR = mos7720_port->shadowLCR | UART_LCR_DLAB; in send_cmd_write_baud_rate()
1339 write_mos_reg(serial, number, MOS7720_LCR, mos7720_port->shadowLCR); in send_cmd_write_baud_rate()
1342 write_mos_reg(serial, number, MOS7720_DLL, (__u8)(divisor & 0xff)); in send_cmd_write_baud_rate()
1343 write_mos_reg(serial, number, MOS7720_DLM, in send_cmd_write_baud_rate()
1347 mos7720_port->shadowLCR = mos7720_port->shadowLCR & ~UART_LCR_DLAB; in send_cmd_write_baud_rate()
1348 write_mos_reg(serial, number, MOS7720_LCR, mos7720_port->shadowLCR); in send_cmd_write_baud_rate()
1363 struct usb_serial *serial; in change_port_settings() local
1375 port = mos7720_port->port; in change_port_settings()
1376 serial = port->serial; in change_port_settings()
1377 port_number = port->port_number; in change_port_settings()
1379 if (!mos7720_port->open) { in change_port_settings()
1380 dev_dbg(&port->dev, "%s - port not opened\n", __func__); in change_port_settings()
1387 cflag = tty->termios.c_cflag; in change_port_settings()
1395 dev_dbg(&port->dev, "%s - parity = odd\n", __func__); in change_port_settings()
1398 dev_dbg(&port->dev, "%s - parity = even\n", __func__); in change_port_settings()
1402 dev_dbg(&port->dev, "%s - parity = none\n", __func__); in change_port_settings()
1411 dev_dbg(&port->dev, "%s - stop bits = 2\n", __func__); in change_port_settings()
1414 dev_dbg(&port->dev, "%s - stop bits = 1\n", __func__); in change_port_settings()
1422 mos7720_port->shadowLCR &= in change_port_settings()
1424 mos7720_port->shadowLCR |= (lData | lParity | lStop); in change_port_settings()
1428 write_mos_reg(serial, port_number, MOS7720_IER, 0x00); in change_port_settings()
1429 write_mos_reg(serial, port_number, MOS7720_FCR, 0x00); in change_port_settings()
1430 write_mos_reg(serial, port_number, MOS7720_FCR, 0xcf); in change_port_settings()
1433 write_mos_reg(serial, port_number, MOS7720_LCR, in change_port_settings()
1434 mos7720_port->shadowLCR); in change_port_settings()
1435 mos7720_port->shadowMCR = 0x0b; in change_port_settings()
1436 write_mos_reg(serial, port_number, MOS7720_MCR, in change_port_settings()
1437 mos7720_port->shadowMCR); in change_port_settings()
1440 mos7720_port->shadowMCR = UART_MCR_OUT2; in change_port_settings()
1442 mos7720_port->shadowMCR |= (UART_MCR_DTR | UART_MCR_RTS); in change_port_settings()
1445 mos7720_port->shadowMCR |= (UART_MCR_XONANY); in change_port_settings()
1447 * serial port, in SP1/2_CONTROL_REG */ in change_port_settings()
1449 write_mos_reg(serial, dummy, MOS7720_SP_CONTROL_REG, in change_port_settings()
1452 write_mos_reg(serial, dummy, MOS7720_SP_CONTROL_REG, in change_port_settings()
1456 mos7720_port->shadowMCR &= ~(UART_MCR_XONANY); in change_port_settings()
1458 write_mos_reg(serial, port_number, MOS7720_MCR, in change_port_settings()
1459 mos7720_port->shadowMCR); in change_port_settings()
1465 dev_dbg(&port->dev, "Picked default baud...\n"); in change_port_settings()
1472 write_mos_reg(serial, port_number, MOS7720_IER, 0x0c); in change_port_settings()
1476 dev_dbg(&port->dev, "%s - baud rate = %d\n", __func__, baud); in change_port_settings()
1483 write_mos_reg(serial, port_number, MOS7720_IER, 0x0c); in change_port_settings()
1485 if (port->read_urb->status != -EINPROGRESS) { in change_port_settings()
1486 status = usb_submit_urb(port->read_urb, GFP_KERNEL); in change_port_settings()
1488 dev_dbg(&port->dev, "usb_submit_urb(read bulk) failed, status = %d\n", status); in change_port_settings()
1509 if (!mos7720_port->open) { in mos7720_set_termios()
1510 dev_dbg(&port->dev, "%s - port not opened\n", __func__); in mos7720_set_termios()
1517 if (port->read_urb->status != -EINPROGRESS) { in mos7720_set_termios()
1518 status = usb_submit_urb(port->read_urb, GFP_KERNEL); in mos7720_set_termios()
1520 dev_dbg(&port->dev, "usb_submit_urb(read bulk) failed, status = %d\n", status); in mos7720_set_termios()
1525 * get_lsr_info - get line status register info
1537 struct usb_serial_port *port = tty->driver_data; in get_lsr_info()
1540 int port_number = port->port_number; in get_lsr_info()
1545 read_mos_reg(port->serial, port_number, MOS7720_LSR, &data); in get_lsr_info()
1548 dev_dbg(&port->dev, "%s -- Empty\n", __func__); in get_lsr_info()
1553 return -EFAULT; in get_lsr_info()
1559 struct usb_serial_port *port = tty->driver_data; in mos7720_tiocmget()
1565 mcr = mos7720_port->shadowMCR; in mos7720_tiocmget()
1566 msr = mos7720_port->shadowMSR; in mos7720_tiocmget()
1581 struct usb_serial_port *port = tty->driver_data; in mos7720_tiocmset()
1585 mcr = mos7720_port->shadowMCR; in mos7720_tiocmset()
1601 mos7720_port->shadowMCR = mcr; in mos7720_tiocmset()
1602 write_mos_reg(port->serial, port->port_number, MOS7720_MCR, in mos7720_tiocmset()
1603 mos7720_port->shadowMCR); in mos7720_tiocmset()
1611 struct usb_serial_port *port = tty->driver_data; in mos7720_ioctl()
1616 return -ENODEV; in mos7720_ioctl()
1620 dev_dbg(&port->dev, "%s TIOCSERGETLSR\n", __func__); in mos7720_ioctl()
1625 return -ENOIOCTLCMD; in mos7720_ioctl()
1628 static int mos7720_startup(struct usb_serial *serial) in mos7720_startup() argument
1635 product = le16_to_cpu(serial->dev->descriptor.idProduct); in mos7720_startup()
1636 dev = serial->dev; in mos7720_startup()
1639 struct urb *urb = serial->port[0]->interrupt_in_urb; in mos7720_startup()
1641 urb->complete = mos7715_interrupt_callback; in mos7720_startup()
1644 ret_val = mos7715_parport_init(serial); in mos7720_startup()
1650 ret_val = usb_submit_urb(serial->port[0]->interrupt_in_urb, GFP_KERNEL); in mos7720_startup()
1652 dev_err(&dev->dev, "failed to submit interrupt urb: %d\n", in mos7720_startup()
1657 read_mos_reg(serial, 0, MOS7720_LSR, &data); in mos7720_startup()
1658 dev_dbg(&dev->dev, "LSR:%x\n", data); in mos7720_startup()
1663 static void mos7720_release(struct usb_serial *serial) in mos7720_release() argument
1665 usb_kill_urb(serial->port[0]->interrupt_in_urb); in mos7720_release()
1670 if (le16_to_cpu(serial->dev->descriptor.idProduct) in mos7720_release()
1673 usb_get_serial_data(serial); in mos7720_release()
1677 mos_parport->pp->private_data = NULL; in mos7720_release()
1681 if (mos_parport->msg_pending) in mos7720_release()
1682 wait_for_completion_timeout(&mos_parport->syncmsg_compl, in mos7720_release()
1687 * below serial clearing is not hoisted above the ->work. in mos7720_release()
1689 cancel_work_sync(&mos_parport->work); in mos7720_release()
1691 parport_remove_port(mos_parport->pp); in mos7720_release()
1692 usb_set_serial_data(serial, NULL); in mos7720_release()
1693 mos_parport->serial = NULL; in mos7720_release()
1695 parport_del_port(mos_parport->pp); in mos7720_release()
1697 kref_put(&mos_parport->ref_count, destroy_mos_parport); in mos7720_release()
1708 return -ENOMEM; in mos7720_port_probe()
1710 mos7720_port->port = port; in mos7720_port_probe()