Angel Pons | 32859fc | 2020-04-02 23:48:27 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Kyösti Mälkki | e2227a2 | 2014-02-05 13:02:55 +0200 | [diff] [blame] | 2 | |
| 3 | #ifndef _CONSOLE_USB_H_ |
| 4 | #define _CONSOLE_USB_H_ |
| 5 | |
Julius Werner | a214837 | 2019-11-13 19:50:33 -0800 | [diff] [blame] | 6 | #include <types.h> |
Kyösti Mälkki | f339086 | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 7 | |
Kyösti Mälkki | d07f377 | 2017-09-07 19:16:27 +0300 | [diff] [blame] | 8 | void usbdebug_init(void); |
Kyösti Mälkki | 63649d2 | 2018-12-29 09:40:40 +0200 | [diff] [blame] | 9 | int usbdebug_hw_init(bool force); |
Kyösti Mälkki | e2227a2 | 2014-02-05 13:02:55 +0200 | [diff] [blame] | 10 | |
Kyösti Mälkki | ea6736a | 2014-02-10 00:00:44 +0200 | [diff] [blame] | 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); |
Kyösti Mälkki | e2227a2 | 2014-02-05 13:02:55 +0200 | [diff] [blame] | 15 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 16 | #define __CONSOLE_USB_ENABLE__ (CONFIG(CONSOLE_USB) && \ |
| 17 | ((ENV_BOOTBLOCK && CONFIG(USBDEBUG_IN_PRE_RAM)) || \ |
Arthur Heymans | a2bc254 | 2021-05-29 08:10:49 +0200 | [diff] [blame^] | 18 | (ENV_SEPARATE_ROMSTAGE && CONFIG(USBDEBUG_IN_PRE_RAM)) || \ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 19 | (ENV_POSTCAR && CONFIG(USBDEBUG_IN_PRE_RAM)) || \ |
Julius Werner | 21a4053 | 2020-04-21 16:03:53 -0700 | [diff] [blame] | 20 | (ENV_SEPARATE_VERSTAGE && CONFIG(USBDEBUG_IN_PRE_RAM)) || \ |
Nico Huber | afa9aef | 2017-05-18 16:12:07 +0200 | [diff] [blame] | 21 | ENV_RAMSTAGE)) |
Kyösti Mälkki | f339086 | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 22 | |
Kyösti Mälkki | f2f7f03 | 2014-04-04 15:05:28 +0300 | [diff] [blame] | 23 | #define USB_PIPE_FOR_CONSOLE 0 |
| 24 | #define USB_PIPE_FOR_GDB 0 |
| 25 | |
Kyösti Mälkki | f339086 | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 26 | #if __CONSOLE_USB_ENABLE__ |
| 27 | static inline void __usbdebug_init(void) { usbdebug_init(); } |
Lee Leahy | 6a566d7 | 2017-03-07 17:45:12 -0800 | [diff] [blame] | 28 | static inline void __usb_tx_byte(u8 data) |
| 29 | { |
| 30 | usb_tx_byte(USB_PIPE_FOR_CONSOLE, data); |
| 31 | } |
Kyösti Mälkki | f2f7f03 | 2014-04-04 15:05:28 +0300 | [diff] [blame] | 32 | static inline void __usb_tx_flush(void) { usb_tx_flush(USB_PIPE_FOR_CONSOLE); } |
Kyösti Mälkki | f339086 | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 33 | #else |
| 34 | static inline void __usbdebug_init(void) {} |
| 35 | static inline void __usb_tx_byte(u8 data) {} |
| 36 | static inline void __usb_tx_flush(void) {} |
| 37 | #endif |
| 38 | |
Kyösti Mälkki | e2227a2 | 2014-02-05 13:02:55 +0200 | [diff] [blame] | 39 | #endif /* _CONSOLE_USB_H_ */ |