From 9e7806a788f9617d3dd9139a74ab3f7b03eb9581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Sat, 6 Jul 2013 11:56:49 +0300 Subject: usbdebug: Move ehci_debug_info allocation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move ehci_debug_info allocation from console to lib, as console code was only built for ramstage. Implement dbgp_ehci_info() to return the EHCI context. Alread alias this as dbgp_console_input() and _output() to return the console stream context later on. Change-Id: Id6cc07d62953f0466df61eeb159e22b0e3287d4e Signed-off-by: Kyösti Mälkki Reviewed-on: http://review.coreboot.org/3625 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin Reviewed-by: Stefan Reinauer --- src/lib/usbdebug.c | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) (limited to 'src/lib') diff --git a/src/lib/usbdebug.c b/src/lib/usbdebug.c index 17a02635da..09306fdb09 100644 --- a/src/lib/usbdebug.c +++ b/src/lib/usbdebug.c @@ -86,6 +86,10 @@ #define DBGP_MAX_PACKET 8 #define DBGP_LOOPS 1000 +#if !defined(__PRE_RAM__) && !defined(__SMM__) +static struct ehci_debug_info glob_dbg_info; +#endif + static int dbgp_wait_until_complete(struct ehci_dbg_port *ehci_debug) { u32 ctrl; @@ -361,8 +365,7 @@ static int ehci_wait_for_port(struct ehci_regs *ehci_regs, int port) return -1; //-ENOTCONN; } - -int usbdebug_init(unsigned ehci_bar, unsigned offset, struct ehci_debug_info *info) +static int usbdebug_init_(unsigned ehci_bar, unsigned offset, struct ehci_debug_info *info) { struct ehci_caps *ehci_caps; struct ehci_regs *ehci_regs; @@ -574,22 +577,8 @@ next_debug_port: return -10; } -int early_usbdebug_init(void) -{ - struct ehci_debug_info *dbg_info = (struct ehci_debug_info *) - (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE - sizeof(struct ehci_debug_info)); - - return usbdebug_init(CONFIG_EHCI_BAR, CONFIG_EHCI_DEBUG_OFFSET, dbg_info); -} - void usbdebug_tx_byte(struct ehci_debug_info *dbg_info, unsigned char data) { - if (!dbg_info) { - /* "Find" dbg_info structure in Cache */ - dbg_info = (struct ehci_debug_info *) - (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE - sizeof(struct ehci_debug_info)); - } - if (dbgp_is_ep_active(dbg_info)) { dbg_info->buf[dbg_info->bufidx++] = data; if (dbg_info->bufidx >= 8) { @@ -601,12 +590,6 @@ void usbdebug_tx_byte(struct ehci_debug_info *dbg_info, unsigned char data) void usbdebug_tx_flush(struct ehci_debug_info *dbg_info) { - if (!dbg_info) { - /* "Find" dbg_info structure in Cache */ - dbg_info = (struct ehci_debug_info *) - (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE - sizeof(struct ehci_debug_info)); - } - if (dbgp_is_ep_active(dbg_info) && dbg_info->bufidx > 0) { dbgp_bulk_write_x(dbg_info, dbg_info->buf, dbg_info->bufidx); dbg_info->bufidx = 0; @@ -617,3 +600,23 @@ int dbgp_ep_is_active(struct ehci_debug_info *dbg_info) { return (dbg_info->status & DBGP_EP_STATMASK) == (DBGP_EP_VALID | DBGP_EP_ENABLED); } + +struct ehci_debug_info *dbgp_ehci_info(void) +{ +#if __PRE_RAM__ + /* "Find" dbg_info structure in Cache */ + return (struct ehci_debug_info *) + (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE - sizeof(struct ehci_debug_info)); +#else + return &glob_dbg_info; +#endif +} + +int usbdebug_init(void) +{ + struct ehci_debug_info *dbg_info = dbgp_ehci_info(); +#if defined(__PRE_RAM__) || !CONFIG_EARLY_CONSOLE + enable_usbdebug(CONFIG_USBDEBUG_DEFAULT_PORT); +#endif + return usbdebug_init_(CONFIG_EHCI_BAR, CONFIG_EHCI_DEBUG_OFFSET, dbg_info); +} -- cgit v1.2.3