[PATCH 4/5] atmel_serial: add rs485 support
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Thu Sep 19 09:20:25 EDT 2013
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at 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
More information about the barebox
mailing list