Generic Linux architectural discussions
 help / color / mirror / Atom feed
From: Rodolfo Giometti <giometti@enneenne.com>
To: linux-arch@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.com>, Arnd Bergmann <arnd@arndb.de>,
	Richard Genoud <richard.genoud@gmail.com>,
	Rodolfo Giometti <giometti@linux.it>,
	Joshua Henderson <joshua.henderson@microchip.com>
Subject: [PATCH 2/2] tty serial: add multidrop support for atmel serial controllers
Date: Thu, 12 Sep 2019 10:40:32 +0200	[thread overview]
Message-ID: <20190912084032.16927-3-giometti@enneenne.com> (raw)
In-Reply-To: <20190912084032.16927-1-giometti@enneenne.com>

From: Rodolfo Giometti <giometti@linux.it>

This patch adds multidrop support for atmel serial controllers and it
has been tested by using a SAMA5D3 CPU.

Signed-off-by: Rodolfo Giometti <giometti@linux.it>
Signed-off-by: Joshua Henderson <joshua.henderson@microchip.com>
---
 drivers/tty/serial/atmel_serial.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index 0b4f36905321..b30b4a336907 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -2178,7 +2178,7 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
 {
 	struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
 	unsigned long flags;
-	unsigned int old_mode, mode, imr, quot, baud, div, cd, fp = 0;
+	unsigned int old_mode, mode, mdrop, imr, quot, baud, div, cd, fp = 0;
 
 	/* save the current mode register */
 	mode = old_mode = atmel_uart_readl(port, ATMEL_US_MR);
@@ -2211,9 +2211,11 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
 
 	/* parity */
 	if (termios->c_cflag & PARENB) {
-		/* Mark or Space parity */
+		/* Mark, Space or Multidrop parity */
 		if (termios->c_cflag & CMSPAR) {
-			if (termios->c_cflag & PARODD)
+			if (termios->c_cflag & PARMD)
+				mode |= ATMEL_US_PAR_MULTI_DROP;
+			else if (termios->c_cflag & PARODD)
 				mode |= ATMEL_US_PAR_MARK;
 			else
 				mode |= ATMEL_US_PAR_SPACE;
@@ -2221,8 +2223,11 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
 			mode |= ATMEL_US_PAR_ODD;
 		else
 			mode |= ATMEL_US_PAR_EVEN;
+
 	} else
 		mode |= ATMEL_US_PAR_NONE;
+	mdrop = termios->c_cflag & SENDA ? ATMEL_US_SENDA : 0;
+	termios->c_cflag &= ~SENDA; /* SENDA bit must be cleared once used */
 
 	spin_lock_irqsave(&port->lock, flags);
 
@@ -2363,7 +2368,8 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
 	if (!(port->iso7816.flags & SER_ISO7816_ENABLED))
 		atmel_uart_writel(port, ATMEL_US_BRGR, quot);
 	atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
-	atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);
+	atmel_uart_writel(port, ATMEL_US_CR,
+			  mdrop | ATMEL_US_TXEN | ATMEL_US_RXEN);
 	atmel_port->tx_stopped = false;
 
 	/* restore interrupts */
-- 
2.17.1

      parent reply	other threads:[~2019-09-12  8:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-12  8:40 Multidrop support Rodolfo Giometti
2019-09-12  8:40 ` [PATCH 1/2] tty: add bits to manage multidrop mode Rodolfo Giometti
2019-09-12  8:48   ` Arnd Bergmann
2019-09-12 11:01   ` Richard Genoud
2019-09-12 12:47     ` Rodolfo Giometti
2019-09-13 14:36       ` Richard Genoud
2019-09-12  8:40 ` Rodolfo Giometti [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190912084032.16927-3-giometti@enneenne.com \
    --to=giometti@enneenne.com \
    --cc=arnd@arndb.de \
    --cc=giometti@linux.it \
    --cc=gregkh@linuxfoundation.org \
    --cc=joshua.henderson@microchip.com \
    --cc=jslaby@suse.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=richard.genoud@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox