diff options
author | Vijai Kumar K <vijai@behindbytes.com> | 2020-12-07 22:24:16 +0530 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2021-01-07 10:18:23 +0530 |
commit | 0d49c3bc1823df8bf229ba3ece8ca0a753f0622b (patch) | |
tree | aff2da83d3e3f2cec3066e434cb2728446f9bca3 /lib | |
parent | 12394a269b8b60e2d37b56afb2fa39fde6a3a4b8 (diff) | |
download | opensbi-0d49c3bc1823df8bf229ba3ece8ca0a753f0622b.zip opensbi-0d49c3bc1823df8bf229ba3ece8ca0a753f0622b.tar.gz opensbi-0d49c3bc1823df8bf229ba3ece8ca0a753f0622b.tar.bz2 |
lib: utils: Fix shakti uart implementation
Fix uart_putc implementation.
Due to a bug in the IP, this went unnoticed.
Use macros instead of magic numbers to make the code
more readable.
Signed-off-by: Vijai Kumar K <vijai@behindbytes.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/utils/serial/shakti-uart.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/utils/serial/shakti-uart.c b/lib/utils/serial/shakti-uart.c index 493edcf..7c1148e 100644 --- a/lib/utils/serial/shakti-uart.c +++ b/lib/utils/serial/shakti-uart.c @@ -18,18 +18,22 @@ #define REG_IQ_CYCLES 0x1C #define REG_RX_THRES 0x20 +#define UART_TX_FULL 0x2 +#define UART_RX_FULL 0x8 + static volatile void *uart_base; void shakti_uart_putc(char ch) { - while((readw(uart_base + REG_STATUS) & 0x2) == 0); + while((readw(uart_base + REG_STATUS) & UART_TX_FULL)) + ; writeb(ch, uart_base + REG_TX); } int shakti_uart_getc(void) { u16 status = readw(uart_base + REG_STATUS); - if (status & 0x8) + if (status & UART_RX_FULL) return readb(uart_base + REG_RX); return -1; } |