serial_sbi.c 606 B

123456789101112131415161718192021222324252627282930313233343536
  1. // SPDX-License-Identifier: GPL-2.0+
  2. #include <debug_uart.h>
  3. #include <asm/sbi.h>
  4. #ifdef CONFIG_SBI_V01
  5. static inline void _debug_uart_init(void)
  6. {
  7. }
  8. static inline void _debug_uart_putc(int c)
  9. {
  10. if (CONFIG_IS_ENABLED(RISCV_SMODE))
  11. sbi_console_putchar(c);
  12. }
  13. #else
  14. static int sbi_dbcn_available;
  15. static inline void _debug_uart_init(void)
  16. {
  17. if (CONFIG_IS_ENABLED(RISCV_SMODE))
  18. sbi_dbcn_available = sbi_probe_extension(SBI_EXT_DBCN);
  19. }
  20. static inline void _debug_uart_putc(int ch)
  21. {
  22. if (CONFIG_IS_ENABLED(RISCV_SMODE) && sbi_dbcn_available)
  23. sbi_dbcn_write_byte(ch);
  24. }
  25. #endif
  26. DEBUG_UART_FUNCS