blob: b5aab66649806a4ee53c23f318a38592379b62a0 [file] [log] [blame]
Kyösti Mälkkie2227a22014-02-05 13:02:55 +02001/*
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.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
19 */
20
21#ifndef _CONSOLE_USB_H_
22#define _CONSOLE_USB_H_
23
Kyösti Mälkkif3390862014-02-26 15:19:04 +020024#include <rules.h>
25#include <stdint.h>
26
Kyösti Mälkkie2227a22014-02-05 13:02:55 +020027int usbdebug_init(void);
28
Kyösti Mälkkiea6736a2014-02-10 00:00:44 +020029void usb_tx_byte(int idx, unsigned char data);
30void usb_tx_flush(int idx);
31unsigned char usb_rx_byte(int idx);
32int usb_can_rx_byte(int idx);
Kyösti Mälkkie2227a22014-02-05 13:02:55 +020033
Kyösti Mälkkif3390862014-02-26 15:19:04 +020034#define __CONSOLE_USB_ENABLE__ CONFIG_CONSOLE_USB && \
35 ((ENV_ROMSTAGE && CONFIG_USBDEBUG_IN_ROMSTAGE) || ENV_RAMSTAGE)
36
Kyösti Mälkkif2f7f032014-04-04 15:05:28 +030037#define USB_PIPE_FOR_CONSOLE 0
38#define USB_PIPE_FOR_GDB 0
39
Kyösti Mälkkif3390862014-02-26 15:19:04 +020040#if __CONSOLE_USB_ENABLE__
41static inline void __usbdebug_init(void) { usbdebug_init(); }
Kyösti Mälkkif2f7f032014-04-04 15:05:28 +030042static inline void __usb_tx_byte(u8 data) { usb_tx_byte(USB_PIPE_FOR_CONSOLE, data); }
43static inline void __usb_tx_flush(void) { usb_tx_flush(USB_PIPE_FOR_CONSOLE); }
Kyösti Mälkkif3390862014-02-26 15:19:04 +020044#else
45static inline void __usbdebug_init(void) {}
46static inline void __usb_tx_byte(u8 data) {}
47static inline void __usb_tx_flush(void) {}
48#endif
49
Kyösti Mälkkif2f7f032014-04-04 15:05:28 +030050/* */
51#if 0 && CONFIG_GDB_STUB && \
52 ((ENV_ROMSTAGE && CONFIG_USBDEBUG_IN_ROMSTAGE) || ENV_RAMSTAGE)
53static inline void __gdb_hw_init(void) { usbdebug_init(); }
54static inline void __gdb_tx_byte(u8 data) { usb_tx_byte(USB_PIPE_FOR_GDB, data); }
55static inline void __gdb_tx_flush(void) { usb_tx_flush(USB_PIPE_FOR_GDB); }
56static inline u8 __gdb_rx_byte(void) { return usb_rx_byte(USB_PIPE_FOR_GDB); }
57#endif
58
Kyösti Mälkkie2227a22014-02-05 13:02:55 +020059#endif /* _CONSOLE_USB_H_ */