From 6979eced0a733f619708391255a92a0f3de36b5f Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Thu, 19 Mar 2015 10:50:23 +0900 Subject: [PATCH 18/18] serial: sh-sci: Expose SCIFA/SCIFB CTS pin Expose CTS pin to serial core for the SCIFA/SCIFB case. Signed-off-by: Magnus Damm Signed-off-by: Andrey Gusakov --- drivers/tty/serial/sh-sci.c | 18 +++++++++++++++--- include/linux/serial_sci.h | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 52fcb41..893f2f0 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -577,6 +577,11 @@ static void sci_init_ctsrts_default(struct uart_port *port, bool hwflow_enabled) serial_port_out(port, SCSPTR, status); /* Set RTS = 0 */ } +static bool sci_cts_asserted_scifab(struct uart_port *port) +{ + return !(serial_port_in(port, SCPDR) & SCPDR_CTSD); +} + static void sci_init_ctsrts_scifab(struct uart_port *port, bool hwflow_enabled) { unsigned short control, data; @@ -1360,9 +1365,16 @@ static unsigned int sci_get_mctrl(struct uart_port *port) if (port->type == PORT_HSCIF) mctrl |= TIOCM_CTS; - - if (s->cfg->capabilities & SCIx_HAVE_RTSCTS) - cts_asserted = sci_cts_asserted_default(port); + if (s->cfg->capabilities & SCIx_HAVE_RTSCTS) { + switch (s->cfg->type) { + case PORT_SCIFA: + case PORT_SCIFB: + cts_asserted = sci_cts_asserted_scifab(port); + break; + default: + cts_asserted = sci_cts_asserted_default(port); + } + } return mctrl | (cts_asserted ? TIOCM_CTS : 0); } diff --git a/include/linux/serial_sci.h b/include/linux/serial_sci.h index 04f0066a..54fd078 100644 --- a/include/linux/serial_sci.h +++ b/include/linux/serial_sci.h @@ -72,6 +72,7 @@ /* SCPDR (Serial Port Data Register) */ #define SCPDR_RTSD (1 << 4) /* Serial Port RTS Output Pin Data */ +#define SCPDR_CTSD (1 << 3) /* Serial Port CTS Input Pin Data */ enum { SCIx_PROBE_REGTYPE, -- 1.7.10.4