diff options
Diffstat (limited to 'src/drivers/usb/pci_ehci.c')
-rw-r--r-- | src/drivers/usb/pci_ehci.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/drivers/usb/pci_ehci.c b/src/drivers/usb/pci_ehci.c index 7c715f67bd..c7e8afb06f 100644 --- a/src/drivers/usb/pci_ehci.c +++ b/src/drivers/usb/pci_ehci.c @@ -34,12 +34,30 @@ static struct device_operations *ehci_drv_ops; static struct device_operations ehci_dbg_ops; #endif -void ehci_debug_hw_enable(void) +int ehci_debug_hw_enable(unsigned int *base, unsigned int *dbg_offset) { -#if defined(__PRE_RAM__) || !CONFIG_USBDEBUG_IN_ROMSTAGE pci_devfn_t dbg_dev = pci_ehci_dbg_dev(CONFIG_USBDEBUG_HCD_INDEX); pci_ehci_dbg_enable(dbg_dev, CONFIG_EHCI_BAR); +#ifdef __SIMPLE_DEVICE__ + pci_devfn_t dev = dbg_dev; +#else + device_t dev = dev_find_slot(PCI_DEV2SEGBUS(dbg_dev), PCI_DEV2DEVFN(dbg_dev)); #endif + + u8 pos = pci_find_capability(dev, PCI_CAP_ID_EHCI_DEBUG); + if (!pos) + return -1; + + u32 cap = pci_read_config32(dev, pos); + + /* FIXME: We should remove static EHCI_BAR_INDEX. */ + u8 dbg_bar = 0x10 + 4 * ((cap >> 29) - 1); + if (dbg_bar != EHCI_BAR_INDEX) + return -1; + + *base = CONFIG_EHCI_BAR; + *dbg_offset = (cap>>16) & 0x1ffc; + return 0; } void ehci_debug_select_port(unsigned int port) |