summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2019-01-02 08:08:56 +0200
committerKyösti Mälkki <kyosti.malkki@gmail.com>2019-01-07 10:37:48 +0000
commit954ed5500c2d8d2284b65689b720ca1530c28b25 (patch)
treec5add68c3f4234aaad80c73f378dbe149f3d1bc6
parent4cc9b6c78d334bdf3f3e27227eb2ce5bba8b4ef5 (diff)
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>
-rw-r--r--src/drivers/usb/ehci_debug.c12
-rw-r--r--src/drivers/usb/ehci_debug.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/src/drivers/usb/ehci_debug.c b/src/drivers/usb/ehci_debug.c
index 4987523f78..6d0339b739 100644
--- a/src/drivers/usb/ehci_debug.c
+++ b/src/drivers/usb/ehci_debug.c
@@ -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;
diff --git a/src/drivers/usb/ehci_debug.h b/src/drivers/usb/ehci_debug.h
index 2a1629df40..efb27666bc 100644
--- a/src/drivers/usb/ehci_debug.h
+++ b/src/drivers/usb/ehci_debug.h
@@ -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