diff options
| author | Elen Song <elen.song@atmel.com> | 2013-07-22 04:30:29 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-29 16:04:12 -0400 |
| commit | 055560b04a8cd063aea916fd083b7aec02c2adb8 (patch) | |
| tree | 9ab27afe910729ddfd1eb45c5ceff766424126bf | |
| parent | 33d64c4ffab7da36d657a35fe2b494d5c971f615 (diff) | |
serial: at91: distinguish usart and uart
Distinguish usart and uart by read ip name register,
The usart read name is "USAR",
The uart and dbgu read name is "DBGU".
Signed-off-by: Elen Song <elen.song@atmel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | drivers/tty/serial/atmel_serial.c | 37 | ||||
| -rw-r--r-- | include/linux/atmel_serial.h | 2 |
2 files changed, 39 insertions, 0 deletions
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 1db68713d656..8dbc3e67dfa4 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c | |||
| @@ -97,6 +97,7 @@ static void atmel_stop_rx(struct uart_port *port); | |||
| 97 | #define UART_PUT_BRGR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_BRGR) | 97 | #define UART_PUT_BRGR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_BRGR) |
| 98 | #define UART_PUT_RTOR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_RTOR) | 98 | #define UART_PUT_RTOR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_RTOR) |
| 99 | #define UART_PUT_TTGR(port, v) __raw_writel(v, (port)->membase + ATMEL_US_TTGR) | 99 | #define UART_PUT_TTGR(port, v) __raw_writel(v, (port)->membase + ATMEL_US_TTGR) |
| 100 | #define UART_GET_IP_NAME(port) __raw_readl((port)->membase + ATMEL_US_NAME) | ||
| 100 | 101 | ||
| 101 | /* PDC registers */ | 102 | /* PDC registers */ |
| 102 | #define UART_PUT_PTCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_PTCR) | 103 | #define UART_PUT_PTCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_PTCR) |
| @@ -166,6 +167,7 @@ struct atmel_uart_port { | |||
| 166 | 167 | ||
| 167 | struct serial_rs485 rs485; /* rs485 settings */ | 168 | struct serial_rs485 rs485; /* rs485 settings */ |
| 168 | unsigned int tx_done_mask; | 169 | unsigned int tx_done_mask; |
| 170 | bool is_usart; /* usart or uart */ | ||
| 169 | int (*prepare_rx)(struct uart_port *port); | 171 | int (*prepare_rx)(struct uart_port *port); |
| 170 | int (*prepare_tx)(struct uart_port *port); | 172 | int (*prepare_tx)(struct uart_port *port); |
| 171 | void (*schedule_rx)(struct uart_port *port); | 173 | void (*schedule_rx)(struct uart_port *port); |
| @@ -1478,6 +1480,34 @@ static void atmel_set_ops(struct uart_port *port) | |||
| 1478 | } | 1480 | } |
| 1479 | 1481 | ||
| 1480 | /* | 1482 | /* |
| 1483 | * Get ip name usart or uart | ||
| 1484 | */ | ||
| 1485 | static int atmel_get_ip_name(struct uart_port *port) | ||
| 1486 | { | ||
| 1487 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); | ||
| 1488 | int name = UART_GET_IP_NAME(port); | ||
| 1489 | int usart, uart; | ||
| 1490 | /* usart and uart ascii */ | ||
| 1491 | usart = 0x55534152; | ||
| 1492 | uart = 0x44424755; | ||
| 1493 | |||
| 1494 | atmel_port->is_usart = false; | ||
| 1495 | |||
| 1496 | if (name == usart) { | ||
| 1497 | dev_dbg(port->dev, "This is usart\n"); | ||
| 1498 | atmel_port->is_usart = true; | ||
| 1499 | } else if (name == uart) { | ||
| 1500 | dev_dbg(port->dev, "This is uart\n"); | ||
| 1501 | atmel_port->is_usart = false; | ||
| 1502 | } else { | ||
| 1503 | dev_err(port->dev, "Not supported ip name, set to uart\n"); | ||
| 1504 | return -EINVAL; | ||
| 1505 | } | ||
| 1506 | |||
| 1507 | return 0; | ||
| 1508 | } | ||
| 1509 | |||
| 1510 | /* | ||
| 1481 | * Perform initialization and enable port for reception | 1511 | * Perform initialization and enable port for reception |
| 1482 | */ | 1512 | */ |
| 1483 | static int atmel_startup(struct uart_port *port) | 1513 | static int atmel_startup(struct uart_port *port) |
| @@ -2336,6 +2366,13 @@ static int atmel_serial_probe(struct platform_device *pdev) | |||
| 2336 | UART_PUT_CR(&port->uart, ATMEL_US_RTSEN); | 2366 | UART_PUT_CR(&port->uart, ATMEL_US_RTSEN); |
| 2337 | } | 2367 | } |
| 2338 | 2368 | ||
| 2369 | /* | ||
| 2370 | * Get port name of usart or uart | ||
| 2371 | */ | ||
| 2372 | ret = atmel_get_ip_name(&port->uart); | ||
| 2373 | if (ret < 0) | ||
| 2374 | goto err_add_port; | ||
| 2375 | |||
| 2339 | return 0; | 2376 | return 0; |
| 2340 | 2377 | ||
| 2341 | err_add_port: | 2378 | err_add_port: |
diff --git a/include/linux/atmel_serial.h b/include/linux/atmel_serial.h index fd6833764d72..be201ca2990c 100644 --- a/include/linux/atmel_serial.h +++ b/include/linux/atmel_serial.h | |||
| @@ -124,4 +124,6 @@ | |||
| 124 | #define ATMEL_US_NER 0x44 /* Number of Errors Register */ | 124 | #define ATMEL_US_NER 0x44 /* Number of Errors Register */ |
| 125 | #define ATMEL_US_IF 0x4c /* IrDA Filter Register */ | 125 | #define ATMEL_US_IF 0x4c /* IrDA Filter Register */ |
| 126 | 126 | ||
| 127 | #define ATMEL_US_NAME 0xf0 /* Ip Name */ | ||
| 128 | |||
| 127 | #endif | 129 | #endif |
