coreboot used to have two different "APIs" for memory accesses:
[coreboot.git] / src / southbridge / intel / i82801gx / i82801gx_usb_debug.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2009 coresystems GmbH
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
18  */
19
20 // An arbitrary address for the BAR
21 #define EHCI_BAR                0xFEF00000
22 // These could be read from DEBUG_BASE (0:1d.7 R 0x5A 16bit)
23 #define EHCI_BAR_INDEX          0x10
24
25 #define EHCI_CONFIG_FLAG        0x40
26 #define EHCI_PORTSC             0x44
27 #define EHCI_DEBUG_OFFSET       0xA0
28
29 void set_debug_port(unsigned port)
30 {
31         u32 dbgctl;
32
33         printk_debug("Enabling OWNER_CNT\n");
34         dbgctl = read32(EHCI_BAR + EHCI_DEBUG_OFFSET);
35         dbgctl |= (1 << 30);
36         write32(EHCI_BAR + EHCI_DEBUG_OFFSET, dbgctl);
37 }
38
39 static void i82801gx_enable_usbdebug_direct(unsigned port)
40 {
41         pci_write_config32(PCI_DEV(0, 0x1d, 7), EHCI_BAR_INDEX, EHCI_BAR);
42         pci_write_config8(PCI_DEV(0, 0x1d, 7), 0x04, 0x2); // Memory Space Enable
43         set_debug_port(port);
44 }
45