blob: 833147372b5ff53d3e7511db42006a6a312ffae7 [file] [log] [blame]
Stefan Reinauerbb01f602009-07-21 21:20:45 +00001/*
2 * This file is part of the coreboot project.
3 *
Uwe Hermann06694a82010-09-23 18:16:46 +00004 * Copyright (C) 2007 AMD
5 * Written by Yinghai Lu <yinghai.lu@amd.com> for AMD.
6 *
Stefan Reinauerbb01f602009-07-21 21:20:45 +00007 * 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
Patrick Georgi16cdbb22009-04-21 20:14:31 +000021#include <string.h>
Yinghai Lud57241f2007-02-28 11:17:02 +000022#include <console/console.h>
Kyösti Mälkkie2227a22014-02-05 13:02:55 +020023#include <console/usb.h>
Kyösti Mälkkifb387df2013-06-07 22:16:52 +030024
Yinghai Lud57241f2007-02-28 11:17:02 +000025static void dbgp_init(void)
26{
Kyösti Mälkki9e7806a2013-07-06 11:56:49 +030027 usbdebug_init();
Yinghai Lud57241f2007-02-28 11:17:02 +000028}
29
Stefan Reinauerbb01f602009-07-21 21:20:45 +000030static void dbgp_tx_byte(unsigned char data)
Yinghai Lud57241f2007-02-28 11:17:02 +000031{
Kyösti Mälkkiea6736a2014-02-10 00:00:44 +020032 usb_tx_byte(0, data);
Yinghai Lud57241f2007-02-28 11:17:02 +000033}
34
Stefan Reinauerbb01f602009-07-21 21:20:45 +000035static unsigned char dbgp_rx_byte(void)
Yinghai Lud57241f2007-02-28 11:17:02 +000036{
Kyösti Mälkkiea6736a2014-02-10 00:00:44 +020037 return usb_rx_byte(0);
Yinghai Lud57241f2007-02-28 11:17:02 +000038}
39
Sven Schnelle82704c62012-07-26 14:31:40 +020040static void dbgp_tx_flush(void)
41{
Kyösti Mälkkiea6736a2014-02-10 00:00:44 +020042 usb_tx_flush(0);
Sven Schnelle82704c62012-07-26 14:31:40 +020043}
44
Stefan Reinauerbb01f602009-07-21 21:20:45 +000045static int dbgp_tst_byte(void)
Yinghai Lud57241f2007-02-28 11:17:02 +000046{
Kyösti Mälkkiea6736a2014-02-10 00:00:44 +020047 return usb_can_rx_byte(0);
Yinghai Lud57241f2007-02-28 11:17:02 +000048}
49
Stefan Reinauerbf873e42007-10-24 14:42:12 +000050static const struct console_driver usbdebug_direct_console __console = {
Stefan Reinauerbb01f602009-07-21 21:20:45 +000051 .init = dbgp_init,
52 .tx_byte = dbgp_tx_byte,
Sven Schnelle82704c62012-07-26 14:31:40 +020053 .tx_flush = dbgp_tx_flush,
Stefan Reinauerbb01f602009-07-21 21:20:45 +000054 .rx_byte = dbgp_rx_byte,
Yinghai Lud57241f2007-02-28 11:17:02 +000055 .tst_byte = dbgp_tst_byte,
56};