Commit dfd37668ea6d5029fb5d8a66ea5e202d0655fad7

Authored by Desmond Liu
Committed by Greg Kroah-Hartman
1 parent 7cf91108d4

serial: 8250_dw: Fix get_mctrl behaviour

Fixed behaviour of get_mctrl() serial driver function as documented in:
https://www.kernel.org/doc/Documentation/serial/driver

Added device-tree properties 'dcd-override', 'dsr-override',
'cts-override', and 'ri-override' specific to the Synopsis 8250
DesignWare UART driver. Allows one to force Data Carrier Detect,
Clear To Send, and Data Set Ready signals to permanently be reported as
active. The Ring indicator can be forced to be reported as inactive.

It is possible that if modem control signalling is enabled on a port
that doesn't have these pins (e.g. - a simple two wire Tx/Rx port), the
driver can hang indefinitely waiting for the state to change. The new
DT properties allow the driver to ignore the state of these pins on
serial ports that don't support them, as recommended in the kernel
documentation.

Reviewed-by: JD (Jiandong) Zheng <jdzheng@broadcom.com>
Signed-off-by: Jonathan Richardson <jonathar@broadcom.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 2 changed files with 48 additions and 0 deletions Side-by-side Diff

Documentation/devicetree/bindings/serial/snps-dw-apb-uart.txt
... ... @@ -21,6 +21,18 @@
21 21 - reg-io-width : the size (in bytes) of the IO accesses that should be
22 22 performed on the device. If this property is not present then single byte
23 23 accesses are used.
  24 +- dcd-override : Override the DCD modem status signal. This signal will always
  25 + be reported as active instead of being obtained from the modem status
  26 + register. Define this if your serial port does not use this pin.
  27 +- dsr-override : Override the DTS modem status signal. This signal will always
  28 + be reported as active instead of being obtained from the modem status
  29 + register. Define this if your serial port does not use this pin.
  30 +- cts-override : Override the CTS modem status signal. This signal will always
  31 + be reported as active instead of being obtained from the modem status
  32 + register. Define this if your serial port does not use this pin.
  33 +- ri-override : Override the RI modem status signal. This signal will always be
  34 + reported as inactive instead of being obtained from the modem status register.
  35 + Define this if your serial port does not use this pin.
24 36  
25 37 Example:
26 38  
... ... @@ -31,6 +43,10 @@
31 43 interrupts = <10>;
32 44 reg-shift = <2>;
33 45 reg-io-width = <4>;
  46 + dcd-override;
  47 + dsr-override;
  48 + cts-override;
  49 + ri-override;
34 50 };
35 51  
36 52 Example with one clock:
drivers/tty/serial/8250/8250_dw.c
... ... @@ -59,6 +59,8 @@
59 59 u8 usr_reg;
60 60 int last_mcr;
61 61 int line;
  62 + int msr_mask_on;
  63 + int msr_mask_off;
62 64 struct clk *clk;
63 65 struct clk *pclk;
64 66 struct reset_control *rst;
... ... @@ -81,6 +83,12 @@
81 83 value &= ~UART_MSR_DCTS;
82 84 }
83 85  
  86 + /* Override any modem control signals if needed */
  87 + if (offset == UART_MSR) {
  88 + value |= d->msr_mask_on;
  89 + value &= ~d->msr_mask_off;
  90 + }
  91 +
84 92 return value;
85 93 }
86 94  
... ... @@ -333,6 +341,30 @@
333 341 id = of_alias_get_id(np, "serial");
334 342 if (id >= 0)
335 343 p->line = id;
  344 +
  345 + if (of_property_read_bool(np, "dcd-override")) {
  346 + /* Always report DCD as active */
  347 + data->msr_mask_on |= UART_MSR_DCD;
  348 + data->msr_mask_off |= UART_MSR_DDCD;
  349 + }
  350 +
  351 + if (of_property_read_bool(np, "dsr-override")) {
  352 + /* Always report DSR as active */
  353 + data->msr_mask_on |= UART_MSR_DSR;
  354 + data->msr_mask_off |= UART_MSR_DDSR;
  355 + }
  356 +
  357 + if (of_property_read_bool(np, "cts-override")) {
  358 + /* Always report DSR as active */
  359 + data->msr_mask_on |= UART_MSR_DSR;
  360 + data->msr_mask_off |= UART_MSR_DDSR;
  361 + }
  362 +
  363 + if (of_property_read_bool(np, "ri-override")) {
  364 + /* Always report Ring indicator as inactive */
  365 + data->msr_mask_off |= UART_MSR_RI;
  366 + data->msr_mask_off |= UART_MSR_TERI;
  367 + }
336 368  
337 369 /* clock got configured through clk api, all done */
338 370 if (p->uartclk)