diff options
author | Pali Rohár <pali@kernel.org> | 2021-01-18 12:39:25 +0100 |
---|---|---|
committer | Pali Rohár <pali@kernel.org> | 2021-01-18 12:39:25 +0100 |
commit | 74867756ef5c8f2a33af2fc59915cbd8905a23e5 (patch) | |
tree | 5a0a4a6a1b35177a1b1a9553b14578065efe6743 | |
parent | 6047a10538810086f7f13b15fcdbff4b5b40180c (diff) | |
download | arm-trusted-firmware-74867756ef5c8f2a33af2fc59915cbd8905a23e5.tar.gz |
marvell: uart: a3720: Implement console_a3700_core_getc
Implementation is simple, just check if there is a pending character in
RX FIFO via RXRDY bit of Status Register and if yes, read it from
UART_RX_REG register.
Signed-off-by: Pali Rohár <pali@kernel.org>
Change-Id: I226b6e336f44f5d0ca8dcb68e49a68e8f2f49708
-rw-r--r-- | drivers/marvell/uart/a3700_console.S | 15 | ||||
-rw-r--r-- | include/drivers/marvell/uart/a3700_console.h | 1 |
2 files changed, 13 insertions, 3 deletions
diff --git a/drivers/marvell/uart/a3700_console.S b/drivers/marvell/uart/a3700_console.S index dc374eed1..9a557aac3 100644 --- a/drivers/marvell/uart/a3700_console.S +++ b/drivers/marvell/uart/a3700_console.S @@ -196,14 +196,23 @@ endfunc console_a3700_putc * int console_a3700_core_getc(void) * Function to get a character from the console. * It returns the character grabbed on success - * or -1 on error. + * or -1 if no character is available. * In : w0 - console base address - * Out : return -1 on error else return character. + * Out : w0 - character if available, else -1 * Clobber list : x0, x1 * --------------------------------------------- */ func console_a3700_core_getc - mov w0, #-1 + /* Check if there is a pending character */ + ldr w1, [x0, #UART_STATUS_REG] + and w1, w1, #UARTLSR_RXRDY + cmp w1, #UARTLSR_RXRDY + b.ne getc_no_char + ldr w0, [x0, #UART_RX_REG] + and w0, w0, #0xff + ret +getc_no_char: + mov w0, #ERROR_NO_PENDING_CHAR ret endfunc console_a3700_core_getc diff --git a/include/drivers/marvell/uart/a3700_console.h b/include/drivers/marvell/uart/a3700_console.h index 5e3ab0515..e77a16560 100644 --- a/include/drivers/marvell/uart/a3700_console.h +++ b/include/drivers/marvell/uart/a3700_console.h @@ -48,6 +48,7 @@ /* Line Status Register bits */ #define UARTLSR_TXFIFOFULL (1 << 11) /* Tx Fifo Full */ +#define UARTLSR_RXRDY (1 << 4) /* Rx Ready */ /* UART Control Register bits */ #define UART_CTRL_RXFIFO_RESET (1 << 14) |