mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 4/5] atmel_serial: add rs485 support
Date: Thu, 19 Sep 2013 15:20:25 +0200	[thread overview]
Message-ID: <1379596826-5743-4-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1379596826-5743-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/serial/atmel.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/serial/atmel.c b/drivers/serial/atmel.c
index 89c141e..40945c9 100644
--- a/drivers/serial/atmel.c
+++ b/drivers/serial/atmel.c
@@ -362,6 +362,32 @@ static int atmel_serial_setbaudrate(struct console_device *cdev, int baudrate)
 	return 0;
 }
 
+static int atmel_serial_set_mode(struct console_device *cdev, enum console_mode mode)
+{
+	struct atmel_uart_port *uart = to_atmel_uart_port(cdev);
+	u32 mr;
+	u8 m;
+
+	mr = readl(uart->base + USART3_MR);
+	mr &= ~0xf;
+
+	switch (mode) {
+	case CONSOLE_MODE_NORMAL:
+		m = USART3_USART_MODE_NORMAL;
+		break;
+	case CONSOLE_MODE_RS485:
+		m = USART3_USART_MODE_RS485;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	mr |= USART3_BF(USART_MODE, m);
+	writel(mr, uart->base + USART3_MR);
+
+	return 0;
+}
+
 /*
  * Initialise the serial port with the given baudrate. The settings
  * are always 8 data bits, no parity, 1 stop bit, no start bits.
@@ -404,6 +430,7 @@ static int atmel_serial_probe(struct device_d *dev)
 	cdev->putc = atmel_serial_putc;
 	cdev->getc = atmel_serial_getc;
 	cdev->setbrg = atmel_serial_setbaudrate;
+	cdev->set_mode = atmel_serial_set_mode;
 
 	atmel_serial_init_port(cdev);
 
-- 
1.8.4.rc1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2013-09-19 13:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-19 13:19 [PATCH 0/5] introduce basic " Jean-Christophe PLAGNIOL-VILLARD
2013-09-19 13:20 ` [PATCH 1/5] shutdown: add board call back Jean-Christophe PLAGNIOL-VILLARD
2013-09-19 13:20   ` [PATCH 2/5] console: introduce console_get_by_dev Jean-Christophe PLAGNIOL-VILLARD
2013-09-19 13:20   ` [PATCH 3/5] console: introduce new callback set_mode Jean-Christophe PLAGNIOL-VILLARD
2013-09-19 13:20   ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2013-09-19 13:20   ` [PATCH 5/5] Animeo IP: add rs485 crossing detection support Jean-Christophe PLAGNIOL-VILLARD
2013-09-24  7:22 ` [PATCH 0/5] introduce basic rs485 support Sascha Hauer

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=1379596826-5743-4-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    /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