blob: c558a2698a506dee2cb5c8c7a77ec3fad1e72ef3 [file] [log] [blame]
zbao246e84b2012-07-13 18:47:03 +08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2010 Advanced Micro Devices, Inc.
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#include <stdint.h>
20#include <arch/io.h>
21#include <arch/romcc_io.h>
22#include <usbdebug.h>
23#include <device/pci_def.h>
24#include "hudson.h"
25
26#ifndef HUDSON_DEVN_BASE
27#define HUDSON_DEVN_BASE 0
28#endif
29
30#define EHCI_EOR (CONFIG_EHCI_BAR + 0x20)
31#define DEBUGPORT_MISC_CONTROL (EHCI_EOR + 0x80)
32
33void set_debug_port(unsigned int port)
34{
35 u32 reg32;
36
37 /* Write the port number to DEBUGPORT_MISC_CONTROL[31:28]. */
38 reg32 = read32(DEBUGPORT_MISC_CONTROL);
39 reg32 &= ~(0xf << 28);
40 reg32 |= (port << 28);
41 reg32 |= (1 << 27); /* Enable Debug Port port number remapping. */
42 write32(DEBUGPORT_MISC_CONTROL, reg32);
43}
44
45
46void enable_usbdebug(unsigned int port)
47{
48 pci_write_config32(PCI_DEV(0, HUDSON_DEVN_BASE + 0x13, 5),
49 EHCI_BAR_INDEX, CONFIG_EHCI_BAR);
50 pci_write_config8(PCI_DEV(0, HUDSON_DEVN_BASE + 0x13, 5), 0x04, 0x2); /* mem space enabe */
51 set_debug_port(port);
52}