Here are the USB-serial updates for 4.21-rc1, including:
- support for mos7840 3-port devices
- improved ftdi baud-rate divisor calculations
- support for a new class of f81534 devices
Included are also various clean ups and some new pl2303 device ids.
All have been in linux-next with no reported issues.
Signed-off-by: Johan Hovold <johan@kernel.org>
-----BEGIN PGP SIGNATURE-----
iHUEABYIAB0WIQQHbPq+cpGvN/peuzMLxc3C7H1lCAUCXBva9AAKCRALxc3C7H1l
CP6XAQClpmmKj59AiAJK+hlWIbNpznPUUrkGHS7mFyuWkDrllQEAsK2IofNWbs9y
g0ot/v4UgUVZHySGl5yYoV4A0uKJdAQ=
=oyPx
-----END PGP SIGNATURE-----
Merge tag 'usb-serial-4.21-rc1' of https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial into usb-next
Johan writes:
USB-serial updates for 4.21-rc1
Here are the USB-serial updates for 4.21-rc1, including:
- support for mos7840 3-port devices
- improved ftdi baud-rate divisor calculations
- support for a new class of f81534 devices
Included are also various clean ups and some new pl2303 device ids.
All have been in linux-next with no reported issues.
Signed-off-by: Johan Hovold <johan@kernel.org>
* tag 'usb-serial-4.21-rc1' of https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial:
USB: serial: pl2303: add ids for Hewlett-Packard HP POS pole displays
USB: serial: mos7840: remove set but not used variables 'number, serial'
USB: serial: mos7840: add a product ID for the new product
USB: serial: mos7840: clean up register handling
USB: serial: ftdi_sio: use rounding when calculating baud rate divisors
USB: serial: f81534: fix reading old/new IC config
USB: serial: mos7840: remove set but not used variables 'st, data1, iflag'
USB: serial: quatech2: remove set but not used variable 'port_priv'
Add device ids to pl2303 for the HP POS pole displays:
LM920: 03f0:026b
TD620: 03f0:0956
LD960TA: 03f0:4439
LD220TA: 03f0:4349
LM940: 03f0:5039
Signed-off-by: Scott Chen <scott@labau.com.tw>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Fixes gcc '-Wunused-but-set-variable' warning:
drivers/usb/serial/mos7840.c: In function 'mos7840_send_cmd_write_baud_rate':
drivers/usb/serial/mos7840.c:1584:16: warning:
variable 'number' set but not used [-Wunused-but-set-variable]
drivers/usb/serial/mos7840.c: In function 'mos7840_change_port_settings':
drivers/usb/serial/mos7840.c:1695:21: warning:
variable 'serial' set but not used [-Wunused-but-set-variable]
'number' never used since introduction in commit 3f5429746d ("USB: Moschip
7840 USB-Serial Driver")
'serial' not used since commit 5833041f1b ("USB: serial: remove unnecessary
reinitialisations of urb->dev")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
The USB-serial console implementation has never reported the actual
terminal settings used. Despite storing the corresponding cflags in its
struct console, these were never honoured on later tty open() where the
tty termios would be left initialised to the driver defaults.
Unlike the serial console implementation, the USB-serial code calls
subdriver open() already at console setup. While calling set_termios()
and write() before open() looks like it could work for some USB-serial
drivers, others definitely do not expect this, so modelling this after
serial core is going to be intrusive, if at all possible.
Instead, use a (renamed) tty helper to save the termios data used at
console setup so that the tty termios reflects the actual terminal
settings after a subsequent tty open().
Note that the calls to tty_init_termios() (tty_driver_install()) and
tty_save_termios() are serialised using the disconnect mutex.
This specifically fixes a regression that was triggered by a recent
change adding software flow control to the pl2303 driver: a getty trying
to disable flow control while leaving the baud rate unchanged would now
also set the baud rate to the driver default (prior to the flow-control
change this had been a noop).
Fixes: 7041d9c3f0 ("USB: serial: pl2303: add support for tx xon/xoff flow control")
Cc: stable <stable@vger.kernel.org> # 4.18
Cc: Florian Zumbiehl <florz@florz.de>
Reported-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Add a new PID 0x7843 to the driver.
Let the new products be able to set up 3 serial ports with the driver.
Note that this depends on e8603076f5 ("USB: serial: mos7840: clean up
register handling").
Signed-off-by: JackyChou <jackychou@asix.com.tw>
[ johan: mention dependency in case anyone wants to backport this ]
Signed-off-by: Johan Hovold <johan@kernel.org>
In the read/write function, set port 2 independently in the 2-port case.
When setting the offset of port registers, the offset between port 1 and
other ports is different, so port 1 is set independently.
Then in the rest of ports, the port 2 between 2-ports case and 4-ports case
is different, so port 2 in 2-ports case is set independently.
Specifically, port 2 in the 2-port case maps to the registers used by
port 3 in the 4-port case.
Signed-off-by: JackyChou <jackychou@asix.com.tw>
[ johan: simplify register-offset handling at port probe, add a comment
and amend commit message ]
Signed-off-by: Johan Hovold <johan@kernel.org>
Improve baud-rate generation by using rounding-to-closest instead of
truncation in divisor calculation.
Results have been verified by logic analyzer on an FT232RT (232BM) chip.
The following table shows the wanted baud rate, the baud rate obtained
with the old method (truncation), with the new method (rounding) and the
baud rate generated by the windows 10 driver. The numbers in parentheses
is the error.
+- Wanted --+------ Old -------+------ New -------+------ Win -------+
| 9600 | 9600 (0.00%) | 9604 (0.05%) | 9605 (0.05%) |
| 19200 | 19200 (0.00%) | 19199 (0.01%) | 19198 (0.01%) |
| 38400 | 38395 (0.01%) | 38431 (0.08%) | 38394 (0.02%) |
| 57600 | 57725 (0.22%) | 57540 (0.10%) | 57673 (0.13%) |
| 115200 | 115307 (0.09%) | 115330 (0.11%) | 115320 (0.10%) |
| 921600 | 919963 (0.18%) | 920386 (0.13%) | 920810 (0.09%) |
| 961200 | 996512 (3.67%) | 956480 (0.49%) | 956937 (0.44%) |
+-----------+------------------+------------------+------------------+
The error due to noise in the measurements is in the order of a few
tenths of a %. As can be seen, the baud rate is significantly improved
for some rates (e.g. 961200), and corresponds to the output given by the
windows driver.
The theoretical baud rate has been calculated for all baud rates from 1
to 3M, and as expected, the error is centered around 0, with a triangle
shape instead of a sawtooth, so the maximum error is decreased to half.
Signed-off-by: Nikolaj Fogh <nikolajfogh@gmail.com>
[ johan: edit commit message slightly ]
Signed-off-by: Johan Hovold <johan@kernel.org>
The F81532/534 had a internal configuration space to save & control
IC state with address F81534_CUSTOM_ADDRESS_START (0x2f00). Layout
as following:
+00h: to indicate the section is valid
+01h~04h: UART Mode & port availability
+05h~08h: Output pin control on IC power on
+09h~12h: Output pin control on working <-- New added
Old driver will use +05~08h as default on working, but newer IC will
configed with shutdown mode(7) in 05h~08h and working mode with RS232(1)
in 09h~12h. It'll make mainstream driver not working.
This patch will make mainstream driver compatible older and newer IC.
If using a old IC, the +05h~08h will be 00h~06h, we'll direct apply it.
If using a new IC, the +05h~08h will be 07h or larger, we'll read +09h~12h
to apply newer configuration.
Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Fixes gcc '-Wunused-but-set-variable' warning:
drivers/usb/serial/mos7840.c: In function 'mos7840_interrupt_callback':
drivers/usb/serial/mos7840.c:604:14: warning:
variable 'st' set but not used [-Wunused-but-set-variable]
drivers/usb/serial/mos7840.c: In function 'mos7840_write':
drivers/usb/serial/mos7840.c:1303:17: warning:
variable 'data1' set but not used [-Wunused-but-set-variable]
drivers/usb/serial/mos7840.c:1700:11: warning:
variable 'iflag' set but not used [-Wunused-but-set-variable]
They are never used since introduction in commit 3f5429746d ("USB:
Moschip 7840 USB-Serial Driver")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Fixes gcc '-Wunused-but-set-variable' warning:
drivers/usb/serial/quatech2.c: In function 'qt2_process_read_urb':
drivers/usb/serial/quatech2.c:503:27: warning:
variable 'port_priv' set but not used [-Wunused-but-set-variable]
It not used any more after commit 2be818a116 ('Revert "USB: quatech2:
only write to the tty if the port is open."')
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Here is the big USB/PHY driver patches for 4.20-rc1
Lots of USB changes in here, primarily in these areas:
- typec updates and new drivers
- new PHY drivers
- dwc2 driver updates and additions (this old core keeps getting added
to new devices.)
- usbtmc major update based on the industry group coming together and
working to add new features and performance to the driver.
- USB gadget additions for new features
- USB gadget configfs updates
- chipidea driver updates
- other USB gadget updates
- USB serial driver updates
- renesas driver updates
- xhci driver updates
- other tiny USB driver updates
All of these have been in linux-next for a while with no reported
issues.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-----BEGIN PGP SIGNATURE-----
iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCW9LlHw8cZ3JlZ0Brcm9h
aC5jb20ACgkQMUfUDdst+ymnvwCffYmMWyMG9zSOw1oSzFPl7TVN1hYAoMyJqzLg
umyLwWxC9ZWWkrpc3iD8
=ux+Y
-----END PGP SIGNATURE-----
Merge tag 'usb-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB/PHY updates from Greg KH:
"Here is the big USB/PHY driver patches for 4.20-rc1
Lots of USB changes in here, primarily in these areas:
- typec updates and new drivers
- new PHY drivers
- dwc2 driver updates and additions (this old core keeps getting
added to new devices.)
- usbtmc major update based on the industry group coming together and
working to add new features and performance to the driver.
- USB gadget additions for new features
- USB gadget configfs updates
- chipidea driver updates
- other USB gadget updates
- USB serial driver updates
- renesas driver updates
- xhci driver updates
- other tiny USB driver updates
All of these have been in linux-next for a while with no reported
issues"
* tag 'usb-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (229 commits)
usb: phy: ab8500: silence some uninitialized variable warnings
usb: xhci: tegra: Add genpd support
usb: xhci: tegra: Power-off power-domains on removal
usbip:vudc: BUG kmalloc-2048 (Not tainted): Poison overwritten
usbip: tools: fix atoi() on non-null terminated string
USB: misc: appledisplay: fix backlight update_status return code
phy: phy-pxa-usb: add a new driver
usb: host: add DT bindings for faraday fotg2
usb: host: ohci-at91: fix request of irq for optional gpio
usb/early: remove set but not used variable 'remain_length'
usb: typec: Fix copy/paste on typec_set_vconn_role() kerneldoc
usb: typec: tcpm: Report back negotiated PPS voltage and current
USB: core: remove set but not used variable 'udev'
usb: core: fix memory leak on port_dev_path allocation
USB: net2280: Remove ->disconnect() callback from net2280_pullup()
usb: dwc2: disable power_down on rockchip devices
usb: gadget: udc: renesas_usb3: add support for r8a77990
dt-bindings: usb: renesas_usb3: add bindings for r8a77990
usb: gadget: udc: renesas_usb3: Add r8a774a1 support
USB: serial: cypress_m8: remove set but not used variable 'iflag'
...
Pull tty ioctl updates from Al Viro:
"This is the compat_ioctl work related to tty ioctls.
Quite a bit of dead code taken out, all tty-related stuff gone from
fs/compat_ioctl.c. A bunch of compat bugs fixed - some still remain,
but all more or less generic tty-related ioctls should be covered
(remaining issues are in things like driver-private ioctls in a pcmcia
serial card driver not getting properly handled in 32bit processes on
64bit host, etc)"
* 'work.tty-ioctl' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (53 commits)
kill TIOCSERGSTRUCT
change semantics of ldisc ->compat_ioctl()
kill TIOCSER[SG]WILD
synclink_gt(): fix compat_ioctl()
pty: fix compat ioctls
compat_ioctl - kill keyboard ioctl handling
gigaset: add ->compat_ioctl()
vt_compat_ioctl(): clean up, use compat_ptr() properly
gigaset: don't try to printk userland buffer contents
dgnc: don't bother with (empty) stub for TCXONC
dgnc: leave TIOC[GS]SOFTCAR to ldisc
remove fallback to drivers for TIOCGICOUNT
dgnc: break-related ioctls won't reach ->ioctl()
kill the rest of tty COMPAT_IOCTL() entries
dgnc: TIOCM... won't reach ->ioctl()
isdn_tty: TCSBRK{,P} won't reach ->ioctl()
kill capinc_tty_ioctl()
take compat TIOC[SG]SERIAL treatment into tty_compat_ioctl()
synclink: reduce pointless checks in ->ioctl()
complete ->[sg]et_serial() switchover
...
Here are the USB-serial updates for 4.20-rc1, including:
- support for CBUS GPIO on FTDI devices (FTX and FT232R)
- fix of a long-standing transfer-length bug
Included are also various clean ups.
All have been in linux-next with no reported issues.
Signed-off-by: Johan Hovold <johan@kernel.org>
-----BEGIN PGP SIGNATURE-----
iQJFBAABCAAvFiEEHszNKQClByu0A+9RQQ3kT97htJUFAlvIZhIRHGpvaGFuQGtl
cm5lbC5vcmcACgkQQQ3kT97htJUNIQ//fv+Jn/XQ4H9Ystik+uJbHOSXYG0OJPkz
IYZcFdlJBwdH9fF0Bof6vRVIlltJH6ZE636qWZi4D0fuS+pjGoyV3XXYAmiJc+d3
jXZSvuib08s89SYz2sK8CYrlgZYnMkn/HO8SIs/dLE81HvGpb+3qS0kcqBoepo5f
MP6TA4jBcRkLVe9gEvgNDwm+Vc1I9Myg6Co5SClaNZRnuj4UyreqX1DIp2lU3evw
gMq1AHZkwijrdES1FbW9SQ4cVujG3KXbKCrrQyXMcTNPX+4BlayiEqC12eNcoP2Q
Ng1IAXTZWP1jFCDWZ5B2gn6r0jGILn2leFKcazt9B5lN/YTE51YgbV2JHlnc+8IV
z1dOs3IIINfwTchh8DSW9nS1j8krFzrGebXlcMApuSqq7s7MGZVy7P48FsgtUd6Y
B2msIjAWxnLf4XQcKWLA9tZj5stBNInSfFFHi4oUhC/A62teC/XFF8505N9y9MVr
PhgWnH2zd7cayuUoHQTVvVpvmnRyJBLmyawqSCGLQvo22II58zvsvRX7K/Mop1WB
u7+dxVfVb+fgpBM5RjfNRK/qXux7BqgXQFhNzzCREiKDi+Mv+2VOe3rmXOi8bMHs
SKY2r70Fk1ihmxSTcUMCTG1bc3BNZwpccgpW9vWw5Kia3lo3JUgd8OSIfxFnLi03
/GAnh8pnSh8=
=V6Jo
-----END PGP SIGNATURE-----
Merge tag 'usb-serial-4.20-rc1' of https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial into usb-next
Johan writes:
USB-serial updates for v4.20-rc1
Here are the USB-serial updates for 4.20-rc1, including:
- support for CBUS GPIO on FTDI devices (FTX and FT232R)
- fix of a long-standing transfer-length bug
Included are also various clean ups.
All have been in linux-next with no reported issues.
Signed-off-by: Johan Hovold <johan@kernel.org>
* tag 'usb-serial-4.20-rc1' of https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial:
USB: serial: cypress_m8: remove set but not used variable 'iflag'
USB: serial: cypress_m8: fix interrupt-out transfer length
USB: serial: ftdi_sio: add support for FT232R CBUS gpios
USB: serial: ftdi_sio: fix gpio name collisions
USB: serial: ftdi_sio: implement GPIO support for FT-X devices
USB: serial: cypress_m8: fix spelling mistake "retreiving" -> "retrieving"
... and fix the return value - on success it used to have ioctl(2)
fill the user-supplied struct serial_struct and return -ENOTTY.
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
add such methods for usb_serial_driver, provide tty_operations
->[sg]et_serial() calling those. For now the lack of methods
in driver means ENOIOCTLCMD from usb-serial ->[sg]et_serial(),
making tty_ioctl() fall back to calling ->ioctl(). Once all
drivers are converted, we'll be returning -ENOTTY instead,
completing the switchover.
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Fixes gcc '-Wunused-but-set-variable' warning:
drivers/usb/serial/cypress_m8.c: In function 'cypress_set_termios':
drivers/usb/serial/cypress_m8.c:866:18: warning:
variable 'iflag' set but not used [-Wunused-but-set-variable]
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Fix interrupt-out transfer length which was being set to the
transfer-buffer length rather than the size of the outgoing packet.
Note that no slab data was leaked as the whole transfer buffer is always
cleared before each transfer.
Fixes: 9aa8dae7b1 ("cypress_m8: use usb_fill_int_urb where appropriate")
Signed-off-by: Johan Hovold <johan@kernel.org>
Enable support for cbus gpios on FT232R. The cbus configuration is
stored in one word in the EEPROM at offset 0x0a (byte-offset 0x14) with
the mux config for CBUS0, CBUS1, CBUS2 and CBUS3 in bits 0..3, 4..7,
8..11 and 12..15, respectively.
Tested using FT232RL by configuring one cbus pin at a time.
Signed-off-by: Johan Hovold <johan@kernel.org>
Drop the gpio line names, which cause gpiolib to complain loudly
whenever a second ftdi gpiochip is registered:
gpio gpiochip5: Detected name collision for GPIO name 'CBUS0'
gpio gpiochip5: Detected name collision for GPIO name 'CBUS1'
gpio gpiochip5: Detected name collision for GPIO name 'CBUS2'
gpio gpiochip5: Detected name collision for GPIO name 'CBUS3'
and also prevents the legacy sysfs interface from being used (as the
line names are used as device names whenever they are set):
sysfs: cannot create duplicate filename '/class/gpio/CBUS0'
Until non-unique names are supported by gpiolib (without warnings and
stack dumps), let's leave the gpio lines unnamed.
Signed-off-by: Johan Hovold <johan@kernel.org>
This patch allows using the CBUS pins of FT-X devices as GPIO in CBUS
bitbanging mode. There is no conflict between the GPIO and VCP
functionality in this mode. Tested on FT230X and FT231X.
As there is no way to request the current CBUS register configuration
from the device, all CBUS pins are set to a known state when the first
GPIO is requested. This allows using libftdi to set the GPIO pins
before loading this module for UART functionality, a behavior that
existing applications might be relying upon (though no specific case
is known to the authors of this patch).
Signed-off-by: Karoly Pados <pados@pados.hu>
[ johan: minor style changes ]
Signed-off-by: Johan Hovold <johan@kernel.org>
Trivial fix to spelling mistake in dev_dbg message
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
These ioctls never reach driver's ->ioctl() - tty_ioctl() handles
them on its own. ->tiocm[gs]et() is what actually gets called,
and mos7720 provides those, with results equivalent to what the
unreachable code would be doing when called.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Allow matching on interfaces having two endpoints by adding a new
device-id flag.
This allows for the handling of devices whose interface numbers can
change (e.g. Quectel EP06) to be contained in the device-id table.
Tested-by: Kristian Evensen <kristian.evensen@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
The Quectel EP06 (and EM06/EG06) LTE modem supports updating the USB
configuration, without the VID/PID or configuration number changing.
When the configuration is updated and interfaces are added/removed, the
interface numbers are updated. This causes our current code for matching
EP06 not to work as intended, as the assumption about reserved
interfaces no longer holds. If for example the diagnostic (first)
interface is removed, option will (try to) bind to the QMI interface.
This patch improves EP06 detection by replacing the current match with
two matches, and those matches check class, subclass and protocol as
well as VID and PID. The diag interface exports class, subclass and
protocol as 0xff. For the other serial interfaces, class is 0xff and
subclass and protocol are both 0x0.
The modem can export the following devices and always in this order:
diag, nmea, at, ppp. qmi and adb. This means that diag can only ever be
interface 0, and interface numbers 1-5 should be marked as reserved. The
three other serial devices can have interface numbers 0-3, but I have
not marked any interfaces as reserved. The reason is that the serial
devices are the only interfaces exported by the device where subclass
and protocol is 0x0.
QMI exports the same class, subclass and protocol values as the diag
interface. However, the two interfaces have different number of
endpoints, QMI has three and diag two. I have added a check for number
of interfaces if VID/PID matches the EP06, and we ignore the device if
number of interfaces equals three (and subclass is set).
Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
Acked-by: Dan Williams <dcbw@redhat.com>
[ johan: drop uneeded RSVD(5) for ADB ]
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Similarly to a recently reported bug in io_ti, a malicious USB device
could set port_number to a negative value and we would underflow the
port array in the interrupt completion handler.
As these devices only have one or two ports, fix this by making sure we
only consider the seventh bit when determining the port number (and
ignore bits 0xb0 which are typically set to 0x30).
Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
As reported by Dan Carpenter, a malicious USB device could set
port_number to a negative value and we would underflow the port array in
the interrupt completion handler.
As these devices only have one or two ports, fix this by making sure we
only consider the seventh bit when determining the port number (and
ignore bits 0xb0 which are typically set to 0x30).
Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Cc: stable <stable@vger.kernel.org>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Movie Song <MovieSong@aten-itlab.cn>
Cc: Johan Hovold <johan@kernel.org>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>