Age | Commit message (Collapse) | Author |
|
Add another copyright notice for the work done in 2021.
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
Reset the transmit and receive FIFOs before enabling the UARTs as part
of open() in order to flush any stale data.
Note that the XR21V141X needs a type-specific implementation due to its
UART Manager registers.
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
The XR22801, XR22802 and XR22804 are compound devices with an embedded
hub and up to seven downstream USB devices including one, two or four
UARTs respectively.
The UART function is similar to XR21B142X but most registers are offset
by 0x40, the register requests are different and are directed at the
device rather than interface, and 5 and 6-bit words are not supported.
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
The single-port XR21B1411 is similar to the XR21B142X type but uses
12-bit registers and 16-bit register addresses, the register requests
are different and are directed at the device rather than interface, and
5 and 6-bit words are not supported.
The register layout is very similar to XR21B142X except that most
registers are offset by 0xc00 (corresponding to a channel index of 12 in
the MSB of wIndex). As the device is single-port so that the derived
channel index is 0, the current register accessors can be reused after
simply changing the address width.
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
The XR21B1421, XR21B1422 and XR21B1424 are the one-, two- and four-port
models of a second XR21B142X type of the Maxlinear/Exar USB UARTs.
The XR21B142X type differs from XR21V141X in several ways, including:
- register layout
- register width (16-bit instead of 8-bit)
- vendor register requests
- UART enable/disable sequence
- custom-driver mode flag
- three additional GPIOs (9 instead of 6)
As for XR21V141X, the XR21B142X vendor requests encode the channel index
in the MSB of wIndex, but it lacks the UART Manager registers which
have been replaced by regular UART registers. The new type also uses the
interface number of the control interface (0, 2, 4, 6) as channel index
instead of the channel number (0, 1, 2, 3).
The XR21B142X lacks the divisor and format registers used by XR21V141X
and instead uses the CDC SET_LINE_CONTROL request to configure the line
settings.
Note that the currently supported XR21V141X type lacks the custom-driver
mode flag that prevents the device from entering CDC-ACM mode when a CDC
requests is received. This specifically means that the SET_LINE_CONTROL
request cannot be used with XR21V141X even though it is otherwise
supported.
The UART enable sequence for XR21B142X does not involve explicitly
enabling the FIFOs, but according to datasheet the UART must be disabled
when writing any register but GPIO_SET, GPIO_CLEAR, TX_BREAK and
ERROR_STATUS.
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
There are at least four types of Maxlinear/Exar USB UARTs which differ
in various ways such as in their register layouts:
XR21V141X
XR21B142X
XR21B1411
XR22804
It is not clear whether the device type can be inferred from the
descriptors so encode it in the device-id table for now.
Add a type structure that can be used to abstract the register layout
and other features, and use it when accessing the XR21V141X UART
registers that are shared by all types.
Note that the currently supported XR21V141X type is the only type that
has a set of UART Manager registers and that these will need to be
handled specifically.
Similarly, XR21V141X is the only type which has the divisor registers
and that needs to use the format register when configuring the line
settings.
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
In preparation for adding support for further types, drop the type
prefix from defines that are not specific to XR21V141X.
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
There's no need to configure the pins on every open and judging from the
vendor driver and datasheet it can be done before enabling the UART.
Move pin configuration from open() to port probe and make sure to
deassert DTR and RTS after configuring all pins as GPIO.
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
Rename the GPIO-pin defines so that they reflect how they are used.
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
Rename the GPIO mode defines so that they reflect the datasheet and how
they are used.
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
Add support for the two- and four-port variants of XR21V1410.
Use the interface number of each control interface (e.g. 0, 2, 4, 6) to
derive the zero-based channel index:
XR21V1410 0
XR21V1412 0, 1
XR21V1414 0, 1, 2, 3
Note that the UART registers reside in separate blocks per channel,
while the UART Manager functionality is implemented using per-channel
registers.
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
Use the new multi-interface support in USB serial core to properly claim
also the control interface during probe. This prevents having another
driver claim the control interface and makes core allocate resources
also for the interrupt endpoint (currently unused).
Switch to probing only Communication Class interfaces and use the Union
functional descriptor to determine the corresponding data interface.
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
The XR21V141X does not have a 5- or 6-bit mode, but the current
implementation failed to properly restore the old setting when CS5 or
CS6 was requested. Instead an invalid request would be sent to the
device.
Fixes: c2d405aa86b4 ("USB: serial: add MaxLinear/Exar USB to Serial driver")
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Cc: stable@vger.kernel.org # 5.12
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
Claiming the sibling control interface is a bit more involved and
specifically requires adding support to USB-serial core for managing
either interface being unbound first, something which could otherwise
lead to a NULL-pointer dereference.
Similarly, additional infrastructure is also needed to handle suspend
properly.
Since the driver currently isn't actually using the control interface,
we can defer this for now by simply not claiming the control interface.
Fixes: c2d405aa86b4 ("USB: serial: add MaxLinear/Exar USB to Serial driver")
Reported-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tested-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
Fix up B0 handling which should leave the baud rate unchanged and
specifically not report back a non-B0 rate when B0 is requested; must
temporarily disable hardware flow control so that RTS can be deasserted;
and should reassert DTR/RTS when moving from B0.
Fixes: c2d405aa86b4 ("USB: serial: add MaxLinear/Exar USB to Serial driver")
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
Make sure that the modem pins are set up correctly when opening the
port to avoid leaving, for example, DTR and RTS configured as inputs,
which is the device default.
This is specifically needed to be able to control DTR and RTS when
hardware flow control is disabled.
Fixes: c2d405aa86b4 ("USB: serial: add MaxLinear/Exar USB to Serial driver")
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
Fix the gpio-mode handling so that all the pins are under driver control
(i.e. in gpio mode) when hardware flow control is disabled.
This is specifically needed to be able to control RTS.
Fixes: c2d405aa86b4 ("USB: serial: add MaxLinear/Exar USB to Serial driver")
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
Simplify the changed-line-speed conditional expression.
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
Shift the line-setting values when defining them rather than in
set_termios() for consistency and improved readability.
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
Add the missing device-recipient define to the vendor control requests
for completeness.
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
Use the termios flag helpers consistently, including for CRTSCTS.
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
Use the subsystem struct usb_device pointer at probe instead of
deriving it from the interface pointer.
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
Make sure to release the control interface at disconnect so that the
driver can be unbound without leaking resources (and later rebound).
Fixes: c2d405aa86b4 ("USB: serial: add MaxLinear/Exar USB to Serial driver")
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
Make sure that the probed device has an interface 0 to avoid
dereferencing a NULL pointer in case of a malicious device or during
USB-descriptor fuzzing.
Fixes: c2d405aa86b4 ("USB: serial: add MaxLinear/Exar USB to Serial driver")
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
Add support for MaxLinear/Exar USB to Serial converters. This driver
only supports XR21V141X series but it can be extended to other series
from Exar as well in future.
This driver is inspired from the initial one submitted by Patong Yang:
https://lore.kernel.org/r/20180404070634.nhspvmxcjwfgjkcv@advantechmxl-desktop
While the initial driver was a custom tty USB driver exposing whole
new serial interface ttyXRUSBn, this version is completely based on USB
serial core thus exposing the interfaces as ttyUSBn. This will avoid
the overhead of exposing a new USB serial interface which the userspace
tools are unaware of.
The Exar XR21V141X can be used in either ACM mode using the cdc-acm
driver or in "custom driver" mode in which further features such as
hardware and software flow control, GPIO control and in-band line-status
reporting are available.
In ACM mode the device always enables RTS/CTS flow control, something
which could prevent transmission in case the CTS input isn't wired up
corrently.
A follow-on patch will prevent cdc_acm from binding whenever this driver
is enabled.
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://lore.kernel.org/r/20201122170822.21715-2-mani@kernel.org
[ johan: fix some style nits, group related functions, drop unused
callbacks, and amend commit message; a few remaining
non-trivial issues will be fixed separately ]
Signed-off-by: Johan Hovold <johan@kernel.org>
|