Skip to contentSkip to conversation

tty: cadence:: Add support for setting modem control signals

PATCH In review Lars-Peter Clausen 2 participants 2 messages Nov 4, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tty: cadence:: Add support for setting modem control signals

Add support for setting the state of the DTR and RTS signals.

---
 drivers/tty/serial/xilinx_uartps.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
drivers/tty/serial/xilinx_uartps.c +21 -1
index 200c1af..fb1de12 100644
@@ -133,6 +133,15 @@ MODULE_PARM_DESC(rx_timeout, "Rx timeout, 1-255");
 #define CDNS_UART_IXR_BRK	0x80000000
 
 /*
+ * Modem Control register:
+ * The read/write Modem Control register controls the interface with the modem
+ * or data set, or a peripheral device emulating a modem.
+ */
+#define CDNS_UART_MODEMCR_FCM	0x00000020 /* Automatic flow control mode */
+#define CDNS_UART_MODEMCR_RTS	0x00000002 /* Request to send output control */
+#define CDNS_UART_MODEMCR_DTR	0x00000001 /* Data Terminal Ready */
+
+/*
  * Channel Status Register:
  * The channel status register (CSR) is provided to enable the control logic
  * to monitor the status of bits in the channel interrupt status register,
@@ -915,7 +924,18 @@ static unsigned int cdns_uart_get_mctrl(struct uart_port *port)
 
 static void cdns_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
 {
-	/* N/A */
+	unsigned int val;
+
+	val = cdns_uart_readl(CDNS_UART_MODEMCR_OFFSET);
+
+	val &= ~(CDNS_UART_MODEMCR_RTS | CDNS_UART_MODEMCR_DTR);
+
+	if (mctrl & TIOCM_RTS)
+		val |= CDNS_UART_MODEMCR_RTS;
+	if (mctrl & TIOCM_DTR)
+		val |= CDNS_UART_MODEMCR_DTR;
+
+	cdns_uart_writel(val, CDNS_UART_MODEMCR_OFFSET);
 }
 
 #ifdef CONFIG_CONSOLE_POLL
Signature · 1 line
1.8.0
Acked-by on v1 1/1
#1 lore raw

Hi Lars,

Quoted 12 lines · Lars-Peter Clausen

Add support for setting the state of the DTR and RTS signals.

---
 drivers/tty/serial/xilinx_uartps.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
drivers/tty/serial/xilinx_uartps.c +0 -0
index 200c1af..fb1de12 100644

drivers/tty/serial/xilinx_uartps.c MODULE_PARM_DESC(rx_timeout, "Rx timeout, 1-255"); · line 142

Quoted 10 lines
drivers/tty/serial/xilinx_uartps.c +7 -0
@@ -133,6 +133,15 @@ MODULE_PARM_DESC(rx_timeout, "Rx timeout, 1-255");
 #define CDNS_UART_IXR_BRK	0x80000000
 
 /*
+ * Modem Control register:
+ * The read/write Modem Control register controls the interface with the modem
+ * or data set, or a peripheral device emulating a modem.
+ */
+#define CDNS_UART_MODEMCR_FCM	0x00000020 /* Automatic flow control mode */
+#define CDNS_UART_MODEMCR_RTS	0x00000002 /* Request to send output control */
+#define CDNS_UART_MODEMCR_DTR	0x00000001 /* Data Terminal Ready */

I'd prefer using the BIT() macro, but I see that it doesn't really fit the style of other #defines in the driver. So, probably ok this way.

drivers/tty/serial/xilinx_uartps.c static unsigned int cdns_uart_get_mctrl(struct uart_port *port) · line 927

Quoted 11 lines
drivers/tty/serial/xilinx_uartps.c +3 -1
+
+/*
  * Channel Status Register:
  * The channel status register (CSR) is provided to enable the control logic
  * to monitor the status of bits in the channel interrupt status register,
@@ -915,7 +924,18 @@ static unsigned int cdns_uart_get_mctrl(struct uart_port *port)
 
 static void cdns_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
 {
-	/* N/A */
+	unsigned int val;

This should be u32.

I don't have a setup to actually test this, but it applies and doesn't seem to break anything :)

Given that you fix the data type:

Thanks,
Sören
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html