|
@@ -8,6 +8,7 @@
|
|
*/
|
|
*/
|
|
|
|
|
|
#include <sbi/riscv_io.h>
|
|
#include <sbi/riscv_io.h>
|
|
|
|
+#include <sbi/sbi_console.h>
|
|
#include <sbi_utils/serial/uart8250.h>
|
|
#include <sbi_utils/serial/uart8250.h>
|
|
|
|
|
|
/* clang-format off */
|
|
/* clang-format off */
|
|
@@ -68,7 +69,7 @@ static void set_reg(u32 num, u32 val)
|
|
writel(val, uart8250_base + offset);
|
|
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)
|
|
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);
|
|
set_reg(UART_THR_OFFSET, ch);
|
|
}
|
|
}
|
|
|
|
|
|
-int uart8250_getc(void)
|
|
|
|
|
|
+static int uart8250_getc(void)
|
|
{
|
|
{
|
|
if (get_reg(UART_LSR_OFFSET) & UART_LSR_DR)
|
|
if (get_reg(UART_LSR_OFFSET) & UART_LSR_DR)
|
|
return get_reg(UART_RBR_OFFSET);
|
|
return get_reg(UART_RBR_OFFSET);
|
|
return -1;
|
|
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,
|
|
int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift,
|
|
u32 reg_width)
|
|
u32 reg_width)
|
|
{
|
|
{
|
|
@@ -121,5 +128,7 @@ int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift,
|
|
/* Set scratchpad */
|
|
/* Set scratchpad */
|
|
set_reg(UART_SCR_OFFSET, 0x00);
|
|
set_reg(UART_SCR_OFFSET, 0x00);
|
|
|
|
|
|
|
|
+ sbi_console_set_device(&uart8250_console);
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|