Stefan Reinauer | bb01f60 | 2009-07-21 21:20:45 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Uwe Hermann | 06694a8 | 2010-09-23 18:16:46 +0000 | [diff] [blame] | 4 | * Copyright (C) 2007 AMD |
| 5 | * Written by Yinghai Lu <yinghai.lu@amd.com> for AMD. |
| 6 | * |
Stefan Reinauer | bb01f60 | 2009-07-21 21:20:45 +0000 | [diff] [blame] | 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 | |
Stefan Reinauer | 5639448 | 2010-05-25 16:02:28 +0000 | [diff] [blame] | 21 | #ifndef USBDEBUG_H |
| 22 | #define USBDEBUG_H |
Yinghai Lu | d57241f | 2007-02-28 11:17:02 +0000 | [diff] [blame] | 23 | |
Kyösti Mälkki | fb387df | 2013-06-07 22:16:52 +0300 | [diff] [blame] | 24 | #define EHCI_BAR_INDEX 0x10 |
| 25 | |
| 26 | #ifndef __PRE_RAM__ |
| 27 | #if !CONFIG_USBDEBUG |
| 28 | #define pci_ehci_read_resources pci_dev_read_resources |
| 29 | #else |
| 30 | /* Relocation of EHCI Debug Port BAR |
| 31 | * |
| 32 | * PCI EHCI controller with Debug Port capability shall replace |
| 33 | * pci_dev_read_resources() with pci_ehci_read_resources() in its |
| 34 | * declaration of device_operations for .read_resources. |
| 35 | * This installs a hook to reconfigure usbdebug when resource allocator |
| 36 | * assigns a new BAR for the device. |
| 37 | */ |
| 38 | struct device; |
| 39 | void pci_ehci_read_resources(struct device *dev); |
| 40 | #endif |
| 41 | #endif |
Myles Watson | 127e976 | 2010-08-04 19:29:11 +0000 | [diff] [blame] | 42 | |
Yinghai Lu | d57241f | 2007-02-28 11:17:02 +0000 | [diff] [blame] | 43 | struct ehci_debug_info { |
| 44 | void *ehci_caps; |
| 45 | void *ehci_regs; |
| 46 | void *ehci_debug; |
Stefan Reinauer | 16ce01b | 2011-01-28 08:05:54 +0000 | [diff] [blame] | 47 | u32 devnum; |
| 48 | u32 endpoint_out; |
| 49 | u32 endpoint_in; |
Sven Schnelle | 82704c6 | 2012-07-26 14:31:40 +0200 | [diff] [blame] | 50 | char buf[8]; |
| 51 | u8 bufidx; |
Kyösti Mälkki | 4d409b5 | 2013-07-05 21:38:54 +0300 | [diff] [blame] | 52 | u8 status; |
Yinghai Lu | d57241f | 2007-02-28 11:17:02 +0000 | [diff] [blame] | 53 | }; |
Stefan Reinauer | bb01f60 | 2009-07-21 21:20:45 +0000 | [diff] [blame] | 54 | |
Kyösti Mälkki | 4d409b5 | 2013-07-05 21:38:54 +0300 | [diff] [blame] | 55 | #define DBGP_EP_VALID (1<<0) |
| 56 | #define DBGP_EP_ENABLED (1<<1) |
| 57 | #define DBGP_EP_STATMASK (DBGP_EP_VALID | DBGP_EP_ENABLED) |
| 58 | |
Sven Schnelle | 20fc631 | 2011-10-30 09:57:35 +0100 | [diff] [blame] | 59 | void enable_usbdebug(unsigned int port); |
Stefan Reinauer | 7e16bf3 | 2009-04-21 23:05:13 +0000 | [diff] [blame] | 60 | int dbgp_bulk_write_x(struct ehci_debug_info *dbg_info, const char *bytes, int size); |
| 61 | int dbgp_bulk_read_x(struct ehci_debug_info *dbg_info, void *data, int size); |
Stefan Reinauer | 7e16bf3 | 2009-04-21 23:05:13 +0000 | [diff] [blame] | 62 | void set_debug_port(unsigned port); |
Kyösti Mälkki | 4d409b5 | 2013-07-05 21:38:54 +0300 | [diff] [blame] | 63 | |
Kyösti Mälkki | 9e7806a | 2013-07-06 11:56:49 +0300 | [diff] [blame^] | 64 | int usbdebug_init(void); |
| 65 | struct ehci_debug_info *dbgp_ehci_info(void); |
| 66 | #define dbgp_console_output dbgp_ehci_info |
| 67 | #define dbgp_console_input dbgp_ehci_info |
Kyösti Mälkki | 4d409b5 | 2013-07-05 21:38:54 +0300 | [diff] [blame] | 68 | int dbgp_ep_is_active(struct ehci_debug_info *dbg_info); |
Sven Schnelle | 82704c6 | 2012-07-26 14:31:40 +0200 | [diff] [blame] | 69 | void usbdebug_tx_byte(struct ehci_debug_info *info, unsigned char data); |
| 70 | void usbdebug_tx_flush(struct ehci_debug_info *info); |
Sven Schnelle | 20fc631 | 2011-10-30 09:57:35 +0100 | [diff] [blame] | 71 | #endif |