usbdebug: Probe for gadget only once

The first stage attempting to initialise usbdebug
gadget will leave it marked as non-present if none
is detected. This allows further stages to bypass
usbdebug init sequence.

Change-Id: I1491d7fab3c89f210fb03b32481f697bc7a1d1e6
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/30622
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
Kyösti Mälkki 2019-01-02 08:08:56 +02:00
parent 4cc9b6c78d
commit 954ed5500c
2 changed files with 13 additions and 0 deletions

View File

@ -435,6 +435,7 @@ static int usbdebug_init_(unsigned ehci_bar, unsigned offset, struct ehci_debug_
memset(info, 0, sizeof (*info));
info->ehci_base = (void *)ehci_bar;
info->ehci_debug = (void *)(ehci_bar + offset);
info->ep_pipe[0].status |= DBGP_EP_NOT_PRESENT;
dprintk(BIOS_INFO, "ehci_bar: 0x%x debug_offset 0x%x\n", ehci_bar, offset);
@ -574,6 +575,8 @@ try_next_port:
goto err;
}
info->ep_pipe[0].status &= ~DBGP_EP_NOT_PRESENT;
return 0;
err:
/* Things didn't work so remove my claim */
@ -610,6 +613,12 @@ static int dbgp_enabled(void)
return (globals->status & DBGP_EP_ENABLED);
}
static int dbgp_not_present(void)
{
struct dbgp_pipe *globals = &dbgp_ehci_info()->ep_pipe[DBGP_SETUP_EP0];
return (globals->status & DBGP_EP_NOT_PRESENT);
}
int dbgp_try_get(struct dbgp_pipe *pipe)
{
struct dbgp_pipe *globals = &dbgp_ehci_info()->ep_pipe[DBGP_SETUP_EP0];
@ -661,6 +670,9 @@ int usbdebug_hw_init(bool force)
if (dbgp_enabled() && !force)
return 0;
if (dbgp_not_present() && !force)
return -1;
/* Do not attempt slow gadget init in postcar. */
if (ENV_POSTCAR)
return -1;

View File

@ -31,6 +31,7 @@ void ehci_debug_select_port(unsigned int port);
#define DBGP_EP_VALID (1<<0)
#define DBGP_EP_ENABLED (1<<1)
#define DBGP_EP_BUSY (1<<2)
#define DBGP_EP_NOT_PRESENT (1<<3)
#define DBGP_EP_STATMASK (DBGP_EP_VALID | DBGP_EP_ENABLED)
#define DBGP_MAX_ENDPOINTS 4