From 954ed5500c2d8d2284b65689b720ca1530c28b25 Mon Sep 17 00:00:00 2001 From: Kyösti Mälkki Date: Wed, 2 Jan 2019 08:08:56 +0200 Subject: usbdebug: Probe for gadget only once MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-on: https://review.coreboot.org/c/30622 Tested-by: build bot (Jenkins) Reviewed-by: Nico Huber --- src/drivers/usb/ehci_debug.c | 12 ++++++++++++ src/drivers/usb/ehci_debug.h | 1 + 2 files changed, 13 insertions(+) (limited to 'src') 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 -- cgit v1.2.3