blob: f3ecfccab4379da74adc1a4d72cf9448ea8a46c6 [file] [log] [blame]
Samuel Holland4c33c262021-09-12 10:56:09 -05001// SPDX-License-Identifier: GPL-2.0+
2
3#include <debug_uart.h>
4#include <asm/sbi.h>
5
Heinrich Schuchardt444c6c52023-09-04 13:24:04 +02006#ifdef CONFIG_SBI_V01
7
Samuel Holland4c33c262021-09-12 10:56:09 -05008static inline void _debug_uart_init(void)
9{
10}
11
12static inline void _debug_uart_putc(int c)
13{
14 if (CONFIG_IS_ENABLED(RISCV_SMODE))
15 sbi_console_putchar(c);
16}
17
Heinrich Schuchardt444c6c52023-09-04 13:24:04 +020018#else
19
Heinrich Schuchardt528a19f2024-02-26 17:32:26 +010020static int sbi_dbcn_available __section(".data");
Heinrich Schuchardt444c6c52023-09-04 13:24:04 +020021
22static inline void _debug_uart_init(void)
23{
24 if (CONFIG_IS_ENABLED(RISCV_SMODE))
25 sbi_dbcn_available = sbi_probe_extension(SBI_EXT_DBCN);
26}
27
28static inline void _debug_uart_putc(int ch)
29{
30 if (CONFIG_IS_ENABLED(RISCV_SMODE) && sbi_dbcn_available)
31 sbi_dbcn_write_byte(ch);
32}
33
34#endif
35
Samuel Holland4c33c262021-09-12 10:56:09 -050036DEBUG_UART_FUNCS