Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp250233pxa; Tue, 11 Aug 2020 01:52:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7uY1OJe4tR4wuYyBtZwyLwuBYOBn1S4rTLp1jq+KfpHiZFYkk4BB7qN7MSRmwScrC2cD4 X-Received: by 2002:a17:906:819:: with SMTP id e25mr26577602ejd.95.1597135935948; Tue, 11 Aug 2020 01:52:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597135935; cv=none; d=google.com; s=arc-20160816; b=RMxSBFrm/GJLN5vCkl4lMWXhmLmHfV2S5NmdYbFlDkNj4KNDEe4LFS9Uky7KUBlvAI zKYkES592kwEx8kwww1iALSo6LSK7Q/Xm7CIXoWEl2rsGPYU8M20QlJJet2N04RAx7Mn DRPLvTzuIaBpNlcjQsobNyVwJnHVJWm70eCMhn/1mxTGg4eavdth0SK5PWIoy+Npzfgz xhc4cp2qiwHviJsefpEpzZgHBljrPVoyslAm1u5ADALp1im7Rhki8sjZFgHMYJyWjDLm Oh7XPEapaficMNrzXMOPjhxgwXUo9eSnB0gaJvvk0Iy08MNDi5ARQtWBVzQRnWUrVmq9 oNEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature; bh=7WwnnDLcpDYR0mzRDFxxHd6DBQPVie18LRrLzCaS3S4=; b=llNr0XHmflEWw4tciP8NMD0WcnKlUlvhhViXsBwvmnees9OQDrO7N93bAd4egrzEqr 87R5se05X+Dpm8WpL3YxmiKoM+sqOq/F1keVZMotlpaY8iiJGsDEGtU0vO2vNvK8YF8A pkYf0KM42RnfGNPBL7ckbzJ3x58Y5gHSUxoGGDoh63jcGIdbeY+Wdlj25HZe3j69o0OD XFt9KMbVeIqT1mQl1YpiNlvUiTjxAt/tl4FRVa9PC6Nkt3g+UTC0w0iS1o8rsT4qYjBA sStVXGIJvLOmpbHb4ztyx+65yBp5J/oe6MIvFHCZs1t0uWMoWTCbGkQ9ArD54zecO/mm zmaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=DK3XNnjc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 17si12561794ejw.686.2020.08.11.01.51.53; Tue, 11 Aug 2020 01:52:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=DK3XNnjc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728426AbgHKIvT (ORCPT + 99 others); Tue, 11 Aug 2020 04:51:19 -0400 Received: from mail29.static.mailgun.info ([104.130.122.29]:42875 "EHLO mail29.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728325AbgHKIvS (ORCPT ); Tue, 11 Aug 2020 04:51:18 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1597135877; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=7WwnnDLcpDYR0mzRDFxxHd6DBQPVie18LRrLzCaS3S4=; b=DK3XNnjceqLItRAB/N2p+op4lzPc4nkaNpNhLfFPZIVkgOtwzZS/YotTTEJhA3vAWz06oJCb 8z5yAvs9rK1++tQvqwOwPAe7VLwoVIqq8y9WdwlbWQLsSZwx9fFM3o5rZyO8yshicl/Bb2BR TL4otMxAIP3fKz/rkJ3ir0yLewo= X-Mailgun-Sending-Ip: 104.130.122.29 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n12.prod.us-east-1.postgun.com with SMTP id 5f325bf82b87d66049f524f7 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 11 Aug 2020 08:51:04 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 125CAC433A1; Tue, 11 Aug 2020 08:51:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,NICE_REPLY_A, SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from [10.131.194.49] (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgautam) by smtp.codeaurora.org (Postfix) with ESMTPSA id 22AE7C433C9; Tue, 11 Aug 2020 08:50:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 22AE7C433C9 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=mgautam@codeaurora.org Subject: Re: [PATCH 2/2] usb: dwc3: Host wake up support from system suspend To: Sandeep Maheswaram , Andy Gross , Bjorn Andersson , Greg Kroah-Hartman , Rob Herring , Mark Rutland , Felipe Balbi , Stephen Boyd , Doug Anderson , Matthias Kaehlcke , Michael Turquette Cc: linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Taniya Das References: <1591885683-29514-1-git-send-email-sanm@codeaurora.org> <1591885683-29514-3-git-send-email-sanm@codeaurora.org> From: Manu Gautam Message-ID: <7e2e94c8-e06b-1ecc-4304-008fcce1fe30@codeaurora.org> Date: Tue, 11 Aug 2020 14:20:55 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <1591885683-29514-3-git-send-email-sanm@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 6/11/2020 7:58 PM, Sandeep Maheswaram wrote: > Avoiding phy powerdown in host mode so that it can be wake up by devices. > Set usb controller wakeup capable when wakeup capable devices are > connected to the host. > > Signed-off-by: Sandeep Maheswaram > --- > drivers/usb/dwc3/core.c | 47 ++++++++++++++++++++++++++----- > drivers/usb/dwc3/core.h | 1 + > drivers/usb/dwc3/dwc3-qcom.c | 66 +++++++++++++++++++++++++++++++++----------- > 3 files changed, 91 insertions(+), 23 deletions(-) > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > index 25c686a7..8370350 100644 > --- a/drivers/usb/dwc3/core.c > +++ b/drivers/usb/dwc3/core.c > @@ -31,15 +31,19 @@ > #include > #include > #include > +#include > > #include "core.h" > #include "gadget.h" > #include "io.h" > > #include "debug.h" > +#include "../host/xhci.h" > > #define DWC3_DEFAULT_AUTOSUSPEND_DELAY 5000 /* ms */ > > +bool need_phy_for_wakeup; > + > /** > * dwc3_get_dr_mode - Validates and sets dr_mode > * @dwc: pointer to our context structure > @@ -1627,10 +1631,36 @@ static int dwc3_core_init_for_resume(struct dwc3 *dwc) > return ret; > } > > +static void dwc3_set_phy_speed_flags(struct dwc3 *dwc) > +{ > + > + int i, num_ports; > + u32 reg; > + struct usb_hcd *hcd = platform_get_drvdata(dwc->xhci); dwc->xhci could be NULL for DR_MODE = PERIPHERAL. > + struct xhci_hcd *xhci_hcd = hcd_to_xhci(hcd); > + > + dwc->hs_phy_flags &= ~(PHY_MODE_USB_HOST_HS | PHY_MODE_USB_HOST_LS); > + > + reg = readl(&xhci_hcd->cap_regs->hcs_params1); > + > + num_ports = HCS_MAX_PORTS(reg); > + for (i = 0; i < num_ports; i++) { > + reg = readl(&xhci_hcd->op_regs->port_status_base + i*0x10); > + if (reg & PORT_PE) { > + if (DEV_HIGHSPEED(reg) || DEV_FULLSPEED(reg)) > + dwc->hs_phy_flags |= PHY_MODE_USB_HOST_HS; > + else if (DEV_LOWSPEED(reg)) > + dwc->hs_phy_flags |= PHY_MODE_USB_HOST_LS; > + } > + } > + phy_set_mode(dwc->usb2_generic_phy, dwc->hs_phy_flags); Can we move this logic to xhci driver instead? > +} > + .. > @@ -240,6 +267,11 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom) > { > u32 val; > int i; > + struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3); > + struct usb_hcd *hcd = platform_get_drvdata(dwc->xhci); dwc->xhci could be NULL > + > + if (usb_wakeup_enabled_descendants(hcd->self.root_hub)) > + device_init_wakeup(qcom->dev, 1); > > if (qcom->is_suspended) > return 0; > @@ -262,6 +294,8 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom) > int ret; > int i; > > + device_init_wakeup(qcom->dev, 0); > + > if (!qcom->is_suspended) > return 0; > -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project