aboutsummaryrefslogtreecommitdiff
path: root/drivers/serial/serial_sbi.c
blob: f3ecfccab4379da74adc1a4d72cf9448ea8a46c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-License-Identifier: GPL-2.0+

#include <debug_uart.h>
#include <asm/sbi.h>

#ifdef CONFIG_SBI_V01

static inline void _debug_uart_init(void)
{
}

static inline void _debug_uart_putc(int c)
{
	if (CONFIG_IS_ENABLED(RISCV_SMODE))
		sbi_console_putchar(c);
}

#else

static int sbi_dbcn_available __section(".data");

static inline void _debug_uart_init(void)
{
	if (CONFIG_IS_ENABLED(RISCV_SMODE))
		sbi_dbcn_available = sbi_probe_extension(SBI_EXT_DBCN);
}

static inline void _debug_uart_putc(int ch)
{
	if (CONFIG_IS_ENABLED(RISCV_SMODE) && sbi_dbcn_available)
		sbi_dbcn_write_byte(ch);
}

#endif

DEBUG_UART_FUNCS