zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame^] | 1 | /* |
| 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 | |
| 33 | void 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 | |
| 46 | void 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 | } |