From: Krishna chaitanya chundru <quic_krichai@quicinc.com>
To: helgaas@kernel.org
Cc: linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, mka@chromium.org,
quic_vbadigan@quicinc.com, quic_hemantk@quicinc.com,
quic_nitegupt@quicinc.com, quic_skananth@quicinc.com,
quic_ramkri@quicinc.com, manivannan.sadhasivam@linaro.org,
swboyd@chromium.org, dmitry.baryshkov@linaro.org,
svarbanov@mm-sol.com, agross@kernel.org, andersson@kernel.org,
konrad.dybcio@somainline.org, lpieralisi@kernel.org,
robh@kernel.org, kw@linux.com, bhelgaas@google.com,
linux-phy@lists.infradead.org, vkoul@kernel.org, kishon@ti.com,
mturquette@baylibre.com, linux-clk@vger.kernel.org,
Krishna chaitanya chundru <quic_krichai@quicinc.com>,
Bjorn Andersson <bjorn.andersson@linaro.org>
Subject: [PATCH v7 4/5] phy: qcom: Add power suspend & resume callbacks to PCIe phy
Date: Tue, 20 Sep 2022 15:52:26 +0530 [thread overview]
Message-ID: <1663669347-29308-5-git-send-email-quic_krichai@quicinc.com> (raw)
In-Reply-To: <1663669347-29308-1-git-send-email-quic_krichai@quicinc.com>
Add phy power suspend & resume callbacks to PCIe phy. Using these
callbacks we can release phy resources like phy specific clocks
but continue maintain PCIe link in l1ss state.
This can help in parking PCIe link in l1ss state during system
suspend (S3).
Instead of this if we add suspend & resume pm ops, phy will suspend
first instead of PCIe driver, it will cause link down as phy will
be down before controller goes down.
Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com>
---
changes since v6:
- Change names from phy_power_down and phy_power_up to
phy_pm_suspend and phy_pm_resume respectively.
---
drivers/pci/controller/dwc/pcie-qcom.c | 4 +--
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 50 ++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c
index 7a6f69e..672a9be 100644
--- a/drivers/pci/controller/dwc/pcie-qcom.c
+++ b/drivers/pci/controller/dwc/pcie-qcom.c
@@ -1326,7 +1326,7 @@ static int qcom_pcie_resume_2_7_0(struct qcom_pcie *pcie)
ret = clk_bulk_prepare_enable(res->num_clks, res->clks);
- phy_power_on(pcie->phy);
+ phy_pm_resume(pcie->phy);
return ret;
}
@@ -1335,7 +1335,7 @@ static int qcom_pcie_suspend_2_7_0(struct qcom_pcie *pcie)
{
struct qcom_pcie_resources_2_7_0 *res = &pcie->res.v2_7_0;
- phy_power_off(pcie->phy);
+ phy_pm_suspend(pcie->phy);
clk_bulk_disable_unprepare(res->num_clks, res->clks);
return 0;
diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c
index 2d65e1f..69220dd 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c
@@ -2145,6 +2145,54 @@ static int qcom_qmp_phy_pcie_exit(struct phy *phy)
return 0;
}
+static int qcom_qmp_phy_pcie_resume(struct phy *phy)
+{
+ struct qmp_phy *qphy = phy_get_drvdata(phy);
+ struct qcom_qmp *qmp = qphy->qmp;
+ const struct qmp_phy_cfg *cfg = qphy->cfg;
+ int ret;
+
+ ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks);
+ if (ret)
+ return ret;
+
+ ret = clk_prepare_enable(qphy->pipe_clk);
+ if (ret)
+ return ret;
+
+ /* Pull out PHY from POWER DOWN state */
+ if (cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL]) {
+ qphy_setbits(qphy->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL],
+ cfg->pwrdn_ctrl);
+ } else {
+ qphy_setbits(qphy->pcs, QPHY_V2_PCS_POWER_DOWN_CONTROL,
+ cfg->pwrdn_ctrl);
+ }
+
+ return 0;
+}
+
+static int qcom_qmp_phy_pcie_suspend(struct phy *phy)
+{
+ struct qmp_phy *qphy = phy_get_drvdata(phy);
+ struct qcom_qmp *qmp = qphy->qmp;
+ const struct qmp_phy_cfg *cfg = qphy->cfg;
+
+ clk_disable_unprepare(qphy->pipe_clk);
+ clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks);
+
+ /* Put PHY into POWER DOWN state: active low */
+ if (cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL]) {
+ qphy_clrbits(qphy->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL],
+ cfg->pwrdn_ctrl);
+ } else {
+ qphy_clrbits(qphy->pcs, QPHY_V2_PCS_POWER_DOWN_CONTROL,
+ cfg->pwrdn_ctrl);
+ }
+
+ return 0;
+}
+
static int qcom_qmp_phy_pcie_enable(struct phy *phy)
{
int ret;
@@ -2304,6 +2352,8 @@ static const struct phy_ops qcom_qmp_phy_pcie_ops = {
.power_on = qcom_qmp_phy_pcie_enable,
.power_off = qcom_qmp_phy_pcie_disable,
.set_mode = qcom_qmp_phy_pcie_set_mode,
+ .suspend = qcom_qmp_phy_pcie_suspend,
+ .resume = qcom_qmp_phy_pcie_resume,
.owner = THIS_MODULE,
};
--
2.7.4
next prev parent reply other threads:[~2022-09-20 10:22 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-20 10:22 [PATCH v7 0/5] PCI: qcom: Add system suspend & resume support Krishna chaitanya chundru
2022-09-20 10:22 ` [PATCH v7 1/5] PCI: qcom: Add system suspend and " Krishna chaitanya chundru
2022-09-20 18:16 ` Bjorn Helgaas
2022-09-21 9:53 ` Krishna Chaitanya Chundru
2022-09-21 16:56 ` Bjorn Helgaas
2022-09-22 15:39 ` Krishna Chaitanya Chundru
2022-09-22 18:42 ` Bjorn Helgaas
2022-09-23 1:59 ` Krishna Chaitanya Chundru
2022-09-23 14:26 ` Bjorn Helgaas
2022-09-25 1:53 ` Krishna Chaitanya Chundru
2022-09-28 14:32 ` Krishna Chaitanya Chundru
2022-09-26 15:30 ` Krishna Chaitanya Chundru
2022-09-29 18:53 ` Bjorn Helgaas
2022-10-03 12:10 ` Krishna Chaitanya Chundru
2022-10-05 21:13 ` Bjorn Helgaas
2022-10-12 14:06 ` Krishna Chaitanya Chundru
2022-10-13 0:44 ` Bjorn Helgaas
2022-09-20 21:58 ` Jeff Johnson
2022-09-20 10:22 ` [PATCH v7 2/5] PCI: qcom: Add retry logic for link to be stable in either L1.1 or L1.2 Krishna chaitanya chundru
2022-09-20 22:00 ` Jeff Johnson
2022-09-24 6:05 ` Vinod Koul
2022-09-25 1:51 ` Krishna Chaitanya Chundru
2022-09-20 10:22 ` [PATCH v7 3/5] phy: core: Add support for phy suspend & resume Krishna chaitanya chundru
2022-09-20 10:22 ` Krishna chaitanya chundru [this message]
2022-09-20 10:22 ` [PATCH v7 5/5] clk: qcom: gcc-sc7280: Update the .pwrsts for PCIe GDSC Krishna chaitanya chundru
2022-09-27 3:23 ` (subset) [PATCH v7 0/5] PCI: qcom: Add system suspend & resume support Bjorn Andersson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1663669347-29308-5-git-send-email-quic_krichai@quicinc.com \
--to=quic_krichai@quicinc.com \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=bhelgaas@google.com \
--cc=bjorn.andersson@linaro.org \
--cc=dmitry.baryshkov@linaro.org \
--cc=helgaas@kernel.org \
--cc=kishon@ti.com \
--cc=konrad.dybcio@somainline.org \
--cc=kw@linux.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=lpieralisi@kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=mka@chromium.org \
--cc=mturquette@baylibre.com \
--cc=quic_hemantk@quicinc.com \
--cc=quic_nitegupt@quicinc.com \
--cc=quic_ramkri@quicinc.com \
--cc=quic_skananth@quicinc.com \
--cc=quic_vbadigan@quicinc.com \
--cc=robh@kernel.org \
--cc=svarbanov@mm-sol.com \
--cc=swboyd@chromium.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).