Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp689602pxx; Wed, 28 Oct 2020 14:35:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmQMnd2poxhJ2mIMwxT85ohUYNRsp3SZVQtBayU0FyufwBo7WbQHzkvriIevqoiKawzsW3 X-Received: by 2002:a17:906:6dc6:: with SMTP id j6mr1145839ejt.354.1603920941284; Wed, 28 Oct 2020 14:35:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603920941; cv=none; d=google.com; s=arc-20160816; b=uxXyY2efL92F/TGCWSCiKlq/vwWbS4Vmdkc4sroaXClSoIkevBVGae85hICL7eeXHN A7hNgCFnig7P45o+v6qOPiGeKn/62P8pF84draHtvbwNRL1zexs/6hV8qtFo6IcfdD+d QwvWLgNd5W4yfD6nXMG9rF/1TG61R/5IAQOD0NYSB63p6FgBDj8tdhqP5vnTUvYB4np/ 1RoEmIVrr+dqXsh+Eo20WGAFc2rri50wXv5aQVDtfGU4o+l50pF5zBekW447sBKXinUh MeEqu2mtq1WLfSUsmukuWDqrHHOTge4oZH9RzrdD83j6TNajUdw5ZGi66xKByXv6EClq ygqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=al2ldZFPHvBbx3vs2aqumXP63X2i/EnIFyvaigal5hA=; b=HUJq49aHybhGz6yeADOZJ+6wsElCDmlHcsUMRQv04AYP73zxfSgJE2OZSJkqm/z7Av /vp/BZrr4S/Gy8/4PywSnR8/7iAEHsxY8zyiD8fKWeC22Idy/IpQVVeqaoeBjXjCjI7Y ySx1eEecsQcOQPNjkSCPsFyAiCW/xqK4V7fcPEPGGsiu0nwIWG9LICvjrkMsNUg5Cm9A teencYB4THW+agXC/C67U88KdvTumSwl4PGUcqZBWti1tEnN1JbDGfQBnEZShhPa5lN2 G+G6RXdD5cm4quLoevcmJ2Prbudq+uggcZXJ3Ol66y9S8srAgfZxIrBdeBCfdb94fZfE 3N4g== ARC-Authentication-Results: i=1; mx.google.com; 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 d4si609514edo.178.2020.10.28.14.35.17; Wed, 28 Oct 2020 14:35:41 -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; 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 S1831838AbgJ0UjA (ORCPT + 99 others); Tue, 27 Oct 2020 16:39:00 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:43794 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1831808AbgJ0Uit (ORCPT ); Tue, 27 Oct 2020 16:38:49 -0400 Received: from ironmsg-lv-alpha.qualcomm.com ([10.47.202.13]) by alexa-out.qualcomm.com with ESMTP; 27 Oct 2020 13:38:48 -0700 X-QCInternal: smtphost Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by ironmsg-lv-alpha.qualcomm.com with ESMTP/TLS/AES256-SHA; 27 Oct 2020 13:38:46 -0700 X-QCInternal: smtphost Received: from c-sanm-linux.qualcomm.com ([10.206.25.31]) by ironmsg02-blr.qualcomm.com with ESMTP; 28 Oct 2020 02:08:19 +0530 Received: by c-sanm-linux.qualcomm.com (Postfix, from userid 2343233) id 34DA92EC8; Wed, 28 Oct 2020 02:08:19 +0530 (IST) From: Sandeep Maheswaram To: Andy Gross , Bjorn Andersson , Greg Kroah-Hartman , Rob Herring , Mark Rutland , Felipe Balbi , Stephen Boyd , Doug Anderson , Matthias Kaehlcke Cc: linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Manu Gautam , Sandeep Maheswaram Subject: [PATCH v4 3/5] usb: dwc3: qcom: Configure wakeup interrupts and set genpd active wakeup flag Date: Wed, 28 Oct 2020 02:08:01 +0530 Message-Id: <1603831083-2025-4-git-send-email-sanm@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1603831083-2025-1-git-send-email-sanm@codeaurora.org> References: <1603831083-2025-1-git-send-email-sanm@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Configure interrupts based on hs_phy_mode to avoid triggering of interrupts during system suspend and suspends successfully. Set genpd active wakeup flag for usb gdsc if wakeup capable devices are connected so that wake up happens without reenumeration. Add helper functions to enable,disable wake irqs. Signed-off-by: Sandeep Maheswaram --- drivers/usb/dwc3/dwc3-qcom.c | 82 ++++++++++++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 30 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c index c703d55..c93f7bb 100644 --- a/drivers/usb/dwc3/dwc3-qcom.c +++ b/drivers/usb/dwc3/dwc3-qcom.c @@ -17,9 +17,11 @@ #include #include #include +#include #include #include #include +#include #include "core.h" @@ -291,60 +293,75 @@ static void dwc3_qcom_interconnect_exit(struct dwc3_qcom *qcom) icc_put(qcom->icc_path_apps); } -static void dwc3_qcom_disable_interrupts(struct dwc3_qcom *qcom) +static void dwc3_qcom_enable_wakeup_irq(int wake_irq) { - if (qcom->hs_phy_irq) { - disable_irq_wake(qcom->hs_phy_irq); - disable_irq_nosync(qcom->hs_phy_irq); + if (wake_irq) { + enable_irq(wake_irq); + enable_irq_wake(wake_irq); } +} - if (qcom->dp_hs_phy_irq) { - disable_irq_wake(qcom->dp_hs_phy_irq); - disable_irq_nosync(qcom->dp_hs_phy_irq); +static void dwc3_qcom_disable_wakeup_irq(int wake_irq) +{ + if (wake_irq) { + disable_irq_wake(wake_irq); + disable_irq_nosync(wake_irq); } +} - if (qcom->dm_hs_phy_irq) { - disable_irq_wake(qcom->dm_hs_phy_irq); - disable_irq_nosync(qcom->dm_hs_phy_irq); - } +static void dwc3_qcom_disable_interrupts(struct dwc3_qcom *qcom) +{ + struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3); + + dwc3_qcom_disable_wakeup_irq(qcom->hs_phy_irq); - if (qcom->ss_phy_irq) { - disable_irq_wake(qcom->ss_phy_irq); - disable_irq_nosync(qcom->ss_phy_irq); + if (dwc->hs_phy_mode & PHY_MODE_USB_HOST_LS) + dwc3_qcom_disable_wakeup_irq(qcom->dp_hs_phy_irq); + else if (dwc->hs_phy_mode & PHY_MODE_USB_HOST_HS) + dwc3_qcom_disable_wakeup_irq(qcom->dm_hs_phy_irq); + else { + dwc3_qcom_disable_wakeup_irq(qcom->dp_hs_phy_irq); + dwc3_qcom_disable_wakeup_irq(qcom->dm_hs_phy_irq); } + + dwc3_qcom_disable_wakeup_irq(qcom->ss_phy_irq); } static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom) { - if (qcom->hs_phy_irq) { - enable_irq(qcom->hs_phy_irq); - enable_irq_wake(qcom->hs_phy_irq); - } + struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3); - if (qcom->dp_hs_phy_irq) { - enable_irq(qcom->dp_hs_phy_irq); - enable_irq_wake(qcom->dp_hs_phy_irq); - } + dwc3_qcom_enable_wakeup_irq(qcom->hs_phy_irq); - if (qcom->dm_hs_phy_irq) { - enable_irq(qcom->dm_hs_phy_irq); - enable_irq_wake(qcom->dm_hs_phy_irq); + if (dwc->hs_phy_mode & PHY_MODE_USB_HOST_LS) + dwc3_qcom_enable_wakeup_irq(qcom->dp_hs_phy_irq); + else if (dwc->hs_phy_mode & PHY_MODE_USB_HOST_HS) + dwc3_qcom_enable_wakeup_irq(qcom->dm_hs_phy_irq); + else { + dwc3_qcom_enable_wakeup_irq(qcom->dp_hs_phy_irq); + dwc3_qcom_enable_wakeup_irq(qcom->dm_hs_phy_irq); } - if (qcom->ss_phy_irq) { - enable_irq(qcom->ss_phy_irq); - enable_irq_wake(qcom->ss_phy_irq); - } + dwc3_qcom_enable_wakeup_irq(qcom->ss_phy_irq); } static int dwc3_qcom_suspend(struct dwc3_qcom *qcom) { u32 val; int i, ret; + struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3); + struct usb_hcd *hcd; + struct generic_pm_domain *genpd = pd_to_genpd(qcom->dev->pm_domain); if (qcom->is_suspended) return 0; + if (dwc->xhci) { + hcd = platform_get_drvdata(dwc->xhci); + if (usb_wakeup_enabled_descendants(hcd->self.root_hub)) + genpd->flags |= GENPD_FLAG_ACTIVE_WAKEUP; + } + val = readl(qcom->qscratch_base + PWR_EVNT_IRQ_STAT_REG); if (!(val & PWR_EVNT_LPM_IN_L2_MASK)) dev_err(qcom->dev, "HS-PHY not in L2\n"); @@ -366,10 +383,15 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom) { int ret; int i; + struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3); + struct generic_pm_domain *genpd = pd_to_genpd(qcom->dev->pm_domain); if (!qcom->is_suspended) return 0; + if (dwc->xhci) + genpd->flags &= ~GENPD_FLAG_ACTIVE_WAKEUP; + dwc3_qcom_disable_interrupts(qcom); for (i = 0; i < qcom->num_clocks; i++) { @@ -764,7 +786,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev) if (ret) goto interconnect_exit; - device_init_wakeup(&pdev->dev, 1); + device_init_wakeup(&pdev->dev, of_property_read_bool(np, "wakeup-source")); qcom->is_suspended = false; pm_runtime_set_active(dev); pm_runtime_enable(dev); -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation