diff options
author | Anup Patel <anup.patel@wdc.com> | 2021-04-21 18:03:50 +0530 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2021-04-28 16:58:23 +0530 |
commit | 068ca086af2312d56efe51a724d78d84e1339ab4 (patch) | |
tree | 0e90c1a9e7a03254ff5dcb33507c5c9a06f9de3e /lib/utils/serial/uart8250.c | |
parent | a3689db92a0e83ef25c52887aa686e4527e35a22 (diff) | |
download | opensbi-068ca086af2312d56efe51a724d78d84e1339ab4.zip opensbi-068ca086af2312d56efe51a724d78d84e1339ab4.tar.gz opensbi-068ca086af2312d56efe51a724d78d84e1339ab4.tar.bz2 |
lib: sbi: Simplify console platform operations
Instead of having console_putc() and console_getc() callbacks in
platform operations, it will be much simpler for console driver to
directly register these operations as device to the sbi_console
implementation.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Xiang W <wxjstz@126.com>
Diffstat (limited to 'lib/utils/serial/uart8250.c')
-rw-r--r-- | lib/utils/serial/uart8250.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/utils/serial/uart8250.c b/lib/utils/serial/uart8250.c index 9635ba8..1cf6624 100644 --- a/lib/utils/serial/uart8250.c +++ b/lib/utils/serial/uart8250.c @@ -8,6 +8,7 @@ */ #include <sbi/riscv_io.h> +#include <sbi/sbi_console.h> #include <sbi_utils/serial/uart8250.h> /* clang-format off */ @@ -68,7 +69,7 @@ static void set_reg(u32 num, u32 val) writel(val, uart8250_base + offset); } -void uart8250_putc(char ch) +static void uart8250_putc(char ch) { while ((get_reg(UART_LSR_OFFSET) & UART_LSR_THRE) == 0) ; @@ -76,13 +77,19 @@ void uart8250_putc(char ch) set_reg(UART_THR_OFFSET, ch); } -int uart8250_getc(void) +static int uart8250_getc(void) { if (get_reg(UART_LSR_OFFSET) & UART_LSR_DR) return get_reg(UART_RBR_OFFSET); return -1; } +static struct sbi_console_device uart8250_console = { + .name = "uart8250", + .console_putc = uart8250_putc, + .console_getc = uart8250_getc +}; + int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift, u32 reg_width) { @@ -121,5 +128,7 @@ int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift, /* Set scratchpad */ set_reg(UART_SCR_OFFSET, 0x00); + sbi_console_set_device(&uart8250_console); + return 0; } |