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:
@@ -23,14 +23,14 @@
|
||||
|
||||
static volatile void *uart_base;
|
||||
|
||||
void shakti_uart_putc(char ch)
|
||||
static void shakti_uart_putc(char ch)
|
||||
{
|
||||
while((readw(uart_base + REG_STATUS) & UART_TX_FULL))
|
||||
;
|
||||
writeb(ch, uart_base + REG_TX);
|
||||
}
|
||||
|
||||
int shakti_uart_getc(void)
|
||||
static int shakti_uart_getc(void)
|
||||
{
|
||||
u16 status = readw(uart_base + REG_STATUS);
|
||||
if (status & UART_RX_FULL)
|
||||
@@ -38,11 +38,19 @@ int shakti_uart_getc(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static struct sbi_console_device shakti_console = {
|
||||
.name = "shakti_uart",
|
||||
.console_putc = shakti_uart_putc,
|
||||
.console_getc = shakti_uart_getc
|
||||
};
|
||||
|
||||
int shakti_uart_init(unsigned long base, u32 in_freq, u32 baudrate)
|
||||
{
|
||||
uart_base = (volatile void *)base;
|
||||
u16 baud = (u16)(in_freq/(16 * baudrate));
|
||||
writew(baud, uart_base + REG_BAUD);
|
||||
|
||||
sbi_console_set_device(&shakti_console);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user