From patchwork Tue Feb 25 19:40:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 25315 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f71.google.com (mail-qa0-f71.google.com [209.85.216.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 580942066E for ; Tue, 25 Feb 2014 19:42:34 +0000 (UTC) Received: by mail-qa0-f71.google.com with SMTP id j7sf1464321qaq.10 for ; Tue, 25 Feb 2014 11:42:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=HC5C5FjkLVsBmDKYTCQ73bvUTf/xordOeitCNCPwr5Q=; b=KJWZJuQ+k8JWu9GznPBZ69EnT4tq4ky/gMZniKoFqWPaGxD7q1OQkrlCweMkVAUiI0 jgPlQD2reis0K7zqIez+gBhcxaqU7YDNGb4UY7DzDoGJKQ/yQ7PRcAx+eya0LBzNrR+J IcM2K/raVQU8jDRsxlGp2qbye1kdiaEx15I5WcbMLRRH9E4rOMWHE/VKLSBVZA0ZRf2i TetCWpaOmbOr2h/L3422tqOssW3llBX2q7436vWRx2JFQkzPlqf6YmCAwI5AEPfmWIpy 5VmpL9ert0vfkPIZ8il6F5Ir7zZZ1BejeLl8kcLKalcRgN1RYUjZeV3yVjbVnRFLWua3 qOHA== X-Gm-Message-State: ALoCoQkhhlCMjn8o1MNw903ksHJsFY6VgIsh6BN6mAZnsZoQmo4sRbAvXzHL6qgk2FV4gEiaOtZE X-Received: by 10.236.4.136 with SMTP id 8mr520248yhj.21.1393357354182; Tue, 25 Feb 2014 11:42:34 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.51.130 with SMTP id u2ls2656005qga.34.gmail; Tue, 25 Feb 2014 11:42:34 -0800 (PST) X-Received: by 10.52.179.198 with SMTP id di6mr2027290vdc.7.1393357354026; Tue, 25 Feb 2014 11:42:34 -0800 (PST) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id kl10si7078254vdb.25.2014.02.25.11.42.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Feb 2014 11:42:34 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id id10so7736925vcb.41 for ; Tue, 25 Feb 2014 11:42:33 -0800 (PST) X-Received: by 10.52.27.9 with SMTP id p9mr2031397vdg.28.1393357353947; Tue, 25 Feb 2014 11:42:33 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp163129vcz; Tue, 25 Feb 2014 11:42:33 -0800 (PST) X-Received: by 10.68.143.72 with SMTP id sc8mr1540870pbb.101.1393357353154; Tue, 25 Feb 2014 11:42:33 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hh1si21502140pac.13.2014.02.25.11.42.32; Tue, 25 Feb 2014 11:42:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753463AbaBYTmb (ORCPT + 3 others); Tue, 25 Feb 2014 14:42:31 -0500 Received: from comal.ext.ti.com ([198.47.26.152]:34507 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753472AbaBYTmR (ORCPT ); Tue, 25 Feb 2014 14:42:17 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s1PJgHSw013329 for ; Tue, 25 Feb 2014 13:42:17 -0600 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s1PJgHDJ005526 for ; Tue, 25 Feb 2014 13:42:17 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Tue, 25 Feb 2014 13:42:16 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s1PJgG9X004259; Tue, 25 Feb 2014 13:42:16 -0600 From: Felipe Balbi To: Linux USB Mailing List CC: Felipe Balbi Subject: [PATCH 09/11] usb: dwc3: gadget: set KEEP_CONNECT in case of hibernation Date: Tue, 25 Feb 2014 13:40:41 -0600 Message-ID: <1393357243-2958-10-git-send-email-balbi@ti.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1393357243-2958-1-git-send-email-balbi@ti.com> References: <1393357243-2958-1-git-send-email-balbi@ti.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: balbi@ti.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , if we have hibernation configured, Databook instructs us to set KEEP_CONNECT bit together with RUN_STOP bit, in step 9 of section 12.3.6.1 Initialization for Hibernation Support. Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/gadget.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index e9f2cbc..3eee96a 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1429,7 +1429,7 @@ static int dwc3_gadget_set_selfpowered(struct usb_gadget *g, return 0; } -static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on) +static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend) { u32 reg; u32 timeout = 500; @@ -1444,9 +1444,17 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on) if (dwc->revision >= DWC3_REVISION_194A) reg &= ~DWC3_DCTL_KEEP_CONNECT; reg |= DWC3_DCTL_RUN_STOP; + + if (dwc->has_hibernation) + reg |= DWC3_DCTL_KEEP_CONNECT; + dwc->pullups_connected = true; } else { reg &= ~DWC3_DCTL_RUN_STOP; + + if (dwc->has_hibernation && !suspend) + reg &= ~DWC3_DCTL_KEEP_CONNECT; + dwc->pullups_connected = false; } @@ -1484,7 +1492,7 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) is_on = !!is_on; spin_lock_irqsave(&dwc->lock, flags); - ret = dwc3_gadget_run_stop(dwc, is_on); + ret = dwc3_gadget_run_stop(dwc, is_on, false); spin_unlock_irqrestore(&dwc->lock, flags); return ret; @@ -2726,8 +2734,10 @@ void dwc3_gadget_exit(struct dwc3 *dwc) int dwc3_gadget_prepare(struct dwc3 *dwc) { - if (dwc->pullups_connected) + if (dwc->pullups_connected) { dwc3_gadget_disable_irq(dwc); + dwc3_gadget_run_stop(dwc, true, true); + } return 0; } @@ -2736,7 +2746,7 @@ void dwc3_gadget_complete(struct dwc3 *dwc) { if (dwc->pullups_connected) { dwc3_gadget_enable_irq(dwc); - dwc3_gadget_run_stop(dwc, true); + dwc3_gadget_run_stop(dwc, true, false); } }