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>
This commit is contained in:
Kyösti Mälkki
2013-07-05 21:38:54 +03:00
committed by Stefan Reinauer
parent d686acd1a3
commit 4d409b5fc2
3 changed files with 27 additions and 28 deletions

View File

@@ -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);
}