Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp290054pxb; Thu, 19 Nov 2020 00:56:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJz4PXvbL2ybtI/wKGcSRBEmqQkL7iJ9Mk3+uNrFaVBhCkBtqhs2jweFj7FvMqSap3O0S1lT X-Received: by 2002:a17:906:4bcb:: with SMTP id x11mr26794826ejv.538.1605776185643; Thu, 19 Nov 2020 00:56:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605776185; cv=none; d=google.com; s=arc-20160816; b=jpHcwOGra2GNUbmMTOmbVZNissrGVAY29K/rdorD+MAC1ipH1AyGbUFbm4TIpAtIbL 9I7P4MhpB0tDBr4070+srYNgmFHPIQJuF/e0prjHrsndNdeLIwNwt/V3b1kF7JSbtVqq cDNb5iFZWQOiFUVS3aLTYvPu4rkuNfEWrJxUmfOY63uSUU0GVqrjeHxTlhT8Y+pMQq/O goFqugRPWItgHTCEFa06e/jg4/80ljTz+m4UNUDBYuRVjptvrJJnlYfcDoRVcKpqZXo2 eBu2eym2aPZE+91PJeTZa4ylueQFL9g6s1vyxQdYZHzvfLAczD+ntmBCCRhag/A4jhrq HB6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=vXYf3LWZ8w8CPnSFOE8KIMYF91wXcqkyWF5qCBY7XG8=; b=fRQ8wBDU8p4G5YopLgh9B50uW29pRdjm/ntXRzRKlezP1f0+VVwyDYR9bDpAgAN9tK 49796dwcGzFx3e9M8nqFmNGCqnFtYKs9f4xUo6kEo2cAhwZVIvGTnQZ9JMnY6i/2hRJu 7wQj+ATtsCxhS1ZJ8wxb21OCJ4nlNNx+adNLE+DWXN8Caxz2/CGqPIneP/RVDfzeXT7j V08tCHaVXXIyxAvFgGnJRQc65cuGPOnWbjPyoI/t71ONdvaoxujwWqYQLdfaXbezEzNN xE8HoDEIPVmLa2ycVdIUO9cJFNgLaySiKyEYEWjsv5oz/BOQEehRpNTP8ZuexIeQ+Ece WPXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=drEwzvje; 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=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b20si17827215edv.300.2020.11.19.00.56.02; Thu, 19 Nov 2020 00:56:25 -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=@nvidia.com header.s=n1 header.b=drEwzvje; 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=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726775AbgKSIya (ORCPT + 99 others); Thu, 19 Nov 2020 03:54:30 -0500 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:13017 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726616AbgKSIy3 (ORCPT ); Thu, 19 Nov 2020 03:54:29 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Thu, 19 Nov 2020 00:54:39 -0800 Received: from HQMAIL101.nvidia.com (172.20.187.10) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 19 Nov 2020 08:54:24 +0000 Received: from jckuo-lt.nvidia.com (10.124.1.5) by mail.nvidia.com (172.20.187.10) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Thu, 19 Nov 2020 08:54:23 +0000 From: JC Kuo To: , , , , CC: , , , , , JC Kuo Subject: [PATCH v5 07/16] phy: tegra: xusb: Add sleepwalk and suspend/resume Date: Thu, 19 Nov 2020 16:53:56 +0800 Message-ID: <20201119085405.556138-8-jckuo@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201119085405.556138-1-jckuo@nvidia.com> References: <20201119085405.556138-1-jckuo@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1605776079; bh=vXYf3LWZ8w8CPnSFOE8KIMYF91wXcqkyWF5qCBY7XG8=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:X-NVConfidentiality: Content-Transfer-Encoding:Content-Type; b=drEwzvjemDRMTxZ0bEnWUQihLeYeYeCigeELQvy5O7A+5yPwvxEY+Hm57T2t+Ld+X Br/CaMuBPHWZCwHrsXg6csnh26mQeiHvbXWz3yK0mXkO79ZDs8J+HHxXvabVyGyctC Sq3rH1SRFdUmDnXYtGkxRVD+mwAB36wfC1r0hK371qlZE7YKuhbGTQDx1VXNNHsdl/ pbXCQ/+tvAKR4kFTQy+JkbKy+XXA3FAYW7ZzawsmP/SILLFtGOVL/vEBTvMw5R1g0v evZkCvyBhbMjRyrcrMP2bt8iz0FYd98GeetU9cwhofCIUP9JbfpczbLemtR7/NFdl/ VfKsS0d2AUuIg== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This commit adds sleepwalk/wake and suspend/resume interfaces to Tegra XUSB PHY driver. Tegra XUSB host controller driver makes use of sleepwalk functions to enable/disable sleepwalk circuit which is in always-on partition and can respond to USB resume signals when controller is not powered. Sleepwalk can be enabled/disabled for any USB UPHY individually. - tegra_xusb_padctl_enable_phy_sleepwalk() - tegra_xusb_padctl_disable_phy_sleepwalk() Tegra XUSB host controller driver makes use of wake functions to enable/disable/query wake circuit which is in always-on partition can wake system up when USB resume happens. Wake circuit can be enabled/disabled for any USB PHY individually. - tegra_xusb_padctl_enable_phy_wake() - tegra_xusb_padctl_disable_phy_wake() - tegra_xusb_padctl_remote_wake_detected() This commit also adds two system suspend stubs that can be used to save and restore XUSB PADCTL context during system suspend and resume. - tegra_xusb_padctl_suspend_noirq() - tegra_xusb_padctl_resume_noirq() Signed-off-by: JC Kuo --- v5: no change v4: move sleepwalk/wake stubs from 'struct tegra_xusb_padctl_ops' to 'struct tegra_xusb_lane_ops' v3: commit message improvement, no change in code drivers/phy/tegra/xusb.c | 82 ++++++++++++++++++++++++++++++++++ drivers/phy/tegra/xusb.h | 8 ++++ include/linux/phy/tegra/xusb.h | 10 ++++- 3 files changed, 99 insertions(+), 1 deletion(-) diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c index e81ac7a088e9..0fdee9ab64da 100644 --- a/drivers/phy/tegra/xusb.c +++ b/drivers/phy/tegra/xusb.c @@ -1275,10 +1275,36 @@ static int tegra_xusb_padctl_remove(struct platform= _device *pdev) return err; } =20 +static int tegra_xusb_padctl_suspend_noirq(struct device *dev) +{ + struct tegra_xusb_padctl *padctl =3D dev_get_drvdata(dev); + + if (padctl->soc && padctl->soc->ops && padctl->soc->ops->suspend_noirq) + return padctl->soc->ops->suspend_noirq(padctl); + + return 0; +} + +static int tegra_xusb_padctl_resume_noirq(struct device *dev) +{ + struct tegra_xusb_padctl *padctl =3D dev_get_drvdata(dev); + + if (padctl->soc && padctl->soc->ops && padctl->soc->ops->resume_noirq) + return padctl->soc->ops->resume_noirq(padctl); + + return 0; +} + +static const struct dev_pm_ops tegra_xusb_padctl_pm_ops =3D { + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(tegra_xusb_padctl_suspend_noirq, + tegra_xusb_padctl_resume_noirq) +}; + static struct platform_driver tegra_xusb_padctl_driver =3D { .driver =3D { .name =3D "tegra-xusb-padctl", .of_match_table =3D tegra_xusb_padctl_of_match, + .pm =3D &tegra_xusb_padctl_pm_ops, }, .probe =3D tegra_xusb_padctl_probe, .remove =3D tegra_xusb_padctl_remove, @@ -1345,6 +1371,62 @@ int tegra_xusb_padctl_hsic_set_idle(struct tegra_xus= b_padctl *padctl, } EXPORT_SYMBOL_GPL(tegra_xusb_padctl_hsic_set_idle); =20 +int tegra_xusb_padctl_enable_phy_sleepwalk(struct tegra_xusb_padctl *padct= l, struct phy *phy, + enum usb_device_speed speed) +{ + struct tegra_xusb_lane *lane =3D phy_get_drvdata(phy); + + if (lane->pad->ops->enable_phy_sleepwalk) + return lane->pad->ops->enable_phy_sleepwalk(lane, speed); + + return -EOPNOTSUPP; +} +EXPORT_SYMBOL_GPL(tegra_xusb_padctl_enable_phy_sleepwalk); + +int tegra_xusb_padctl_disable_phy_sleepwalk(struct tegra_xusb_padctl *padc= tl, struct phy *phy) +{ + struct tegra_xusb_lane *lane =3D phy_get_drvdata(phy); + + if (lane->pad->ops->disable_phy_sleepwalk) + return lane->pad->ops->disable_phy_sleepwalk(lane); + + return -EOPNOTSUPP; +} +EXPORT_SYMBOL_GPL(tegra_xusb_padctl_disable_phy_sleepwalk); + +int tegra_xusb_padctl_enable_phy_wake(struct tegra_xusb_padctl *padctl, st= ruct phy *phy) +{ + struct tegra_xusb_lane *lane =3D phy_get_drvdata(phy); + + if (lane->pad->ops->enable_phy_wake) + return lane->pad->ops->enable_phy_wake(lane); + + return -EOPNOTSUPP; +} +EXPORT_SYMBOL_GPL(tegra_xusb_padctl_enable_phy_wake); + +int tegra_xusb_padctl_disable_phy_wake(struct tegra_xusb_padctl *padctl, s= truct phy *phy) +{ + struct tegra_xusb_lane *lane =3D phy_get_drvdata(phy); + + if (lane->pad->ops->disable_phy_wake) + return lane->pad->ops->disable_phy_wake(lane); + + return -EOPNOTSUPP; +} +EXPORT_SYMBOL_GPL(tegra_xusb_padctl_disable_phy_wake); + +bool tegra_xusb_padctl_remote_wake_detected(struct tegra_xusb_padctl *padc= tl, struct phy *phy) +{ + struct tegra_xusb_lane *lane =3D phy_get_drvdata(phy); + + if (lane->pad->ops->remote_wake_detected) + return lane->pad->ops->remote_wake_detected(lane); + + return false; +} +EXPORT_SYMBOL_GPL(tegra_xusb_padctl_remote_wake_detected); + int tegra_xusb_padctl_usb3_set_lfps_detect(struct tegra_xusb_padctl *padct= l, unsigned int port, bool enable) { diff --git a/drivers/phy/tegra/xusb.h b/drivers/phy/tegra/xusb.h index e789d5ff4eb8..034f7a2c28d6 100644 --- a/drivers/phy/tegra/xusb.h +++ b/drivers/phy/tegra/xusb.h @@ -11,6 +11,7 @@ #include #include =20 +#include #include #include =20 @@ -132,6 +133,11 @@ struct tegra_xusb_lane_ops { void (*remove)(struct tegra_xusb_lane *lane); void (*iddq_enable)(struct tegra_xusb_lane *lane); void (*iddq_disable)(struct tegra_xusb_lane *lane); + int (*enable_phy_sleepwalk)(struct tegra_xusb_lane *lane, enum usb_device= _speed speed); + int (*disable_phy_sleepwalk)(struct tegra_xusb_lane *lane); + int (*enable_phy_wake)(struct tegra_xusb_lane *lane); + int (*disable_phy_wake)(struct tegra_xusb_lane *lane); + bool (*remote_wake_detected)(struct tegra_xusb_lane *lane); }; =20 bool tegra_xusb_lane_check(struct tegra_xusb_lane *lane, const char *funct= ion); @@ -396,6 +402,8 @@ struct tegra_xusb_padctl_ops { const struct tegra_xusb_padctl_soc *soc); void (*remove)(struct tegra_xusb_padctl *padctl); =20 + int (*suspend_noirq)(struct tegra_xusb_padctl *padctl); + int (*resume_noirq)(struct tegra_xusb_padctl *padctl); int (*usb3_save_context)(struct tegra_xusb_padctl *padctl, unsigned int index); int (*hsic_set_idle)(struct tegra_xusb_padctl *padctl, diff --git a/include/linux/phy/tegra/xusb.h b/include/linux/phy/tegra/xusb.= h index 71d956935405..3a35e74cdc61 100644 --- a/include/linux/phy/tegra/xusb.h +++ b/include/linux/phy/tegra/xusb.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2016-2020, NVIDIA CORPORATION. All rights reserved. */ =20 #ifndef PHY_TEGRA_XUSB_H @@ -8,6 +8,7 @@ =20 struct tegra_xusb_padctl; struct device; +enum usb_device_speed; =20 struct tegra_xusb_padctl *tegra_xusb_padctl_get(struct device *dev); void tegra_xusb_padctl_put(struct tegra_xusb_padctl *padctl); @@ -23,4 +24,11 @@ int tegra_xusb_padctl_set_vbus_override(struct tegra_xus= b_padctl *padctl, int tegra_phy_xusb_utmi_port_reset(struct phy *phy); int tegra_xusb_padctl_get_usb3_companion(struct tegra_xusb_padctl *padctl, unsigned int port); +int tegra_xusb_padctl_enable_phy_sleepwalk(struct tegra_xusb_padctl *padct= l, struct phy *phy, + enum usb_device_speed speed); +int tegra_xusb_padctl_disable_phy_sleepwalk(struct tegra_xusb_padctl *padc= tl, struct phy *phy); +int tegra_xusb_padctl_enable_phy_wake(struct tegra_xusb_padctl *padctl, st= ruct phy *phy); +int tegra_xusb_padctl_disable_phy_wake(struct tegra_xusb_padctl *padctl, s= truct phy *phy); +bool tegra_xusb_padctl_remote_wake_detected(struct tegra_xusb_padctl *padc= tl, struct phy *phy); + #endif /* PHY_TEGRA_XUSB_H */ --=20 2.25.1