9
0
Fork 0

atmel_serial: add rs485 support

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Jean-Christophe PLAGNIOL-VILLARD 2013-09-19 15:20:25 +02:00 committed by Sascha Hauer
parent 9adf567789
commit 568e628974
1 changed files with 27 additions and 0 deletions

View File

@ -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);