summaryrefslogtreecommitdiffstats
path: root/drivers/serial/atmel.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/serial/atmel.c')
-rw-r--r--drivers/serial/atmel.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/serial/atmel.c b/drivers/serial/atmel.c
index 8392e78..c2a5d33 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.
@@ -401,6 +427,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);