Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp241163pxf; Wed, 10 Mar 2021 05:27:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwubzdvpdLZR5imhQM/NKxNVMh+pCPC/pjAbnHxVqnDcoUE5lovTp2wRDZB0/tALZx8RIb+ X-Received: by 2002:a17:907:2b03:: with SMTP id gc3mr3687231ejc.448.1615382858573; Wed, 10 Mar 2021 05:27:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615382858; cv=none; d=google.com; s=arc-20160816; b=w+iaRBd+E07ZvDxNubPYjwEhO1IPx9w/Sa08i4GjElwEG1/ZF68pKty/+CiL6Rbqw7 hoVhw6p9upM5A5aGs76KsknrP8OVAYUradonPXDZEjfHEc6vNTFxQQHcMGymVXXu/k0t sQqb+nHuOnhBRHCBDeOl6RO0/l9Gvew1BzYFU645OUvhfrd86i+AKK7q5OuvcUfAvghk 8eP4nWSqih3siEe7FCYHw1ZUce+yQhZYeEaiycUt/UmxCZoSyzG+FwxwxjeYPmBUk7hE UiaO7518V35b8GrqGKratRiUWOyC7F0a5d6w4tj1zxSu4xpOU89eIXFjKqxWNQsxPNAS RzsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SZO4kMmKLz1ofBeZLXDe2S/y/0S1ByNqNIY12hkW6qg=; b=tMpGytFFIyYZF9DTdzAC+k2GIaKxQlZ4z2Ci0qPq6av1q6TfF9GlUYpBuq2q4Op5R2 tvPj9WhngezfJTDkw+mcnGx2nb3umTizjo9LMRgXKBDDrZsltBcZq+dnfwK437UtBs+z n5VQ88jskUmR+FZ80+8ofzIS6om02q7BpsVK2/eVvrwG/ci/G+IIn9Rf4DuKEd9gB+UZ 7qYn3GPdGtbA5s2VwCK1X3DtCLFxdrrmcGIqqCXZ0Eg9/TZ46wUdAoBar8GHoViBVxkZ Ykd7tgjRPdfHQBRssCAZ76P3VFRbolqYhsGdUB242Z1pICnfSsoDox9xz9NBXulPvuAy aujA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IcO+sUGu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bl4si11964114ejb.47.2021.03.10.05.27.15; Wed, 10 Mar 2021 05:27:38 -0800 (PST) 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=pass header.i=@linuxfoundation.org header.s=korg header.b=IcO+sUGu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233718AbhCJN0c (ORCPT + 99 others); Wed, 10 Mar 2021 08:26:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:46286 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232775AbhCJNYv (ORCPT ); Wed, 10 Mar 2021 08:24:51 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E0A9F64FFD; Wed, 10 Mar 2021 13:24:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615382691; bh=11+RLgFdUOGc+50dYt+7/yBWkDBYllVykRhX9ROYzx8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IcO+sUGuxx5fUr+URqrbUpok9N9YiGqRi/CKxTmMAt2OreyxRrFzqne2D3yCuYy8B 8NVQDuO/eXrg4tyeusmehKP6VbdmKhfkE3k9xhy+94Ivi7E38FIm+oDJIg2RyycuAH JADdsCz0DCrAx5YeM+OlnfMPVdZPNw6s7ey//tLY= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pawel Laszczak , Peter Chen , Sasha Levin Subject: [PATCH 5.10 25/49] usb: cdns3: host: add .suspend_quirk for xhci-plat.c Date: Wed, 10 Mar 2021 14:23:36 +0100 Message-Id: <20210310132322.745082044@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210310132321.948258062@linuxfoundation.org> References: <20210310132321.948258062@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Peter Chen [ Upstream commit ed22764847e8100f0af9af91ccfa58e5c559bd47 ] cdns3 has some special PM sequence between xhci_bus_suspend and xhci_suspend, add quirk to implement it. Reviewed-by: Pawel Laszczak Signed-off-by: Peter Chen Signed-off-by: Sasha Levin --- drivers/usb/cdns3/host-export.h | 6 +++++ drivers/usb/cdns3/host.c | 43 +++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/drivers/usb/cdns3/host-export.h b/drivers/usb/cdns3/host-export.h index ae11810f8826..26041718a086 100644 --- a/drivers/usb/cdns3/host-export.h +++ b/drivers/usb/cdns3/host-export.h @@ -9,9 +9,11 @@ #ifndef __LINUX_CDNS3_HOST_EXPORT #define __LINUX_CDNS3_HOST_EXPORT +struct usb_hcd; #ifdef CONFIG_USB_CDNS3_HOST int cdns3_host_init(struct cdns3 *cdns); +int xhci_cdns3_suspend_quirk(struct usb_hcd *hcd); #else @@ -21,6 +23,10 @@ static inline int cdns3_host_init(struct cdns3 *cdns) } static inline void cdns3_host_exit(struct cdns3 *cdns) { } +static inline int xhci_cdns3_suspend_quirk(struct usb_hcd *hcd) +{ + return 0; +} #endif /* CONFIG_USB_CDNS3_HOST */ diff --git a/drivers/usb/cdns3/host.c b/drivers/usb/cdns3/host.c index b3e2cb69762c..de8da737fa25 100644 --- a/drivers/usb/cdns3/host.c +++ b/drivers/usb/cdns3/host.c @@ -14,6 +14,18 @@ #include "drd.h" #include "host-export.h" #include +#include "../host/xhci.h" +#include "../host/xhci-plat.h" + +#define XECP_PORT_CAP_REG 0x8000 +#define XECP_AUX_CTRL_REG1 0x8120 + +#define CFG_RXDET_P3_EN BIT(15) +#define LPM_2_STB_SWITCH_EN BIT(25) + +static const struct xhci_plat_priv xhci_plat_cdns3_xhci = { + .suspend_quirk = xhci_cdns3_suspend_quirk, +}; static int __cdns3_host_init(struct cdns3 *cdns) { @@ -39,6 +51,11 @@ static int __cdns3_host_init(struct cdns3 *cdns) goto err1; } + ret = platform_device_add_data(xhci, &xhci_plat_cdns3_xhci, + sizeof(struct xhci_plat_priv)); + if (ret) + goto err1; + ret = platform_device_add(xhci); if (ret) { dev_err(cdns->dev, "failed to register xHCI device\n"); @@ -56,6 +73,32 @@ err1: return ret; } +int xhci_cdns3_suspend_quirk(struct usb_hcd *hcd) +{ + struct xhci_hcd *xhci = hcd_to_xhci(hcd); + u32 value; + + if (pm_runtime_status_suspended(hcd->self.controller)) + return 0; + + /* set usbcmd.EU3S */ + value = readl(&xhci->op_regs->command); + value |= CMD_PM_INDEX; + writel(value, &xhci->op_regs->command); + + if (hcd->regs) { + value = readl(hcd->regs + XECP_AUX_CTRL_REG1); + value |= CFG_RXDET_P3_EN; + writel(value, hcd->regs + XECP_AUX_CTRL_REG1); + + value = readl(hcd->regs + XECP_PORT_CAP_REG); + value |= LPM_2_STB_SWITCH_EN; + writel(value, hcd->regs + XECP_PORT_CAP_REG); + } + + return 0; +} + static void cdns3_host_exit(struct cdns3 *cdns) { platform_device_unregister(cdns->host_dev); -- 2.30.1