usbdebug: Make the EHCI debug console work in the bootblock
[coreboot.git] / src / include / console / usb.h
blobd58a6a6e5092550f0c3112f68825d4501dc37628
1 /*
2 * This file is part of the coreboot project.
4 * Copyright (C) 2007 AMD
5 * Written by Yinghai Lu <yinghai.lu@amd.com> for AMD.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
17 #ifndef _CONSOLE_USB_H_
18 #define _CONSOLE_USB_H_
20 #include <rules.h>
21 #include <stdint.h>
23 void usbdebug_init(void);
24 int usbdebug_hw_init(bool force);
26 void usb_tx_byte(int idx, unsigned char data);
27 void usb_tx_flush(int idx);
28 unsigned char usb_rx_byte(int idx);
29 int usb_can_rx_byte(int idx);
31 #define __CONSOLE_USB_ENABLE__ (IS_ENABLED(CONFIG_CONSOLE_USB) && \
32 ((ENV_BOOTBLOCK && IS_ENABLED(CONFIG_USBDEBUG_IN_PRE_RAM)) || \
33 (ENV_ROMSTAGE && IS_ENABLED(CONFIG_USBDEBUG_IN_PRE_RAM)) || \
34 (ENV_POSTCAR && IS_ENABLED(CONFIG_USBDEBUG_IN_PRE_RAM)) || \
35 ENV_RAMSTAGE))
37 #define USB_PIPE_FOR_CONSOLE 0
38 #define USB_PIPE_FOR_GDB 0
40 #if __CONSOLE_USB_ENABLE__
41 static inline void __usbdebug_init(void) { usbdebug_init(); }
42 static inline void __usb_tx_byte(u8 data)
44 usb_tx_byte(USB_PIPE_FOR_CONSOLE, data);
46 static inline void __usb_tx_flush(void) { usb_tx_flush(USB_PIPE_FOR_CONSOLE); }
47 #else
48 static inline void __usbdebug_init(void) {}
49 static inline void __usb_tx_byte(u8 data) {}
50 static inline void __usb_tx_flush(void) {}
51 #endif
53 /* */
54 #if 0 && IS_ENABLED(CONFIG_GDB_STUB) && \
55 ((ENV_ROMSTAGE && IS_ENABLED(CONFIG_USBDEBUG_IN_PRE_RAM)) \
56 || ENV_RAMSTAGE)
57 static inline void __gdb_hw_init(void) { usbdebug_init(); }
58 static inline void __gdb_tx_byte(u8 data)
60 usb_tx_byte(USB_PIPE_FOR_GDB, data);
62 static inline void __gdb_tx_flush(void) { usb_tx_flush(USB_PIPE_FOR_GDB); }
63 static inline u8 __gdb_rx_byte(void)
65 return usb_rx_byte(USB_PIPE_FOR_GDB);
67 #endif
69 #endif /* _CONSOLE_USB_H_ */