usb:serial:f81534 add F81532/534 driver
Subsystems (2)
PATCH v3 1/1 usb:serial:f81534 add F81532/534 driver
This driver is for Fintek F81532/F81534 USB to Serial Ports IC.
Features:
1. F81534 is 1-to-4 & F81532 is 1-to-2 serial ports IC
2. Support Baudrate from B50 to B1500000 (excluding B1000000).
3. The RTS signal can be transformed their behavior with configuration by default ioctl TIOCGRS485/TIOCSRS485 (for RS232/RS485/RS422 with transceiver)
If the driver setting with SER_RS485_ENABLED, the RTS signal will high with not in TX and low with in TX.
If the driver setting with SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND, the RTS signal will low with not in TX and high with in TX.
4. There are 4x3 output-only ic pins to control transceiver mode. It's can be controlled via gpiolib. We could found the gpio number from /sys/class/tty/ttyUSB[x]/device/gpiochap[yyy] where x is F81532/534 serial port and yyy is gpiochip number.
After we found chip number, we can export 3 gpios(M2/M1/M0) per serial port by
echo yyy > /sys/class/gpio/export
echo yyy+1 > /sys/class/gpio/export
echo yyy+2 > /sys/class/gpio/export
then we can control it with
echo [M0 value] > /sys/class/gpio/gpio[yyy]/value
echo [M1 value] > /sys/class/gpio/gpio[yyy+1]/value
echo [M2 value] > /sys/class/gpio/gpio[yyy+2]/valuewhich M0/M1/M2 as your desired value, value is only 0 or 1.
When configure complete, It's a must to free all gpio by
echo yyy > /sys/class/gpio/unexport
echo yyy+1 > /sys/class/gpio/unexport
echo yyy+2 > /sys/class/gpio/unexport
The driver will "save" gpio configure after we release all gpio of a serial port.
For examples to change mode & gpio with F81532/534 Evalaution Board.
F81532 EVB
port0: F81437 (RS232 only)
port1: F81439 (RS232/RS485/RS422 ... etc.) F81534 EVB
port0/1: F81437 (RS232 only) port2/3: F81439 (RS232/RS485/RS422 ... etc.)
1. RS232 Mode (Default IC Mode)
1. Set struct serial_rs485 flags "without" SER_RS485_ENABLED (control F81532/534 RTS control)
2. Set M2/M1/M0 as 0/0/1
(control F81532/534 output pin to control transceiver mode)
2. RS485 Mode (RTS Low when TX Mode)
1. Set struct serial_rs485 flags with SER_RS485_ENABLED
2. Set M2/M1/M0 as 0/1/0
3. RS485 Mode (RTS High when TX Mode)
1. Set struct serial_rs485 flags with SER_RS485_ENABLED and SER_RS485_RTS_ON_SEND
2. Set M2/M1/M0 as 0/1/1
4. RS422 Mode
1. The RTS mode is dont care.
2. Set M2/M1/M0 as 0/0/0
Please reference https://bitbucket.org/hpeter/fintek-general/src/
with f81534/tools to get set_gpio.c & set_mode.c. Please use it carefully.
Changelog
v3
1. Migrate read, write and some routine from custom code to usbserial subsystem callback function.
2. Use more defines to replece magic numbers to make it meaningful
3. Make more comments as document in source code.
v2
1. v1 version submit to staging tree, but Greg KH advised me to cleanup source code & re-submit it to correct subsystem
2. Remove all custom ioctl commands
--- drivers/usb/serial/Kconfig | 10 + drivers/usb/serial/Makefile | 1 + drivers/usb/serial/f81534.c | 3316 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 3327 insertions(+) create mode 100644 drivers/usb/serial/f81534.c
drivers/usb/serial/Kconfig +10 -0
@@ -255,6 +255,16 @@ config USB_SERIAL_F81232 To compile this driver as a module, choose M here: the module will be called f81232. +config USB_SERIAL_F8153X + tristate "USB Fintek F81532/534 Multi-Ports Serial Driver" + help + Say Y here if you want to use the Fintek F81532/534 Multi-Ports + usb to serial adapter. + + To compile this driver as a module, choose M here: the + module will be called f81534. + + config USB_SERIAL_GARMIN tristate "USB Garmin GPS driver" help
drivers/usb/serial/Makefile +1 -0
@@ -23,6 +23,7 @@ obj-$(CONFIG_USB_SERIAL_EDGEPORT) += io_edgeport.o obj-$(CONFIG_USB_SERIAL_EDGEPORT_TI) += io_ti.o obj-$(CONFIG_USB_SERIAL_EMPEG) += empeg.o obj-$(CONFIG_USB_SERIAL_F81232) += f81232.o +obj-$(CONFIG_USB_SERIAL_F8153X) += f81534.o obj-$(CONFIG_USB_SERIAL_FTDI_SIO) += ftdi_sio.o obj-$(CONFIG_USB_SERIAL_GARMIN) += garmin_gps.o obj-$(CONFIG_USB_SERIAL_IPAQ) += ipaq.o
drivers/usb/serial/f81534.c new file +3316 -0
2,977 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.9.1
Part of the diff is not shown here. View the raw message.
Hi Johan,
Peter Hung 於 2015/7/9 上午 11:15 寫道:
Quoted 2 lines
This driver is for Fintek F81532/F81534 USB to Serial Ports IC.
Please pending for the driver, I found a problem with prepare_write_buffer(). The driver submit write block size != real tx send size. It's will ok on transmitting small mount data, but it's will fail on transmitting large mount data.
I'll fix for this problem and re-send patch.
Sorry for found bug so lately.
Signature · 2 lines
With Best Regards, Peter Hung
Johan Hovold
maintainerQuoted 6 lines · Peter Hung
Hi Johan,
Peter Hung 於 2015/7/9 上午 11:15 寫道:
Quoted 2 lines
This driver is for Fintek F81532/F81534 USB to Serial Ports IC.
Quoted 7 lines
Please pending for the driver, I found a problem with
prepare_write_buffer(). The driver submit write block size != real tx send size. It's will ok on transmitting small mount data, but it's will fail on transmitting large mount data.I'll fix for this problem and re-send patch.
Sorry for found bug so lately.
Ok, I'll wait for v4.
Thanks,
Johan