History

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.

Desmond Liu committed 11 years ago

Commit dfd37661 parent 7cf91102 files · +48 −0Browse files

Unified · Split

2 files
  1. Documentation/devicetree/bindings/serial/snps-dw-apb-uart.txt +16 −0
  2. drivers/tty/serial/8250/8250_dw.c +32 −0
Documentation/devicetree/bindings/serial/snps-dw-apb-uart.txt+16−0
@@ -21,6 +21,18 @@ Optional properties: · 20 unmodified lines
2121 - reg-io-width : the size (in bytes) of the IO accesses that should be
2222 performed on the device. If this property is not present then single byte
2323 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.
2436
2537 Example:
2638
@@ -31,6 +43,10 @@ Example: · 4 unmodified lines
3143 interrupts = <10>;
3244 reg-shift = <2>;
3345 reg-io-width = <4>;
46+ dcd-override;
47+ dsr-override;
48+ cts-override;
49+ ri-override;
3450 };
3551
3652 Example with one clock:
drivers/tty/serial/8250/8250_dw.c+32−0
@@ -59,6 +59,8 @@ struct dw8250_data { · 58 unmodified lines
5959 u8 usr_reg;
6060 int last_mcr;
6161 int line;
62+ int msr_mask_on;
63+ int msr_mask_off;
6264 struct clk *clk;
6365 struct clk *pclk;
6466 struct reset_control *rst;
@@ -81,6 +83,12 @@ static inline int dw8250_modify_msr(struct uart_port *p, int offset, int value) · 16 unmodified lines
8183 value &= ~UART_MSR_DCTS;
8284 }
8385
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+
8492 return value;
8593 }
8694
@@ -334,6 +342,30 @@ static int dw8250_probe_of(struct uart_port *p, · 247 unmodified lines
334342 if (id >= 0)
335343 p->line = id;
336344
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+ }
368+
337369 /* clock got configured through clk api, all done */
338370 if (p->uartclk)
339371 return 0;