Stefan Reinauer | bb01f60 | 2009-07-21 21:20:45 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Uwe Hermann | 06694a8 | 2010-09-23 18:16:46 +0000 | [diff] [blame] | 4 | * Copyright (C) 2007 AMD |
| 5 | * Written by Yinghai Lu <yinghai.lu@amd.com> for AMD. |
| 6 | * |
Stefan Reinauer | bb01f60 | 2009-07-21 21:20:45 +0000 | [diff] [blame] | 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 | |
Patrick Georgi | 16cdbb2 | 2009-04-21 20:14:31 +0000 | [diff] [blame] | 21 | #include <string.h> |
Yinghai Lu | d57241f | 2007-02-28 11:17:02 +0000 | [diff] [blame] | 22 | #include <console/console.h> |
Kyösti Mälkki | e2227a2 | 2014-02-05 13:02:55 +0200 | [diff] [blame] | 23 | #include <console/usb.h> |
Kyösti Mälkki | fb387df | 2013-06-07 22:16:52 +0300 | [diff] [blame] | 24 | |
Yinghai Lu | d57241f | 2007-02-28 11:17:02 +0000 | [diff] [blame] | 25 | static void dbgp_init(void) |
| 26 | { |
Kyösti Mälkki | 9e7806a | 2013-07-06 11:56:49 +0300 | [diff] [blame] | 27 | usbdebug_init(); |
Yinghai Lu | d57241f | 2007-02-28 11:17:02 +0000 | [diff] [blame] | 28 | } |
| 29 | |
Stefan Reinauer | bb01f60 | 2009-07-21 21:20:45 +0000 | [diff] [blame] | 30 | static void dbgp_tx_byte(unsigned char data) |
Yinghai Lu | d57241f | 2007-02-28 11:17:02 +0000 | [diff] [blame] | 31 | { |
Kyösti Mälkki | ea6736a | 2014-02-10 00:00:44 +0200 | [diff] [blame] | 32 | usb_tx_byte(0, data); |
Yinghai Lu | d57241f | 2007-02-28 11:17:02 +0000 | [diff] [blame] | 33 | } |
| 34 | |
Stefan Reinauer | bb01f60 | 2009-07-21 21:20:45 +0000 | [diff] [blame] | 35 | static unsigned char dbgp_rx_byte(void) |
Yinghai Lu | d57241f | 2007-02-28 11:17:02 +0000 | [diff] [blame] | 36 | { |
Kyösti Mälkki | ea6736a | 2014-02-10 00:00:44 +0200 | [diff] [blame] | 37 | return usb_rx_byte(0); |
Yinghai Lu | d57241f | 2007-02-28 11:17:02 +0000 | [diff] [blame] | 38 | } |
| 39 | |
Sven Schnelle | 82704c6 | 2012-07-26 14:31:40 +0200 | [diff] [blame] | 40 | static void dbgp_tx_flush(void) |
| 41 | { |
Kyösti Mälkki | ea6736a | 2014-02-10 00:00:44 +0200 | [diff] [blame] | 42 | usb_tx_flush(0); |
Sven Schnelle | 82704c6 | 2012-07-26 14:31:40 +0200 | [diff] [blame] | 43 | } |
| 44 | |
Stefan Reinauer | bb01f60 | 2009-07-21 21:20:45 +0000 | [diff] [blame] | 45 | static int dbgp_tst_byte(void) |
Yinghai Lu | d57241f | 2007-02-28 11:17:02 +0000 | [diff] [blame] | 46 | { |
Kyösti Mälkki | ea6736a | 2014-02-10 00:00:44 +0200 | [diff] [blame] | 47 | return usb_can_rx_byte(0); |
Yinghai Lu | d57241f | 2007-02-28 11:17:02 +0000 | [diff] [blame] | 48 | } |
| 49 | |
Stefan Reinauer | bf873e4 | 2007-10-24 14:42:12 +0000 | [diff] [blame] | 50 | static const struct console_driver usbdebug_direct_console __console = { |
Stefan Reinauer | bb01f60 | 2009-07-21 21:20:45 +0000 | [diff] [blame] | 51 | .init = dbgp_init, |
| 52 | .tx_byte = dbgp_tx_byte, |
Sven Schnelle | 82704c6 | 2012-07-26 14:31:40 +0200 | [diff] [blame] | 53 | .tx_flush = dbgp_tx_flush, |
Stefan Reinauer | bb01f60 | 2009-07-21 21:20:45 +0000 | [diff] [blame] | 54 | .rx_byte = dbgp_rx_byte, |
Yinghai Lu | d57241f | 2007-02-28 11:17:02 +0000 | [diff] [blame] | 55 | .tst_byte = dbgp_tst_byte, |
| 56 | }; |