From patchwork Wed Sep 18 00:29:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julius Werner X-Patchwork-Id: 275572 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 49D712C00D3 for ; Wed, 18 Sep 2013 10:56:35 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1D5C44A130; Wed, 18 Sep 2013 02:56:33 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5nNSmKISVryQ; Wed, 18 Sep 2013 02:56:32 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 969204A120; Wed, 18 Sep 2013 02:56:28 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 065034A120 for ; Wed, 18 Sep 2013 02:56:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eaC-4632ieR0 for ; Wed, 18 Sep 2013 02:56:18 +0200 (CEST) X-Greylist: delayed 1419 seconds by postgrey-1.27 at theia; Wed, 18 Sep 2013 02:56:11 CEST X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pb0-f44.google.com (mail-pb0-f44.google.com [209.85.160.44]) by theia.denx.de (Postfix) with ESMTPS id 374004A11F for ; Wed, 18 Sep 2013 02:56:11 +0200 (CEST) Received: by mail-pb0-f44.google.com with SMTP id xa7so6321082pbc.3 for ; Tue, 17 Sep 2013 17:56:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=f/+Ql9hEVTnxf9SAi2SsxEMmBHlCFLQOLqzLRhnrOWI=; b=C32ifk/PUSH/vrLv89YAwBGCDbb9V+VTJOVqT52VnOrvTwLwW+11JApJxSxHVpV4pr EpHHgIcv+SWEpEFHPWLVv7ytipTagk9woKE8BxohorLJI5d7Muk0hi/CHgx3XMVWKlcf nKaz2veMFI09E576zY8azxZSMZEqgPaRo3g0M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=f/+Ql9hEVTnxf9SAi2SsxEMmBHlCFLQOLqzLRhnrOWI=; b=VIEeS7ADc0BP+suy389bsvbPcAOw+iT4gsQhqHRLarRyua65s/u86r/JQGFW/eiqcj CmiXkAf9Bq9c9NEYVi2ykpwWdoEZXc/koCv1cucsWHx06Pf+qzzgOSEv6xNyaLIs++6u ajW/LTvnvOo1ERJ2FCvAFAiAuyVF1t+B1aTciLlhuHKneamaLqU2Pw6c3fGsKHcHi4I3 1yDwLg/s1W6L1uDup7JSRY01JLNRsatlrYPnkqIpHKC65RD6jGsGAlD3rMcrXcwxEvkE yk/zXer/nGi11HxFYQKie1hheQck9WyVwQo9ggzQUEUsBrHfXorVoNSelaDoVnkK7la/ ZXMA== X-Gm-Message-State: ALoCoQkTXVmTZzdZCgxhwq5iC57d6Ovbo9L0IhWrvoNIOtmwRh1OQU0ken/q/ETqqSm5seVLpLiV X-Received: by 10.68.219.194 with SMTP id pq2mr21389505pbc.52.1379464349528; Tue, 17 Sep 2013 17:32:29 -0700 (PDT) Received: from jwerner-linux.mtv.corp.google.com (jwerner-linux.mtv.corp.google.com [172.22.72.75]) by mx.google.com with ESMTPSA id hx1sm41146677pbb.35.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 17 Sep 2013 17:32:28 -0700 (PDT) From: Julius Werner To: Marek Vasut Date: Tue, 17 Sep 2013 17:29:15 -0700 Message-Id: <1379464155-13250-1-git-send-email-jwerner@chromium.org> X-Mailer: git-send-email 1.8.4 Cc: U-Boot Mailing List , Vincent Palatin , u-boot-review@google.com, Julius Werner Subject: [U-Boot] [PATCH] usb: ehci: Fix test mode for connected ports X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de The EHCI controller has some very specific requirements for the USB 2.0 port test modes, which were not closely followed in the initial test mode commit. It demands that the host controller is completely shut down (all ports suspended, Run/Stop bit unset) when activating test mode, and will not work on an already enumerated port. This patch fixes that by introducing a new ehci_shutdown() function that closely follows the procedure listed in EHCI 4.14. Also, when we have such a function anyway, we might as well also use it in usb_lowlevel_stop() to make the normal host controller shutdown cleaner. Signed-off-by: Julius Werner --- drivers/usb/host/ehci-hcd.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index fdad739..3143021 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -190,6 +190,35 @@ out: return ret; } +static int ehci_shutdown(struct ehci_ctrl *ctrl) +{ + int i, ret = 0; + uint32_t cmd, reg; + + cmd = ehci_readl(&ctrl->hcor->or_usbcmd); + cmd &= ~(CMD_PSE | CMD_ASE); + ehci_writel(&ctrl->hcor->or_usbcmd, cmd); + ret = handshake(&ctrl->hcor->or_usbsts, STS_ASS | STS_PSS, 0, 8 * 1000); + + if (!ret) { + for (i = 0; i < CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS; i++) { + reg = ehci_readl(&ctrl->hcor->or_portsc[i]); + reg |= EHCI_PS_SUSP; + ehci_writel(&ctrl->hcor->or_portsc[i], reg); + } + + cmd &= ~CMD_RUN; + ehci_writel(&ctrl->hcor->or_usbcmd, cmd); + ret = handshake(&ctrl->hcor->or_usbsts, STS_HALT, STS_HALT, + 8 * 1000); + } + + if (ret) + printf("EHCI failed to shut down host controller.\n"); + + return ret; +} + static int ehci_td_buffer(struct qTD *td, void *buf, size_t sz) { uint32_t delta, next; @@ -808,6 +837,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer, } break; case USB_PORT_FEAT_TEST: + ehci_shutdown(ctrl); reg &= ~(0xf << 16); reg |= ((le16_to_cpu(req->index) >> 8) & 0xf) << 16; ehci_writel(status_reg, reg); @@ -878,6 +908,7 @@ unknown: int usb_lowlevel_stop(int index) { + ehci_shutdown(&ehcic[index]); return ehci_hcd_stop(index); }