2009-07-21 23:20:45 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the coreboot project.
|
|
|
|
*
|
2010-09-23 20:16:46 +02:00
|
|
|
* Copyright (C) 2007 AMD
|
|
|
|
* Written by Yinghai Lu <yinghai.lu@amd.com> for AMD.
|
|
|
|
*
|
2009-07-21 23:20:45 +02:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2009-04-21 22:14:31 +02:00
|
|
|
#include <string.h>
|
2007-02-28 12:17:02 +01:00
|
|
|
#include <console/console.h>
|
2010-05-25 18:17:45 +02:00
|
|
|
#include <usbdebug.h>
|
2007-02-28 12:17:02 +01:00
|
|
|
#include <pc80/mc146818rtc.h>
|
|
|
|
|
2009-07-21 23:20:45 +02:00
|
|
|
static struct ehci_debug_info dbg_info;
|
2007-02-28 12:17:02 +01:00
|
|
|
|
|
|
|
void set_ehci_base(unsigned ehci_base)
|
|
|
|
{
|
|
|
|
unsigned diff;
|
2009-07-21 23:20:45 +02:00
|
|
|
|
|
|
|
if (!dbg_info.ehci_debug)
|
|
|
|
return;
|
|
|
|
|
2010-08-04 21:29:11 +02:00
|
|
|
diff = (unsigned)dbg_info.ehci_caps - ehci_base;
|
2007-02-28 12:17:02 +01:00
|
|
|
dbg_info.ehci_regs -= diff;
|
|
|
|
dbg_info.ehci_debug -= diff;
|
2010-08-04 21:29:11 +02:00
|
|
|
dbg_info.ehci_caps = (void*)ehci_base;
|
2007-02-28 12:17:02 +01:00
|
|
|
}
|
2009-07-21 23:20:45 +02:00
|
|
|
|
2007-02-28 12:17:02 +01:00
|
|
|
void set_ehci_debug(unsigned ehci_debug)
|
|
|
|
{
|
2010-08-04 21:29:11 +02:00
|
|
|
dbg_info.ehci_debug = (void*)ehci_debug;
|
2007-02-28 12:17:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned get_ehci_debug(void)
|
|
|
|
{
|
2010-08-04 21:29:11 +02:00
|
|
|
return (unsigned)dbg_info.ehci_debug;
|
2007-02-28 12:17:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void dbgp_init(void)
|
|
|
|
{
|
2013-06-06 09:29:49 +02:00
|
|
|
#if !CONFIG_EARLY_CONSOLE
|
|
|
|
enable_usbdebug(CONFIG_USBDEBUG_DEFAULT_PORT);
|
|
|
|
#endif
|
2011-10-30 09:57:35 +01:00
|
|
|
usbdebug_init(CONFIG_EHCI_BAR, CONFIG_EHCI_DEBUG_OFFSET, &dbg_info);
|
2007-02-28 12:17:02 +01:00
|
|
|
}
|
|
|
|
|
2009-07-21 23:20:45 +02:00
|
|
|
static void dbgp_tx_byte(unsigned char data)
|
2007-02-28 12:17:02 +01:00
|
|
|
{
|
2012-07-26 14:31:40 +02:00
|
|
|
usbdebug_tx_byte(&dbg_info, data);
|
2007-02-28 12:17:02 +01:00
|
|
|
}
|
|
|
|
|
2009-07-21 23:20:45 +02:00
|
|
|
static unsigned char dbgp_rx_byte(void)
|
2007-02-28 12:17:02 +01:00
|
|
|
{
|
|
|
|
unsigned char data = 0xff;
|
2009-07-21 23:20:45 +02:00
|
|
|
|
|
|
|
if (dbg_info.ehci_debug)
|
|
|
|
dbgp_bulk_read_x(&dbg_info, &data, 1);
|
|
|
|
|
2007-02-28 12:17:02 +01:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2012-07-26 14:31:40 +02:00
|
|
|
static void dbgp_tx_flush(void)
|
|
|
|
{
|
|
|
|
usbdebug_tx_flush(&dbg_info);
|
|
|
|
}
|
|
|
|
|
2009-07-21 23:20:45 +02:00
|
|
|
static int dbgp_tst_byte(void)
|
2007-02-28 12:17:02 +01:00
|
|
|
{
|
2010-08-04 21:29:11 +02:00
|
|
|
return (int)dbg_info.ehci_debug;
|
2007-02-28 12:17:02 +01:00
|
|
|
}
|
|
|
|
|
2007-10-24 16:42:12 +02:00
|
|
|
static const struct console_driver usbdebug_direct_console __console = {
|
2009-07-21 23:20:45 +02:00
|
|
|
.init = dbgp_init,
|
|
|
|
.tx_byte = dbgp_tx_byte,
|
2012-07-26 14:31:40 +02:00
|
|
|
.tx_flush = dbgp_tx_flush,
|
2009-07-21 23:20:45 +02:00
|
|
|
.rx_byte = dbgp_rx_byte,
|
2007-02-28 12:17:02 +01:00
|
|
|
.tst_byte = dbgp_tst_byte,
|
|
|
|
};
|