Commit 055560b0 authored by Elen Song's avatar Elen Song Committed by Greg Kroah-Hartman

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: default avatarElen Song <elen.song@atmel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 33d64c4f
...@@ -97,6 +97,7 @@ static void atmel_stop_rx(struct uart_port *port); ...@@ -97,6 +97,7 @@ static void atmel_stop_rx(struct uart_port *port);
#define UART_PUT_BRGR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_BRGR) #define UART_PUT_BRGR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_BRGR)
#define UART_PUT_RTOR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_RTOR) #define UART_PUT_RTOR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_RTOR)
#define UART_PUT_TTGR(port, v) __raw_writel(v, (port)->membase + ATMEL_US_TTGR) #define UART_PUT_TTGR(port, v) __raw_writel(v, (port)->membase + ATMEL_US_TTGR)
#define UART_GET_IP_NAME(port) __raw_readl((port)->membase + ATMEL_US_NAME)
/* PDC registers */ /* PDC registers */
#define UART_PUT_PTCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_PTCR) #define UART_PUT_PTCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_PTCR)
...@@ -166,6 +167,7 @@ struct atmel_uart_port { ...@@ -166,6 +167,7 @@ struct atmel_uart_port {
struct serial_rs485 rs485; /* rs485 settings */ struct serial_rs485 rs485; /* rs485 settings */
unsigned int tx_done_mask; unsigned int tx_done_mask;
bool is_usart; /* usart or uart */
int (*prepare_rx)(struct uart_port *port); int (*prepare_rx)(struct uart_port *port);
int (*prepare_tx)(struct uart_port *port); int (*prepare_tx)(struct uart_port *port);
void (*schedule_rx)(struct uart_port *port); void (*schedule_rx)(struct uart_port *port);
...@@ -1477,6 +1479,34 @@ static void atmel_set_ops(struct uart_port *port) ...@@ -1477,6 +1479,34 @@ static void atmel_set_ops(struct uart_port *port)
} }
} }
/*
* Get ip name usart or uart
*/
static int atmel_get_ip_name(struct uart_port *port)
{
struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
int name = UART_GET_IP_NAME(port);
int usart, uart;
/* usart and uart ascii */
usart = 0x55534152;
uart = 0x44424755;
atmel_port->is_usart = false;
if (name == usart) {
dev_dbg(port->dev, "This is usart\n");
atmel_port->is_usart = true;
} else if (name == uart) {
dev_dbg(port->dev, "This is uart\n");
atmel_port->is_usart = false;
} else {
dev_err(port->dev, "Not supported ip name, set to uart\n");
return -EINVAL;
}
return 0;
}
/* /*
* Perform initialization and enable port for reception * Perform initialization and enable port for reception
*/ */
...@@ -2336,6 +2366,13 @@ static int atmel_serial_probe(struct platform_device *pdev) ...@@ -2336,6 +2366,13 @@ static int atmel_serial_probe(struct platform_device *pdev)
UART_PUT_CR(&port->uart, ATMEL_US_RTSEN); UART_PUT_CR(&port->uart, ATMEL_US_RTSEN);
} }
/*
* Get port name of usart or uart
*/
ret = atmel_get_ip_name(&port->uart);
if (ret < 0)
goto err_add_port;
return 0; return 0;
err_add_port: err_add_port:
......
...@@ -124,4 +124,6 @@ ...@@ -124,4 +124,6 @@
#define ATMEL_US_NER 0x44 /* Number of Errors Register */ #define ATMEL_US_NER 0x44 /* Number of Errors Register */
#define ATMEL_US_IF 0x4c /* IrDA Filter Register */ #define ATMEL_US_IF 0x4c /* IrDA Filter Register */
#define ATMEL_US_NAME 0xf0 /* Ip Name */
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment