From 4d409b5fc27e44f7c902f8402f661db56d62ac74 Mon Sep 17 00:00:00 2001 From: Kyösti Mälkki Date: Fri, 5 Jul 2013 21:38:54 +0300 Subject: usbdebug: Refactor disable logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Output to usbdebug console needs to be disabled until hardware is initialized and while EHCI BAR is relocated. Add separate field ehci_info to point to back to EHCI context when hardware is ready to transfer data. Change-Id: If7d441b561819ab8ae23ed9f3f320f7742ed231e Signed-off-by: Kyösti Mälkki Reviewed-on: http://review.coreboot.org/3624 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/lib/usbdebug.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/lib') diff --git a/src/lib/usbdebug.c b/src/lib/usbdebug.c index e425fbf05f..17a02635da 100644 --- a/src/lib/usbdebug.c +++ b/src/lib/usbdebug.c @@ -385,6 +385,7 @@ int usbdebug_init(unsigned ehci_bar, unsigned offset, struct ehci_debug_info *in ehci_debug = (struct ehci_dbg_port *)(ehci_bar + offset); info->ehci_debug = (void *)0; info->bufidx = 0; + info->status = 0; try_next_time: port_map_tried = 0; @@ -547,6 +548,7 @@ try_next_port: info->devnum = devnum; info->endpoint_out = dbgp_endpoint_out; info->endpoint_in = dbgp_endpoint_in; + info->status |= DBGP_EP_ENABLED | DBGP_EP_VALID; return 0; err: @@ -582,35 +584,36 @@ int early_usbdebug_init(void) void usbdebug_tx_byte(struct ehci_debug_info *dbg_info, unsigned char data) { -#if DBGP_DEBUG == 0 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 (dbg_info->ehci_debug) { + if (dbgp_is_ep_active(dbg_info)) { dbg_info->buf[dbg_info->bufidx++] = data; if (dbg_info->bufidx >= 8) { dbgp_bulk_write_x(dbg_info, dbg_info->buf, dbg_info->bufidx); dbg_info->bufidx = 0; } } -#endif } void usbdebug_tx_flush(struct ehci_debug_info *dbg_info) { -#if DBGP_DEBUG == 0 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 (dbg_info->ehci_debug && dbg_info->bufidx > 0) { + 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; } -#endif +} + +int dbgp_ep_is_active(struct ehci_debug_info *dbg_info) +{ + return (dbg_info->status & DBGP_EP_STATMASK) == (DBGP_EP_VALID | DBGP_EP_ENABLED); } -- cgit v1.2.3