From f7d7ddb2a3ad4c20dbbd7cbabf56bca4c35b8368 Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Thu, 19 Mar 2015 10:50:03 +0900 Subject: [PATCH 16/18] serial: sh-sci: Expose default CTS pin Expose the CTS pin to the ->get_mctrl() callback for the default case. Without this patch the serial core can not retrieve the CTS pin state from the SCIF driver. Signed-off-by: Magnus Damm Signed-off-by: Andrey Gusakov --- drivers/tty/serial/sh-sci.c | 24 ++++++++++++++++++++++-- include/linux/serial_sci.h | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 64bf5b6..4f82fcc 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -522,6 +522,17 @@ static void sci_poll_put_char(struct uart_port *port, unsigned char c) } #endif /* CONFIG_CONSOLE_POLL || CONFIG_SERIAL_SH_SCI_CONSOLE */ +static bool sci_cts_asserted_default(struct uart_port *port) +{ + struct sci_port *s = to_sci_port(port); + struct plat_sci_reg *reg = sci_regmap[s->cfg->regtype] + SCSPTR; + + if (reg->size) + return !(serial_port_in(port, SCSPTR) & SCSPTR_CTSDT); + + return true; +} + static void sci_init_ctsrts_default(struct uart_port *port, bool hwflow_enabled) { struct sci_port *s = to_sci_port(port); @@ -1280,14 +1291,23 @@ static void sci_set_mctrl(struct uart_port *port, unsigned int mctrl) static unsigned int sci_get_mctrl(struct uart_port *port) { + unsigned int mctrl; + struct sci_port *s = to_sci_port(port); + bool cts_asserted = false; + /* * CTS/RTS is handled in hardware when supported, while nothing * else is wired up. Keep it simple and simply assert DSR/CAR. */ - unsigned int mctrl = TIOCM_DSR | TIOCM_CAR; + mctrl = TIOCM_DSR | TIOCM_CAR; + if (port->type == PORT_HSCIF) mctrl |= TIOCM_CTS; - return mctrl; + + if (s->cfg->capabilities & SCIx_HAVE_RTSCTS) + cts_asserted = sci_cts_asserted_default(port); + + return mctrl | (cts_asserted ? TIOCM_CTS : 0); } #ifdef CONFIG_SERIAL_SH_SCI_DMA diff --git a/include/linux/serial_sci.h b/include/linux/serial_sci.h index 39884de..d61096e 100644 --- a/include/linux/serial_sci.h +++ b/include/linux/serial_sci.h @@ -59,6 +59,7 @@ #define SCSPTR_RTSIO (1 << 7) /* Serial Port RTS Pin Input/Output */ #define SCSPTR_RTSDT (1 << 6) /* Serial Port RTS Pin Data */ #define SCSPTR_CTSIO (1 << 5) /* Serial Port CTS Pin Input/Output */ +#define SCSPTR_CTSDT (1 << 4) /* Serial Port CTS Pin Data */ #define SCSPTR_SPB2IO (1 << 1) /* Serial Port Break Input/Output */ #define SCSPTR_SPB2DT (1 << 0) /* Serial Port Break Data */ -- 1.7.10.4