diff options
Diffstat (limited to 'drivers/usb/serial/mos7840.c')
-rw-r--r-- | drivers/usb/serial/mos7840.c | 142 |
1 files changed, 63 insertions, 79 deletions
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index 03b5e249e95e..c526550694a0 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c | |||
@@ -174,6 +174,7 @@ | |||
174 | 174 | ||
175 | #define CLK_MULTI_REGISTER ((__u16)(0x02)) | 175 | #define CLK_MULTI_REGISTER ((__u16)(0x02)) |
176 | #define CLK_START_VALUE_REGISTER ((__u16)(0x03)) | 176 | #define CLK_START_VALUE_REGISTER ((__u16)(0x03)) |
177 | #define GPIO_REGISTER ((__u16)(0x07)) | ||
177 | 178 | ||
178 | #define SERIAL_LCR_DLAB ((__u16)(0x0080)) | 179 | #define SERIAL_LCR_DLAB ((__u16)(0x0080)) |
179 | 180 | ||
@@ -1101,14 +1102,25 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1101 | mos7840_port->read_urb = port->read_urb; | 1102 | mos7840_port->read_urb = port->read_urb; |
1102 | 1103 | ||
1103 | /* set up our bulk in urb */ | 1104 | /* set up our bulk in urb */ |
1104 | 1105 | if ((serial->num_ports == 2) | |
1105 | usb_fill_bulk_urb(mos7840_port->read_urb, | 1106 | && ((((__u16)port->number - |
1106 | serial->dev, | 1107 | (__u16)(port->serial->minor)) % 2) != 0)) { |
1107 | usb_rcvbulkpipe(serial->dev, | 1108 | usb_fill_bulk_urb(mos7840_port->read_urb, |
1108 | port->bulk_in_endpointAddress), | 1109 | serial->dev, |
1109 | port->bulk_in_buffer, | 1110 | usb_rcvbulkpipe(serial->dev, |
1110 | mos7840_port->read_urb->transfer_buffer_length, | 1111 | (port->bulk_in_endpointAddress) + 2), |
1111 | mos7840_bulk_in_callback, mos7840_port); | 1112 | port->bulk_in_buffer, |
1113 | mos7840_port->read_urb->transfer_buffer_length, | ||
1114 | mos7840_bulk_in_callback, mos7840_port); | ||
1115 | } else { | ||
1116 | usb_fill_bulk_urb(mos7840_port->read_urb, | ||
1117 | serial->dev, | ||
1118 | usb_rcvbulkpipe(serial->dev, | ||
1119 | port->bulk_in_endpointAddress), | ||
1120 | port->bulk_in_buffer, | ||
1121 | mos7840_port->read_urb->transfer_buffer_length, | ||
1122 | mos7840_bulk_in_callback, mos7840_port); | ||
1123 | } | ||
1112 | 1124 | ||
1113 | dbg("mos7840_open: bulkin endpoint is %d", | 1125 | dbg("mos7840_open: bulkin endpoint is %d", |
1114 | port->bulk_in_endpointAddress); | 1126 | port->bulk_in_endpointAddress); |
@@ -1509,7 +1521,7 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1509 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); | 1521 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); |
1510 | 1522 | ||
1511 | if (urb->transfer_buffer == NULL) { | 1523 | if (urb->transfer_buffer == NULL) { |
1512 | dev_err(&port->dev, "%s no more kernel memory...\n", | 1524 | dev_err_console(port, "%s no more kernel memory...\n", |
1513 | __func__); | 1525 | __func__); |
1514 | goto exit; | 1526 | goto exit; |
1515 | } | 1527 | } |
@@ -1519,13 +1531,25 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1519 | memcpy(urb->transfer_buffer, current_position, transfer_size); | 1531 | memcpy(urb->transfer_buffer, current_position, transfer_size); |
1520 | 1532 | ||
1521 | /* fill urb with data and submit */ | 1533 | /* fill urb with data and submit */ |
1522 | usb_fill_bulk_urb(urb, | 1534 | if ((serial->num_ports == 2) |
1523 | serial->dev, | 1535 | && ((((__u16)port->number - |
1524 | usb_sndbulkpipe(serial->dev, | 1536 | (__u16)(port->serial->minor)) % 2) != 0)) { |
1525 | port->bulk_out_endpointAddress), | 1537 | usb_fill_bulk_urb(urb, |
1526 | urb->transfer_buffer, | 1538 | serial->dev, |
1527 | transfer_size, | 1539 | usb_sndbulkpipe(serial->dev, |
1528 | mos7840_bulk_out_data_callback, mos7840_port); | 1540 | (port->bulk_out_endpointAddress) + 2), |
1541 | urb->transfer_buffer, | ||
1542 | transfer_size, | ||
1543 | mos7840_bulk_out_data_callback, mos7840_port); | ||
1544 | } else { | ||
1545 | usb_fill_bulk_urb(urb, | ||
1546 | serial->dev, | ||
1547 | usb_sndbulkpipe(serial->dev, | ||
1548 | port->bulk_out_endpointAddress), | ||
1549 | urb->transfer_buffer, | ||
1550 | transfer_size, | ||
1551 | mos7840_bulk_out_data_callback, mos7840_port); | ||
1552 | } | ||
1529 | 1553 | ||
1530 | data1 = urb->transfer_buffer; | 1554 | data1 = urb->transfer_buffer; |
1531 | dbg("bulkout endpoint is %d", port->bulk_out_endpointAddress); | 1555 | dbg("bulkout endpoint is %d", port->bulk_out_endpointAddress); |
@@ -1535,7 +1559,7 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1535 | 1559 | ||
1536 | if (status) { | 1560 | if (status) { |
1537 | mos7840_port->busy[i] = 0; | 1561 | mos7840_port->busy[i] = 0; |
1538 | dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed " | 1562 | dev_err_console(port, "%s - usb_submit_urb(write bulk) failed " |
1539 | "with status = %d\n", __func__, status); | 1563 | "with status = %d\n", __func__, status); |
1540 | bytes_sent = status; | 1564 | bytes_sent = status; |
1541 | goto exit; | 1565 | goto exit; |
@@ -1838,7 +1862,7 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, | |||
1838 | 1862 | ||
1839 | } else { | 1863 | } else { |
1840 | #ifdef HW_flow_control | 1864 | #ifdef HW_flow_control |
1841 | / *setting h/w flow control bit to 0 */ | 1865 | /* setting h/w flow control bit to 0 */ |
1842 | Data = 0xb; | 1866 | Data = 0xb; |
1843 | mos7840_port->shadowMCR = Data; | 1867 | mos7840_port->shadowMCR = Data; |
1844 | status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, | 1868 | status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, |
@@ -2305,19 +2329,26 @@ static int mos7840_ioctl(struct tty_struct *tty, | |||
2305 | 2329 | ||
2306 | static int mos7840_calc_num_ports(struct usb_serial *serial) | 2330 | static int mos7840_calc_num_ports(struct usb_serial *serial) |
2307 | { | 2331 | { |
2308 | int mos7840_num_ports = 0; | 2332 | __u16 Data = 0x00; |
2309 | 2333 | int ret = 0; | |
2310 | dbg("numberofendpoints: cur %d, alt %d", | 2334 | int mos7840_num_ports; |
2311 | (int)serial->interface->cur_altsetting->desc.bNumEndpoints, | 2335 | |
2312 | (int)serial->interface->altsetting->desc.bNumEndpoints); | 2336 | ret = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), |
2313 | if (serial->interface->cur_altsetting->desc.bNumEndpoints == 5) { | 2337 | MCS_RDREQ, MCS_RD_RTYPE, 0, GPIO_REGISTER, &Data, |
2314 | mos7840_num_ports = serial->num_ports = 2; | 2338 | VENDOR_READ_LENGTH, MOS_WDR_TIMEOUT); |
2315 | } else if (serial->interface->cur_altsetting->desc.bNumEndpoints == 9) { | 2339 | |
2340 | if ((Data & 0x01) == 0) { | ||
2341 | mos7840_num_ports = 2; | ||
2342 | serial->num_bulk_in = 2; | ||
2343 | serial->num_bulk_out = 2; | ||
2344 | serial->num_ports = 2; | ||
2345 | } else { | ||
2346 | mos7840_num_ports = 4; | ||
2316 | serial->num_bulk_in = 4; | 2347 | serial->num_bulk_in = 4; |
2317 | serial->num_bulk_out = 4; | 2348 | serial->num_bulk_out = 4; |
2318 | mos7840_num_ports = serial->num_ports = 4; | 2349 | serial->num_ports = 4; |
2319 | } | 2350 | } |
2320 | dbg ("mos7840_num_ports = %d", mos7840_num_ports); | 2351 | |
2321 | return mos7840_num_ports; | 2352 | return mos7840_num_ports; |
2322 | } | 2353 | } |
2323 | 2354 | ||
@@ -2638,7 +2669,6 @@ static struct usb_driver io_driver = { | |||
2638 | .probe = usb_serial_probe, | 2669 | .probe = usb_serial_probe, |
2639 | .disconnect = usb_serial_disconnect, | 2670 | .disconnect = usb_serial_disconnect, |
2640 | .id_table = moschip_id_table_combined, | 2671 | .id_table = moschip_id_table_combined, |
2641 | .no_dynamic_id = 1, | ||
2642 | }; | 2672 | }; |
2643 | 2673 | ||
2644 | static struct usb_serial_driver moschip7840_4port_device = { | 2674 | static struct usb_serial_driver moschip7840_4port_device = { |
@@ -2647,7 +2677,6 @@ static struct usb_serial_driver moschip7840_4port_device = { | |||
2647 | .name = "mos7840", | 2677 | .name = "mos7840", |
2648 | }, | 2678 | }, |
2649 | .description = DRIVER_DESC, | 2679 | .description = DRIVER_DESC, |
2650 | .usb_driver = &io_driver, | ||
2651 | .id_table = moschip_port_id_table, | 2680 | .id_table = moschip_port_id_table, |
2652 | .num_ports = 4, | 2681 | .num_ports = 4, |
2653 | .open = mos7840_open, | 2682 | .open = mos7840_open, |
@@ -2674,57 +2703,12 @@ static struct usb_serial_driver moschip7840_4port_device = { | |||
2674 | .read_int_callback = mos7840_interrupt_callback, | 2703 | .read_int_callback = mos7840_interrupt_callback, |
2675 | }; | 2704 | }; |
2676 | 2705 | ||
2677 | /**************************************************************************** | 2706 | static struct usb_serial_driver * const serial_drivers[] = { |
2678 | * moschip7840_init | 2707 | &moschip7840_4port_device, NULL |
2679 | * This is called by the module subsystem, or on startup to initialize us | 2708 | }; |
2680 | ****************************************************************************/ | ||
2681 | static int __init moschip7840_init(void) | ||
2682 | { | ||
2683 | int retval; | ||
2684 | |||
2685 | dbg("%s", " mos7840_init :entering.........."); | ||
2686 | |||
2687 | /* Register with the usb serial */ | ||
2688 | retval = usb_serial_register(&moschip7840_4port_device); | ||
2689 | |||
2690 | if (retval) | ||
2691 | goto failed_port_device_register; | ||
2692 | |||
2693 | dbg("%s", "Entering..."); | ||
2694 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
2695 | DRIVER_DESC "\n"); | ||
2696 | |||
2697 | /* Register with the usb */ | ||
2698 | retval = usb_register(&io_driver); | ||
2699 | if (retval == 0) { | ||
2700 | dbg("%s", "Leaving..."); | ||
2701 | return 0; | ||
2702 | } | ||
2703 | usb_serial_deregister(&moschip7840_4port_device); | ||
2704 | failed_port_device_register: | ||
2705 | return retval; | ||
2706 | } | ||
2707 | |||
2708 | /**************************************************************************** | ||
2709 | * moschip7840_exit | ||
2710 | * Called when the driver is about to be unloaded. | ||
2711 | ****************************************************************************/ | ||
2712 | static void __exit moschip7840_exit(void) | ||
2713 | { | ||
2714 | |||
2715 | dbg("%s", " mos7840_exit :entering.........."); | ||
2716 | |||
2717 | usb_deregister(&io_driver); | ||
2718 | |||
2719 | usb_serial_deregister(&moschip7840_4port_device); | ||
2720 | |||
2721 | dbg("%s", "Entering..."); | ||
2722 | } | ||
2723 | 2709 | ||
2724 | module_init(moschip7840_init); | 2710 | module_usb_serial_driver(io_driver, serial_drivers); |
2725 | module_exit(moschip7840_exit); | ||
2726 | 2711 | ||
2727 | /* Module information */ | ||
2728 | MODULE_DESCRIPTION(DRIVER_DESC); | 2712 | MODULE_DESCRIPTION(DRIVER_DESC); |
2729 | MODULE_LICENSE("GPL"); | 2713 | MODULE_LICENSE("GPL"); |
2730 | 2714 | ||