usbdebug: Drop duplicates of EHCI BAR relocation code

All the additional work that needs to be done in EHCI BAR relocation
is independent of the hardware platform and was functionally identical
in all the copies removed.

When USBDEBUG is not selected, PCI EHCI controllers use standard
pci_dev_read_resources() call.

With USBDEBUG selected, PCI EHCI controller's device_operations
.read_resources is replaced with pci_ehci_read_resources() call,
which in turn will replace the device_operations .set_resources call.
The replacement for .set_resources reconfigures usbdebug driver side,
and calls the original .set_resources to configure hardware side.

Change-Id: I8e136a5da4efedf60b6dd7068c0488153efaaf8e
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: http://review.coreboot.org/3412
Reviewed-by: Aaron Durbin <adurbin@google.com>
Tested-by: build bot (Jenkins)
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
This commit is contained in:
Kyösti Mälkki
2013-06-07 22:16:52 +03:00
committed by Aaron Durbin
parent 0d8d482f63
commit fb387dfb92
16 changed files with 92 additions and 355 deletions

View File

@ -21,9 +21,12 @@
#include <string.h>
#include <console/console.h>
#include <usbdebug.h>
#include <device/pci.h>
#include <pc80/mc146818rtc.h>
static struct ehci_debug_info dbg_info;
static struct device_operations *ehci_drv_ops;
static struct device_operations ehci_dbg_ops;
void set_ehci_base(unsigned ehci_base)
{
@ -48,6 +51,43 @@ unsigned get_ehci_debug(void)
return (unsigned)dbg_info.ehci_debug;
}
static void pci_ehci_set_resources(struct device *dev)
{
struct resource *res;
u32 base;
u32 usb_debug;
printk(BIOS_DEBUG, "%s EHCI Debug Port hook triggered\n", dev_path(dev));
usb_debug = get_ehci_debug();
set_ehci_debug(0);
if (ehci_drv_ops->set_resources)
ehci_drv_ops->set_resources(dev);
res = find_resource(dev, EHCI_BAR_INDEX);
set_ehci_debug(usb_debug);
if (!res) return;
base = res->base;
set_ehci_base(base);
report_resource_stored(dev, res, "");
printk(BIOS_DEBUG, "%s EHCI Debug Port relocated\n", dev_path(dev));
}
void pci_ehci_read_resources(struct device *dev)
{
if (!ehci_drv_ops) {
memcpy(&ehci_dbg_ops, dev->ops, sizeof(ehci_dbg_ops));
ehci_drv_ops = dev->ops;
ehci_dbg_ops.set_resources = pci_ehci_set_resources;
dev->ops = &ehci_dbg_ops;
printk(BIOS_DEBUG, "%s EHCI BAR hook registered\n", dev_path(dev));
} else {
printk(BIOS_DEBUG, "More than one caller of %s from %s\n", __func__, dev_path(dev));
}
pci_dev_read_resources(dev);
}
static void dbgp_init(void)
{
#if !CONFIG_EARLY_CONSOLE