2 * This file is part of the coreboot project.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
19 #include <console/console.h>
21 #include <pc80/mc146818rtc.h>
23 static struct ehci_debug_info dbg_info;
25 void set_ehci_base(unsigned ehci_base)
29 if (!dbg_info.ehci_debug)
32 diff = dbg_info.ehci_caps - ehci_base;
33 dbg_info.ehci_regs -= diff;
34 dbg_info.ehci_debug -= diff;
35 dbg_info.ehci_caps = ehci_base;
38 void set_ehci_debug(unsigned ehci_debug)
40 dbg_info.ehci_debug = ehci_debug;
43 unsigned get_ehci_debug(void)
45 return dbg_info.ehci_debug;
48 static void dbgp_init(void)
50 struct ehci_debug_info *dbg_infox;
52 /* At this point, all we have to do is copy the fixed address
53 * debug_info data structure to our version defined above. */
55 dbg_infox = (struct ehci_debug_info *)
56 ((CONFIG_RAMTOP) - sizeof(struct ehci_debug_info));
58 memcpy(&dbg_info, dbg_infox, sizeof(struct ehci_debug_info));
61 static void dbgp_tx_byte(unsigned char data)
63 if (dbg_info.ehci_debug)
64 dbgp_bulk_write_x(&dbg_info, &data, 1);
67 static unsigned char dbgp_rx_byte(void)
69 unsigned char data = 0xff;
71 if (dbg_info.ehci_debug)
72 dbgp_bulk_read_x(&dbg_info, &data, 1);
77 static int dbgp_tst_byte(void)
79 return dbg_info.ehci_debug;
82 static const struct console_driver usbdebug_direct_console __console = {
84 .tx_byte = dbgp_tx_byte,
85 .rx_byte = dbgp_rx_byte,
86 .tst_byte = dbgp_tst_byte,