Re: [PATCH v2] USB: serial: add nt124 usb to serial driver
On Tue, Mar 03, 2015 at 11:57:04AM -0600, George McCollister wrote: This driver is for the NovaTech 124 4x serial expansion board for the NovaTech OrionLXm. Firmware source code can be found here: https://github.com/novatechweb/nt124 Signed-off-by: George McCollister george.mccollis...@gmail.com --- Changes to v1: - Added description after nt124.c on line 2. - Removed DRIVER_AUTHOR and DRIVER_DESC, use MODULE macros directly. - Removed some unnecessary new lines and comments. - Removed __packed from struct nt124_line_coding. - Added locking around ctrlin and ctrlout. - Switch ctrlin and ctrlout from unsigned int to u16. - Removed serial_transmit and added tx_empty. Use a hybrid notification/polling method to accurately determine when transmission is finished while minimizing bus traffic (see comments in the code for details). - Removed flowctrl from struct nt124_line_coding. - Use u16 for request and value, size_t for len arguments of nt124_ctrl_msg() - Use USB_CTRL_SET_TIMEOUT instead of 5000. - Use %04x for 16-bit variables and %zu for size_t variables in dev_dbg() and dev_err(). - Removed use of ?: constructs. - Removed nt124_set_control, nt124_set_line, nt124_send_break and - nt124_set_flowctrl macros in favor of calling nt124_ctrl_msg() directly. - Renamed nt124_process_notify() to nt124_process_status(). - Call usb_serial_handle_dcd_change() unconditionally when DCD has changed. - Removed in argument list assignments. - Use usb_translate_errors() in nt124_port_tiocmset(). - Use C_CSTOPB, C_CSIZE, C_PARENB, C_CMSPAR, C_PARODD, C_CRTSCTS macros. - Raise/lower RTS on !B0/B0. - Added NT124_BREAK_ON and NT124_BREAK_OFF #defines. - Change nt124_open() to just call nt124_set_termios() followed by usb_serial_generic_open(). - Don't set bulk_in_size and bulk_out_size. - Performed thorough testing. Thanks for the update. Looks really good, but I have few comments below. drivers/usb/serial/Kconfig | 9 + drivers/usb/serial/Makefile | 1 + drivers/usb/serial/nt124.c | 501 3 files changed, 511 insertions(+) create mode 100644 drivers/usb/serial/nt124.c diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index b7cf198..677a26a 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig @@ -510,6 +510,15 @@ config USB_SERIAL_NAVMAN To compile this driver as a module, choose M here: the module will be called navman. +config USB_SERIAL_NT124 + tristate USB NovaTech 124 Serial Driver + help + Say Y here if you want to use the NovaTech 124 4x USB to serial + board. + + To compile this driver as a module, choose M here: the + module will be called nt124. + config USB_SERIAL_PL2303 tristate USB Prolific 2303 Single Port Serial Driver help diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile index 349d9df..f88eaab 100644 --- a/drivers/usb/serial/Makefile +++ b/drivers/usb/serial/Makefile @@ -39,6 +39,7 @@ obj-$(CONFIG_USB_SERIAL_MOS7720)+= mos7720.o obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o obj-$(CONFIG_USB_SERIAL_MXUPORT) += mxuport.o obj-$(CONFIG_USB_SERIAL_NAVMAN) += navman.o +obj-$(CONFIG_USB_SERIAL_NT124) += nt124.o obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o obj-$(CONFIG_USB_SERIAL_OPTICON) += opticon.o obj-$(CONFIG_USB_SERIAL_OPTION) += option.o diff --git a/drivers/usb/serial/nt124.c b/drivers/usb/serial/nt124.c new file mode 100644 index 000..d837593 --- /dev/null +++ b/drivers/usb/serial/nt124.c @@ -0,0 +1,501 @@ +/* + * nt124.c - Driver for nt124 4x serial board based on STM32F103 + * + * Copyright (c) 2014 - 2015 NovaTech LLC + * + * Portions derived from the cdc-acm driver + * + * The original intention was to implement a cdc-acm compliant + * 4x USB to serial converter in the STM32F103 however several problems arose. + * The STM32F103 didn't have enough end points to implement 4 ports. + * CTS control was required by the application. + * Accurate notification of transmission completion was required. + * RTSCTS flow control support was required. + * + * The interrupt endpoint was eliminated and the control line information + * was moved to the first two bytes of the bulk in endpoint message. CTS + * control and mechanisms to enable RTSCTS flow control and deliver TXEMPTY + * information were added. + * + * Firmware source code can be found here: + * https://github.com/novatechweb/nt124 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your
Re: [PATCH v2] USB: serial: add nt124 usb to serial driver
On Tue, Mar 03, 2015 at 11:57:04AM -0600, George McCollister wrote: This driver is for the NovaTech 124 4x serial expansion board for the NovaTech OrionLXm. Firmware source code can be found here: https://github.com/novatechweb/nt124 Signed-off-by: George McCollister george.mccollis...@gmail.com Thanks for the v2, George. And sorry for not getting back to you sooner. I'll try to find time to review it this week. Johan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] USB: serial: add nt124 usb to serial driver
This driver is for the NovaTech 124 4x serial expansion board for the NovaTech OrionLXm. Firmware source code can be found here: https://github.com/novatechweb/nt124 Signed-off-by: George McCollister george.mccollis...@gmail.com --- Changes to v1: - Added description after nt124.c on line 2. - Removed DRIVER_AUTHOR and DRIVER_DESC, use MODULE macros directly. - Removed some unnecessary new lines and comments. - Removed __packed from struct nt124_line_coding. - Added locking around ctrlin and ctrlout. - Switch ctrlin and ctrlout from unsigned int to u16. - Removed serial_transmit and added tx_empty. Use a hybrid notification/polling method to accurately determine when transmission is finished while minimizing bus traffic (see comments in the code for details). - Removed flowctrl from struct nt124_line_coding. - Use u16 for request and value, size_t for len arguments of nt124_ctrl_msg() - Use USB_CTRL_SET_TIMEOUT instead of 5000. - Use %04x for 16-bit variables and %zu for size_t variables in dev_dbg() and dev_err(). - Removed use of ?: constructs. - Removed nt124_set_control, nt124_set_line, nt124_send_break and - nt124_set_flowctrl macros in favor of calling nt124_ctrl_msg() directly. - Renamed nt124_process_notify() to nt124_process_status(). - Call usb_serial_handle_dcd_change() unconditionally when DCD has changed. - Removed in argument list assignments. - Use usb_translate_errors() in nt124_port_tiocmset(). - Use C_CSTOPB, C_CSIZE, C_PARENB, C_CMSPAR, C_PARODD, C_CRTSCTS macros. - Raise/lower RTS on !B0/B0. - Added NT124_BREAK_ON and NT124_BREAK_OFF #defines. - Change nt124_open() to just call nt124_set_termios() followed by usb_serial_generic_open(). - Don't set bulk_in_size and bulk_out_size. - Performed thorough testing. drivers/usb/serial/Kconfig | 9 + drivers/usb/serial/Makefile | 1 + drivers/usb/serial/nt124.c | 501 3 files changed, 511 insertions(+) create mode 100644 drivers/usb/serial/nt124.c diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index b7cf198..677a26a 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig @@ -510,6 +510,15 @@ config USB_SERIAL_NAVMAN To compile this driver as a module, choose M here: the module will be called navman. +config USB_SERIAL_NT124 + tristate USB NovaTech 124 Serial Driver + help + Say Y here if you want to use the NovaTech 124 4x USB to serial + board. + + To compile this driver as a module, choose M here: the + module will be called nt124. + config USB_SERIAL_PL2303 tristate USB Prolific 2303 Single Port Serial Driver help diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile index 349d9df..f88eaab 100644 --- a/drivers/usb/serial/Makefile +++ b/drivers/usb/serial/Makefile @@ -39,6 +39,7 @@ obj-$(CONFIG_USB_SERIAL_MOS7720) += mos7720.o obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o obj-$(CONFIG_USB_SERIAL_MXUPORT) += mxuport.o obj-$(CONFIG_USB_SERIAL_NAVMAN)+= navman.o +obj-$(CONFIG_USB_SERIAL_NT124) += nt124.o obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o obj-$(CONFIG_USB_SERIAL_OPTICON) += opticon.o obj-$(CONFIG_USB_SERIAL_OPTION)+= option.o diff --git a/drivers/usb/serial/nt124.c b/drivers/usb/serial/nt124.c new file mode 100644 index 000..d837593 --- /dev/null +++ b/drivers/usb/serial/nt124.c @@ -0,0 +1,501 @@ +/* + * nt124.c - Driver for nt124 4x serial board based on STM32F103 + * + * Copyright (c) 2014 - 2015 NovaTech LLC + * + * Portions derived from the cdc-acm driver + * + * The original intention was to implement a cdc-acm compliant + * 4x USB to serial converter in the STM32F103 however several problems arose. + * The STM32F103 didn't have enough end points to implement 4 ports. + * CTS control was required by the application. + * Accurate notification of transmission completion was required. + * RTSCTS flow control support was required. + * + * The interrupt endpoint was eliminated and the control line information + * was moved to the first two bytes of the bulk in endpoint message. CTS + * control and mechanisms to enable RTSCTS flow control and deliver TXEMPTY + * information were added. + * + * Firmware source code can be found here: + * https://github.com/novatechweb/nt124 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the