Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3461812pxv; Mon, 28 Jun 2021 05:11:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6WQ8fndMUh9M7FycfcyNqi61dc1pxF1HblOU0wVxHn01uhQwLJOqloAOKFk6zJbazl7wd X-Received: by 2002:a05:600c:2248:: with SMTP id a8mr5272237wmm.188.1624882285285; Mon, 28 Jun 2021 05:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624882285; cv=none; d=google.com; s=arc-20160816; b=PzGOS9cu4vcQ/DJ/m9PtjLNlC8jd6JHWLBXAwNUBU/C3Uc6Nmp9kofOYEiJUx1yFKe E43wU8SidhD8WKZCoKEpMglztLxssRj24nvlf3Lo3GAQ1rfjsm3czqQL4qezNBzzZSPn p0fQH36n5ATKJ0KyCaxsas/viZJUVnftftWnwdNEqhYV+pPZL5yswJVyupyLuRJOZbVB aBgjDqDFXQhqL638MaQ3+T7wMw9SAl4VX8KDeAZ7exhYdmA+7R6FycVBz2h1lxktZQ1O IDG/FYLy44moLrU3JtAc2RJvi6PP4IWuwcE1fErFfaM9xrlFX5FkwKyHDOLk6UXFvoZH eCig== 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=pNxaIPUk13CT8Cb2cqOA+or07EkO84yBMVpHA3Y8YvI=; b=WFd0YqbEggi+TAJc9F9t9je7OH5H9yt75ZlwMMQrXbuz8Q5Zrp3KRGawje5ZnqefkI AX0xqNCTAo1jb3E64Iu8RMwg9rTv0jVO0ZkBxcPzrupLJq+3LceOjoYUDIs5PtgmfVDs DyR0zUUKjQxCLf0r++POguC67ZIORUFJOM2vLgTntLsPFV5rpH5S5kGJd4vZTV8enDR9 sNpfNZHHGo3KdsV3bcaIFHJN+wWYT8K3e3btoANxNlEM72Bx0V03ngJGPsCs8uzwgx9E 93cgEICIMfBcDzGGa8Dze2OJuiYv4bRcwFRiVrj3vIOE373BCNjFROURyDA0W6ubKv0y /rBg== 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 nb19si3358068ejc.331.2021.06.28.05.11.00; Mon, 28 Jun 2021 05:11:25 -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 S233026AbhF1MLq (ORCPT + 99 others); Mon, 28 Jun 2021 08:11:46 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:1218 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232957AbhF1ML0 (ORCPT ); Mon, 28 Jun 2021 08:11:26 -0400 Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 28 Jun 2021 05:09:01 -0700 X-QCInternal: smtphost Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/AES256-SHA; 28 Jun 2021 05:08:59 -0700 X-QCInternal: smtphost Received: from c-sanm-linux.qualcomm.com ([10.206.25.31]) by ironmsg02-blr.qualcomm.com with ESMTP; 28 Jun 2021 17:38:27 +0530 Received: by c-sanm-linux.qualcomm.com (Postfix, from userid 2343233) id 503273A48; Mon, 28 Jun 2021 17:38:26 +0530 (IST) From: Sandeep Maheswaram To: Andy Gross , Bjorn Andersson , Greg Kroah-Hartman , Felipe Balbi , Stephen Boyd , Doug Anderson , Matthias Kaehlcke , Mathias Nyman Cc: linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Pratham Pratap , Sandeep Maheswaram Subject: [PATCH v8 2/6] usb: host: xhci: plat: Add suspend quirk for dwc3 controller Date: Mon, 28 Jun 2021 17:38:13 +0530 Message-Id: <1624882097-23265-3-git-send-email-sanm@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1624882097-23265-1-git-send-email-sanm@codeaurora.org> References: <1624882097-23265-1-git-send-email-sanm@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org During suspend read the status of all port and make sure the PHYs are in the correct mode based on current speed. Phy interrupt masks are set based on this mode. Keep track of the mode of the HS PHY to be able to configure wakeup properly. Also check during suspend if any wakeup capable devices are connected to the controller (directly or through hubs), if there are none set a flag to indicate that the PHY should be powered down during suspend. Signed-off-by: Sandeep Maheswaram --- drivers/usb/host/xhci-plat.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index c1edcc9..ee87923 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -24,6 +24,7 @@ #include "xhci-plat.h" #include "xhci-mvebu.h" #include "xhci-rcar.h" +#include "../dwc3/core.h" static struct hc_driver __read_mostly xhci_plat_hc_driver; @@ -430,6 +431,39 @@ static int xhci_plat_remove(struct platform_device *dev) return 0; } +static void xhci_dwc3_suspend_quirk(struct usb_hcd *hcd) +{ + int i, num_ports; + u32 reg; + unsigned int ss_phy_mode = 0; + struct dwc3 *dwc = dev_get_drvdata(hcd->self.controller->parent); + struct xhci_hcd *xhci_hcd = hcd_to_xhci(hcd); + + dwc->hs_phy_mode = 0; + + 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 * 0x04); + if (reg & PORT_PE) { + if (DEV_HIGHSPEED(reg) || DEV_FULLSPEED(reg)) + dwc->hs_phy_mode |= PHY_MODE_USB_HOST_HS; + else if (DEV_LOWSPEED(reg)) + dwc->hs_phy_mode |= PHY_MODE_USB_HOST_LS; + + if (DEV_SUPERSPEED(reg)) + ss_phy_mode |= PHY_MODE_USB_HOST_SS; + } + } + phy_set_mode(dwc->usb2_generic_phy, dwc->hs_phy_mode); + phy_set_mode(dwc->usb3_generic_phy, ss_phy_mode); + + if (usb_wakeup_enabled_descendants(hcd->self.root_hub)) + dwc->phy_power_off = false; + else + dwc->phy_power_off = true; +} static int __maybe_unused xhci_plat_suspend(struct device *dev) { @@ -440,6 +474,10 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev) ret = xhci_priv_suspend_quirk(hcd); if (ret) return ret; + + if (of_device_is_compatible(dev->parent->of_node, "snps,dwc3")) + xhci_dwc3_suspend_quirk(hcd); + /* * xhci_suspend() needs `do_wakeup` to know whether host is allowed * to do wakeup during suspend. -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation