This patch unifies the use of config options in v2 to all start with CONFIG_
[coreboot.git] / src / console / usbdebug_direct_console.c
1 #include <string.h>
2 #include <console/console.h>
3 #include <usbdebug_direct.h>
4 #include <pc80/mc146818rtc.h>
5
6 struct ehci_debug_info dbg_info;
7
8 void set_ehci_base(unsigned ehci_base)
9 {
10         unsigned diff;
11         if(!dbg_info.ehci_debug) return;
12         diff = dbg_info.ehci_caps - ehci_base;
13         dbg_info.ehci_regs -= diff;
14         dbg_info.ehci_debug -= diff;
15         dbg_info.ehci_caps = ehci_base;
16 }
17 void set_ehci_debug(unsigned ehci_debug)
18 {
19         dbg_info.ehci_debug = ehci_debug;
20 }
21
22 unsigned get_ehci_debug(void)
23 {
24        return dbg_info.ehci_debug;
25 }
26
27 static void dbgp_init(void)
28 {
29         struct ehci_debug_info *dbg_infox;
30         dbg_infox = (struct ehci_debug_info *)((CONFIG_LB_MEM_TOPK<<10) - sizeof (struct ehci_debug_info)); //in RAM
31         memcpy(&dbg_info, dbg_infox, sizeof(struct ehci_debug_info) );
32 }
33
34 static void dbgp_tx_byte(unsigned char data) 
35 {
36         if(dbg_info.ehci_debug) 
37                 dbgp_bulk_write_x(&dbg_info,&data,1);
38 }
39
40 static unsigned char dbgp_rx_byte(void) 
41 {
42         unsigned char data = 0xff;
43         if(dbg_info.ehci_debug) 
44                 dbgp_bulk_read_x(&dbg_info,&data,1);
45         return data;
46 }
47
48 static int dbgp_tst_byte(void) 
49 {
50         return dbg_info.ehci_debug;
51 }
52
53 static const struct console_driver usbdebug_direct_console __console = {
54         .init    = dbgp_init,
55         .tx_byte = dbgp_tx_byte,
56         .rx_byte = dbgp_rx_byte,
57         .tst_byte = dbgp_tst_byte,
58 };
59