mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-25 07:41:42 +01:00
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>
This commit is contained in:
@@ -66,7 +66,7 @@ static void set_reg(u32 num, u32 val)
|
||||
writel(val, uart_base + (num * 0x4));
|
||||
}
|
||||
|
||||
void sifive_uart_putc(char ch)
|
||||
static void sifive_uart_putc(char ch)
|
||||
{
|
||||
while (get_reg(UART_REG_TXFIFO) & UART_TXFIFO_FULL)
|
||||
;
|
||||
@@ -74,7 +74,7 @@ void sifive_uart_putc(char ch)
|
||||
set_reg(UART_REG_TXFIFO, ch);
|
||||
}
|
||||
|
||||
int sifive_uart_getc(void)
|
||||
static int sifive_uart_getc(void)
|
||||
{
|
||||
u32 ret = get_reg(UART_REG_RXFIFO);
|
||||
if (!(ret & UART_RXFIFO_EMPTY))
|
||||
@@ -82,6 +82,12 @@ int sifive_uart_getc(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static struct sbi_console_device sifive_console = {
|
||||
.name = "sifive_uart",
|
||||
.console_putc = sifive_uart_putc,
|
||||
.console_getc = sifive_uart_getc
|
||||
};
|
||||
|
||||
int sifive_uart_init(unsigned long base, u32 in_freq, u32 baudrate)
|
||||
{
|
||||
uart_base = (volatile void *)base;
|
||||
@@ -98,5 +104,7 @@ int sifive_uart_init(unsigned long base, u32 in_freq, u32 baudrate)
|
||||
/* Enable Rx */
|
||||
set_reg(UART_REG_RXCTRL, UART_RXCTRL_RXEN);
|
||||
|
||||
sbi_console_set_device(&sifive_console);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user