diff options
author | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2013-07-06 11:41:21 +0300 |
---|---|---|
committer | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2013-09-06 00:36:16 +0200 |
commit | 690bf2f333322e764262e60fd24802205280df5e (patch) | |
tree | 7d9cd7fdb77bb9a5f9fddc59df5f35339caaef8a /src/lib/usbdebug.c | |
parent | e53cece07b14eab1912db3d18d2cb50423d996ec (diff) | |
download | coreboot-690bf2f333322e764262e60fd24802205280df5e.tar.xz |
usbdebug: Use CAR migration
If we already initialized EHCI controller and USB device in romstage,
locate active configuration from salvaged CAR_GLOBAL and avoid doing
the hardware initialisation again.
Change-Id: I7cb3a359488b25abc9de49c96c0197f6563a4a2c
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: http://review.coreboot.org/3476
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@google.com>
Diffstat (limited to 'src/lib/usbdebug.c')
-rw-r--r-- | src/lib/usbdebug.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/lib/usbdebug.c b/src/lib/usbdebug.c index 3dc35f1088..7a8402dfa3 100644 --- a/src/lib/usbdebug.c +++ b/src/lib/usbdebug.c @@ -26,6 +26,7 @@ #include <arch/byteorder.h> #include <cpu/x86/car.h> #include <string.h> +#include <cbmem.h> #include <usb_ch9.h> #include <ehci.h> @@ -868,6 +869,38 @@ void pci_ehci_read_resources(struct device *dev) } #endif +#if CONFIG_CAR_MIGRATION +#if !defined(__PRE_RAM__) && !defined(__SMM__) +static int get_usbdebug_from_cbmem(struct ehci_debug_info *info) +{ + struct ehci_debug_info *dbg_info_cbmem; + + dbg_info_cbmem = cbmem_find(CBMEM_ID_EHCI_DEBUG); + if (dbg_info_cbmem == NULL) + return -1; + + memcpy(info, dbg_info_cbmem, sizeof (*info)); + printk(BIOS_DEBUG, "EHCI debug port found in CBMEM.\n"); + + return 0; +} + +#elif defined(__PRE_RAM__) +static void migrate_ehci_debug(void) +{ + struct ehci_debug_info *dbg_info = dbgp_ehci_info(); + struct ehci_debug_info *dbg_info_cbmem; + + dbg_info_cbmem = cbmem_add(CBMEM_ID_EHCI_DEBUG, sizeof(*dbg_info)); + if (dbg_info_cbmem == NULL) + return; + + memcpy(dbg_info_cbmem, dbg_info, sizeof(*dbg_info)); +} +CAR_MIGRATE(migrate_ehci_debug); +#endif +#endif /* CONFIG_CAR_MIGRATION */ + unsigned long pci_ehci_base_regs(pci_devfn_t sdev) { #ifdef __SIMPLE_DEVICE__ @@ -898,6 +931,10 @@ int usbdebug_init(void) { struct ehci_debug_info *dbg_info = dbgp_ehci_info(); +#if CONFIG_CAR_MIGRATION && !defined(__PRE_RAM__) && !defined(__SMM__) + if (!get_usbdebug_from_cbmem(dbg_info)) + return 0; +#endif #if defined(__PRE_RAM__) || !CONFIG_EARLY_CONSOLE enable_usbdebug(); #endif |