blob: d52ea87536fb3cd154df82b400dd95f61b6e2c04 [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.
Kyösti Mälkkie2227a22014-02-05 13:02:55 +020015 */
16
17#ifndef _CONSOLE_USB_H_
18#define _CONSOLE_USB_H_
19
Kyösti Mälkkif3390862014-02-26 15:19:04 +020020#include <rules.h>
21#include <stdint.h>
22
Kyösti Mälkkie2227a22014-02-05 13:02:55 +020023int usbdebug_init(void);
24
Kyösti Mälkkiea6736a2014-02-10 00:00:44 +020025void usb_tx_byte(int idx, unsigned char data);
26void usb_tx_flush(int idx);
27unsigned char usb_rx_byte(int idx);
28int usb_can_rx_byte(int idx);
Kyösti Mälkkie2227a22014-02-05 13:02:55 +020029
Lee Leahyf00e4462017-03-07 13:17:49 -080030#define __CONSOLE_USB_ENABLE__ (CONFIG_CONSOLE_USB && \
31 ((ENV_ROMSTAGE && CONFIG_USBDEBUG_IN_ROMSTAGE) || ENV_RAMSTAGE))
Kyösti Mälkkif3390862014-02-26 15:19:04 +020032
Kyösti Mälkkif2f7f032014-04-04 15:05:28 +030033#define USB_PIPE_FOR_CONSOLE 0
34#define USB_PIPE_FOR_GDB 0
35
Kyösti Mälkkif3390862014-02-26 15:19:04 +020036#if __CONSOLE_USB_ENABLE__
37static inline void __usbdebug_init(void) { usbdebug_init(); }
Kyösti Mälkkif2f7f032014-04-04 15:05:28 +030038static inline void __usb_tx_byte(u8 data) { usb_tx_byte(USB_PIPE_FOR_CONSOLE, data); }
39static inline void __usb_tx_flush(void) { usb_tx_flush(USB_PIPE_FOR_CONSOLE); }
Kyösti Mälkkif3390862014-02-26 15:19:04 +020040#else
41static inline void __usbdebug_init(void) {}
42static inline void __usb_tx_byte(u8 data) {}
43static inline void __usb_tx_flush(void) {}
44#endif
45
Kyösti Mälkkif2f7f032014-04-04 15:05:28 +030046/* */
47#if 0 && CONFIG_GDB_STUB && \
48 ((ENV_ROMSTAGE && CONFIG_USBDEBUG_IN_ROMSTAGE) || ENV_RAMSTAGE)
49static inline void __gdb_hw_init(void) { usbdebug_init(); }
50static inline void __gdb_tx_byte(u8 data) { usb_tx_byte(USB_PIPE_FOR_GDB, data); }
51static inline void __gdb_tx_flush(void) { usb_tx_flush(USB_PIPE_FOR_GDB); }
52static inline u8 __gdb_rx_byte(void) { return usb_rx_byte(USB_PIPE_FOR_GDB); }
53#endif
54
Kyösti Mälkkie2227a22014-02-05 13:02:55 +020055#endif /* _CONSOLE_USB_H_ */