Kyösti Mälkki | e2227a2 | 2014-02-05 13:02:55 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2007 AMD |
| 5 | * Written by Yinghai Lu <yinghai.lu@amd.com> for AMD. |
| 6 | * |
| 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. |
| 10 | * |
| 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. |
Kyösti Mälkki | e2227a2 | 2014-02-05 13:02:55 +0200 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #ifndef _CONSOLE_USB_H_ |
| 18 | #define _CONSOLE_USB_H_ |
| 19 | |
Kyösti Mälkki | f339086 | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 20 | #include <rules.h> |
| 21 | #include <stdint.h> |
| 22 | |
Kyösti Mälkki | e2227a2 | 2014-02-05 13:02:55 +0200 | [diff] [blame] | 23 | int usbdebug_init(void); |
| 24 | |
Kyösti Mälkki | ea6736a | 2014-02-10 00:00:44 +0200 | [diff] [blame] | 25 | void usb_tx_byte(int idx, unsigned char data); |
| 26 | void usb_tx_flush(int idx); |
| 27 | unsigned char usb_rx_byte(int idx); |
| 28 | int usb_can_rx_byte(int idx); |
Kyösti Mälkki | e2227a2 | 2014-02-05 13:02:55 +0200 | [diff] [blame] | 29 | |
Kyösti Mälkki | f339086 | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 30 | #define __CONSOLE_USB_ENABLE__ CONFIG_CONSOLE_USB && \ |
| 31 | ((ENV_ROMSTAGE && CONFIG_USBDEBUG_IN_ROMSTAGE) || ENV_RAMSTAGE) |
| 32 | |
Kyösti Mälkki | f2f7f03 | 2014-04-04 15:05:28 +0300 | [diff] [blame] | 33 | #define USB_PIPE_FOR_CONSOLE 0 |
| 34 | #define USB_PIPE_FOR_GDB 0 |
| 35 | |
Kyösti Mälkki | f339086 | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 36 | #if __CONSOLE_USB_ENABLE__ |
| 37 | static inline void __usbdebug_init(void) { usbdebug_init(); } |
Kyösti Mälkki | f2f7f03 | 2014-04-04 15:05:28 +0300 | [diff] [blame] | 38 | static inline void __usb_tx_byte(u8 data) { usb_tx_byte(USB_PIPE_FOR_CONSOLE, data); } |
| 39 | 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] | 40 | #else |
| 41 | static inline void __usbdebug_init(void) {} |
| 42 | static inline void __usb_tx_byte(u8 data) {} |
| 43 | static inline void __usb_tx_flush(void) {} |
| 44 | #endif |
| 45 | |
Kyösti Mälkki | f2f7f03 | 2014-04-04 15:05:28 +0300 | [diff] [blame] | 46 | /* */ |
| 47 | #if 0 && CONFIG_GDB_STUB && \ |
| 48 | ((ENV_ROMSTAGE && CONFIG_USBDEBUG_IN_ROMSTAGE) || ENV_RAMSTAGE) |
| 49 | static inline void __gdb_hw_init(void) { usbdebug_init(); } |
| 50 | static inline void __gdb_tx_byte(u8 data) { usb_tx_byte(USB_PIPE_FOR_GDB, data); } |
| 51 | static inline void __gdb_tx_flush(void) { usb_tx_flush(USB_PIPE_FOR_GDB); } |
| 52 | static inline u8 __gdb_rx_byte(void) { return usb_rx_byte(USB_PIPE_FOR_GDB); } |
| 53 | #endif |
| 54 | |
Kyösti Mälkki | e2227a2 | 2014-02-05 13:02:55 +0200 | [diff] [blame] | 55 | #endif /* _CONSOLE_USB_H_ */ |