Separate CMOS layout from lbtable handling
[coreboot.git] / src / pc80 / usbdebug_serial.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007 AMD
5  * Written by Yinghai Lu <yinghai.lu@amd.com> for AMD.
6  *
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
21 #include "../lib/usbdebug.c"
22 #include <arch/io.h>
23 #include <ehci.h>
24
25 void early_usbdebug_init(void)
26 {
27         struct ehci_debug_info *dbg_info = (struct ehci_debug_info *)
28             (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE - sizeof(struct ehci_debug_info));
29
30         usbdebug_init(CONFIG_EHCI_BAR, CONFIG_EHCI_DEBUG_OFFSET, dbg_info);
31 }
32
33 void usbdebug_tx_byte(unsigned char data)
34 {
35         struct ehci_debug_info *dbg_info;
36
37         /* "Find" dbg_info structure in Cache */
38         dbg_info = (struct ehci_debug_info *)
39             (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE - sizeof(struct ehci_debug_info));
40
41         if (dbg_info->ehci_debug) {
42                 dbgp_bulk_write_x(dbg_info, (char*)&data, 1);
43         }
44 }
45
46 void usbdebug_ram_tx_byte(unsigned char data)
47 {
48         struct ehci_debug_info *dbg_info;
49
50         /* "Find" dbg_info structure in RAM */
51         dbg_info = (struct ehci_debug_info *)
52             ((CONFIG_RAMTOP) - sizeof(struct ehci_debug_info));
53
54         if (dbg_info->ehci_debug) {
55                 dbgp_bulk_write_x(dbg_info, (char*)&data, 1);
56         }
57 }