diff options
author | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2013-07-05 21:38:54 +0300 |
---|---|---|
committer | Stefan Reinauer <stefan.reinauer@coreboot.org> | 2013-07-10 23:22:36 +0200 |
commit | 4d409b5fc27e44f7c902f8402f661db56d62ac74 (patch) | |
tree | a8bdcd3bfa898c6fcdf32bc5ff6b4d22627dc1a9 /src/lib/usbdebug.c | |
parent | d686acd1a358518e8f37452c0e826a3ac381cbe2 (diff) |
usbdebug: Refactor disable logic
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 <kyosti.malkki@gmail.com>
Reviewed-on: http://review.coreboot.org/3624
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 | 15 |
1 files changed, 9 insertions, 6 deletions
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); } |