Kyösti Mälkki (kyosti.malkki@gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3476
-gerrit
commit c30ac2924497289eefc189cf190b26cde2f882c9 Author: Kyösti Mälkki kyosti.malkki@gmail.com Date: Sat Jul 6 11:41:21 2013 +0300
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 --- src/include/cbmem.h | 1 + src/lib/cbmem_info.c | 1 + src/lib/usbdebug.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+)
diff --git a/src/include/cbmem.h b/src/include/cbmem.h index efb0f90..f1931a9 100644 --- a/src/include/cbmem.h +++ b/src/include/cbmem.h @@ -70,6 +70,7 @@ #define CBMEM_ID_ROOT 0xff4007ff #define CBMEM_ID_VBOOT_HANDOFF 0x780074f0 #define CBMEM_ID_CAR_GLOBALS 0xcac4e6a3 +#define CBMEM_ID_EHCI_DEBUG 0xe4c1deb9 #define CBMEM_ID_NONE 0x00000000 #define CBMEM_ID_AGESA_RUNTIME 0x41474553
diff --git a/src/lib/cbmem_info.c b/src/lib/cbmem_info.c index 65be67c..a60761f 100644 --- a/src/lib/cbmem_info.c +++ b/src/lib/cbmem_info.c @@ -48,6 +48,7 @@ static struct cbmem_id_to_name { { CBMEM_ID_VBOOT_HANDOFF, "VBOOT " }, { CBMEM_ID_CAR_GLOBALS, "CAR GLOBALS" }, { CBMEM_ID_AGESA_RUNTIME, "AGESA RSVD " }, + { CBMEM_ID_EHCI_DEBUG, "USBDEBUG " }, };
void cbmem_print_entry(int n, u32 id, u64 base, u64 size) diff --git a/src/lib/usbdebug.c b/src/lib/usbdebug.c index dd34a07..6ee942d 100644 --- a/src/lib/usbdebug.c +++ b/src/lib/usbdebug.c @@ -24,6 +24,8 @@ #include <device/pci.h> #include <arch/byteorder.h> #include <cpu/x86/car.h> +#include <cbmem.h> +#include <string.h>
#include <usb_ch9.h> #include <ehci.h> @@ -655,6 +657,47 @@ void pci_ehci_read_resources(struct device *dev)
pci_dev_read_resources(dev); } + +#if CONFIG_CAR_MIGRATION +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; + + info->ehci_caps = dbg_info_cbmem->ehci_caps; + info->ehci_regs = dbg_info_cbmem->ehci_regs; + info->ehci_debug = dbg_info_cbmem->ehci_debug; + info->devnum = dbg_info_cbmem->devnum; + info->endpoint_out = dbg_info_cbmem->endpoint_out; + info->endpoint_in = dbg_info_cbmem->endpoint_in; + info->ehci_info = info; + + printk(BIOS_DEBUG, "EHCI debug port found in CBMEM.\n"); + + return 0; +} +#endif +#endif + +#if CONFIG_CAR_MIGRATION && defined(__PRE_RAM__) +static void migrate_ehci_debug(void) +{ + struct ehci_debug_info *dbg_info; + struct ehci_debug_info *dbg_info_cbmem; + + dbg_info = car_get_var_ptr(&glob_dbg_info); + + 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
struct ehci_debug_info *dbgp_ehci_info(void) @@ -665,6 +708,11 @@ struct ehci_debug_info *dbgp_ehci_info(void) 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(CONFIG_USBDEBUG_DEFAULT_PORT); #endif