xref: /aosp_15_r20/external/coreboot/src/include/console/usb.h (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef _CONSOLE_USB_H_
4 #define _CONSOLE_USB_H_
5 
6 #include <types.h>
7 
8 void usbdebug_init(void);
9 int usbdebug_hw_init(bool force);
10 
11 void usb_tx_byte(int idx, unsigned char data);
12 void usb_tx_flush(int idx);
13 unsigned char usb_rx_byte(int idx);
14 int usb_can_rx_byte(int idx);
15 
16 #define __CONSOLE_USB_ENABLE__	(CONFIG(CONSOLE_USB) && \
17 	((ENV_BOOTBLOCK && CONFIG(USBDEBUG_IN_PRE_RAM)) || \
18 	 (ENV_SEPARATE_ROMSTAGE && CONFIG(USBDEBUG_IN_PRE_RAM)) || \
19 	 (ENV_POSTCAR && CONFIG(USBDEBUG_IN_PRE_RAM)) || \
20 	 (ENV_SEPARATE_VERSTAGE && CONFIG(USBDEBUG_IN_PRE_RAM)) || \
21 	 ENV_RAMSTAGE))
22 
23 #define USB_PIPE_FOR_CONSOLE 0
24 #define USB_PIPE_FOR_GDB 0
25 
26 #if __CONSOLE_USB_ENABLE__
__usbdebug_init(void)27 static inline void __usbdebug_init(void)	{ usbdebug_init(); }
__usb_tx_byte(u8 data)28 static inline void __usb_tx_byte(u8 data)
29 {
30 	usb_tx_byte(USB_PIPE_FOR_CONSOLE, data);
31 }
__usb_tx_flush(void)32 static inline void __usb_tx_flush(void)	{ usb_tx_flush(USB_PIPE_FOR_CONSOLE); }
33 #else
__usbdebug_init(void)34 static inline void __usbdebug_init(void)	{}
__usb_tx_byte(u8 data)35 static inline void __usb_tx_byte(u8 data)	{}
__usb_tx_flush(void)36 static inline void __usb_tx_flush(void)	{}
37 #endif
38 
39 #endif /* _CONSOLE_USB_H_ */
40