From: Manu Gautam <mgautam@codeaurora.org>
To: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Felipe Balbi <balbi@kernel.org>,
linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org,
Manu Gautam <mgautam@codeaurora.org>,
Vivek Gautam <vivek.gautam@codeaurora.org>,
Varadarajan Narayanan <varada@codeaurora.org>,
Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
Fengguang Wu <fengguang.wu@intel.com>,
Wei Yongjun <weiyongjun1@huawei.com>,
"open list:GENERIC PHY FRAMEWORK" <linux-kernel@vger.kernel.org>
Subject: [PATCH v4 03/16] phy: qcom-qmp: Power-on PHY before initialization
Date: Wed, 3 Jan 2018 16:58:36 +0530 [thread overview]
Message-ID: <1514978930-31341-4-git-send-email-mgautam@codeaurora.org> (raw)
In-Reply-To: <1514978930-31341-1-git-send-email-mgautam@codeaurora.org>
PHY regulators which are enabled from power_on() must be ON
before turning-on clocks and initializing it as part of init().
As most of the core drivers perform power_on() after init(), move
PHY regulators enable to com_init() and use power_on() to
only enable pipe_clk. This pipe_clk is output from PHY and some
core drivers e.g. PCIe follow specific sequence after phy_init()
that mandates pipe_clk to be enabled from power_on() only.
On similar lines move clk_enable from init() to com_init() which
executes once for multi lane PHYs.
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
---
drivers/phy/qualcomm/phy-qcom-qmp.c | 61 +++++++++++++++----------------------
1 file changed, 24 insertions(+), 37 deletions(-)
diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c b/drivers/phy/qualcomm/phy-qcom-qmp.c
index 5fed1ae..1b82cea 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp.c
@@ -724,36 +724,13 @@ static int qcom_qmp_phy_poweron(struct phy *phy)
{
struct qmp_phy *qphy = phy_get_drvdata(phy);
struct qcom_qmp *qmp = qphy->qmp;
- int num = qmp->cfg->num_vregs;
int ret;
- dev_vdbg(&phy->dev, "Powering on QMP phy\n");
-
- /* turn on regulator supplies */
- ret = regulator_bulk_enable(num, qmp->vregs);
- if (ret) {
- dev_err(qmp->dev, "failed to enable regulators, err=%d\n", ret);
- return ret;
- }
-
ret = clk_prepare_enable(qphy->pipe_clk);
- if (ret) {
+ if (ret)
dev_err(qmp->dev, "pipe_clk enable failed, err=%d\n", ret);
- regulator_bulk_disable(num, qmp->vregs);
- return ret;
- }
- return 0;
-}
-
-static int qcom_qmp_phy_poweroff(struct phy *phy)
-{
- struct qmp_phy *qphy = phy_get_drvdata(phy);
- struct qcom_qmp *qmp = qphy->qmp;
-
- regulator_bulk_disable(qmp->cfg->num_vregs, qmp->vregs);
-
- return 0;
+ return ret;
}
static int qcom_qmp_phy_com_init(struct qcom_qmp *qmp)
@@ -768,6 +745,19 @@ static int qcom_qmp_phy_com_init(struct qcom_qmp *qmp)
return 0;
}
+ /* turn on regulator supplies */
+ ret = regulator_bulk_enable(cfg->num_vregs, qmp->vregs);
+ if (ret) {
+ dev_err(qmp->dev, "failed to enable regulators, err=%d\n", ret);
+ goto err_reg_enable;
+ }
+
+ ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks);
+ if (ret) {
+ dev_err(qmp->dev, "failed to enable clks, err=%d\n", ret);
+ goto err_clk_enable;
+ }
+
for (i = 0; i < cfg->num_resets; i++) {
ret = reset_control_deassert(qmp->resets[i]);
if (ret) {
@@ -812,6 +802,10 @@ static int qcom_qmp_phy_com_init(struct qcom_qmp *qmp)
err_rst:
while (--i >= 0)
reset_control_assert(qmp->resets[i]);
+ clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks);
+err_clk_enable:
+ regulator_bulk_disable(cfg->num_vregs, qmp->vregs);
+err_reg_enable:
mutex_unlock(&qmp->phy_mutex);
return ret;
@@ -841,6 +835,10 @@ static int qcom_qmp_phy_com_exit(struct qcom_qmp *qmp)
while (--i >= 0)
reset_control_assert(qmp->resets[i]);
+ clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks);
+
+ regulator_bulk_disable(cfg->num_vregs, qmp->vregs);
+
mutex_unlock(&qmp->phy_mutex);
return 0;
@@ -861,15 +859,9 @@ static int qcom_qmp_phy_init(struct phy *phy)
dev_vdbg(qmp->dev, "Initializing QMP phy\n");
- ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks);
- if (ret) {
- dev_err(qmp->dev, "failed to enable clks, err=%d\n", ret);
- return ret;
- }
-
ret = qcom_qmp_phy_com_init(qmp);
if (ret)
- goto err_com_init;
+ return ret;
if (cfg->has_lane_rst) {
ret = reset_control_deassert(qphy->lane_rst);
@@ -917,8 +909,6 @@ static int qcom_qmp_phy_init(struct phy *phy)
reset_control_assert(qphy->lane_rst);
err_lane_rst:
qcom_qmp_phy_com_exit(qmp);
-err_com_init:
- clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks);
return ret;
}
@@ -945,8 +935,6 @@ static int qcom_qmp_phy_exit(struct phy *phy)
qcom_qmp_phy_com_exit(qmp);
- clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks);
-
return 0;
}
@@ -1060,7 +1048,6 @@ static int phy_pipe_clk_register(struct qcom_qmp *qmp, struct device_node *np)
.init = qcom_qmp_phy_init,
.exit = qcom_qmp_phy_exit,
.power_on = qcom_qmp_phy_poweron,
- .power_off = qcom_qmp_phy_poweroff,
.owner = THIS_MODULE,
};
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2018-01-03 11:28 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-03 11:28 [PATCH v4 00/16] Support for Qualcomm QUSBv2 and QMPv3 USB PHYs Manu Gautam
2018-01-03 11:28 ` [PATCH v4 01/16] phy: qcom-qmp: Fix phy pipe clock gating Manu Gautam
2018-01-03 11:28 ` [PATCH v4 02/16] phy: qcom-qmp: Adapt to clk_bulk_* APIs Manu Gautam
2018-01-03 11:28 ` Manu Gautam [this message]
[not found] ` <1514978930-31341-4-git-send-email-mgautam-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-01-12 8:27 ` [PATCH v4 03/16] phy: qcom-qmp: Power-on PHY before initialization Vivek Gautam
2018-01-03 11:28 ` [PATCH v4 04/16] phy: qcom-qusb2: " Manu Gautam
[not found] ` <1514978930-31341-5-git-send-email-mgautam-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-01-12 8:29 ` Vivek Gautam
2018-01-03 11:28 ` [PATCH v4 05/16] phy: qcom-qmp: Fix PHY block reset sequence Manu Gautam
2018-01-12 8:44 ` Vivek Gautam
2018-01-12 8:46 ` Manu Gautam
2018-01-12 9:12 ` Vivek Gautam
2018-01-03 11:28 ` [PATCH v4 06/16] phy: qcom-qmp: Move SERDES/PCS START after PHY reset Manu Gautam
2018-01-03 11:28 ` [PATCH v4 07/16] phy: qcom-qusb2: Add support for different register layouts Manu Gautam
2018-01-12 9:18 ` Vivek Gautam
2018-01-03 11:28 ` [PATCH v4 08/16] dt-bindings: phy-qcom-qusb2: Update binding for QUSB2 V2 version Manu Gautam
2018-01-03 11:28 ` [PATCH v4 09/16] phy: qcom-qusb2: Add support " Manu Gautam
2018-01-12 9:29 ` Vivek Gautam
2018-01-03 11:28 ` [PATCH v4 10/16] phy: qcom-qmp: Move register offsets to header file Manu Gautam
2018-01-12 6:26 ` Vivek Gautam
2018-01-03 11:28 ` [PATCH v4 11/16] phy: qcom-qmp: Add register offsets for QMP V3 PHY Manu Gautam
2018-01-03 11:28 ` [PATCH v4 12/16] dt-bindings: phy-qcom-qmp: Update bindings for QMP V3 USB PHY Manu Gautam
2018-01-03 11:28 ` [PATCH v4 13/16] phy: qcom-qmp: Add support for QMP V3 USB3 PHY Manu Gautam
2018-01-03 11:28 ` [PATCH v4 14/16] phy: Add USB speed related PHY modes Manu Gautam
2018-01-05 11:01 ` Kishon Vijay Abraham I
2018-01-08 4:46 ` Manu Gautam
2018-01-03 11:28 ` [PATCH v4 15/16] phy: qcom-qusb2: Add support for runtime PM Manu Gautam
2018-01-03 11:28 ` [PATCH v4 16/16] phy: qcom-qmp: " Manu Gautam
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=1514978930-31341-4-git-send-email-mgautam@codeaurora.org \
--to=mgautam@codeaurora.org \
--cc=balbi@kernel.org \
--cc=fengguang.wu@intel.com \
--cc=kishon@ti.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=varada@codeaurora.org \
--cc=vivek.gautam@codeaurora.org \
--cc=weiyongjun1@huawei.com \
--cc=yoshihiro.shimoda.uh@renesas.com \
/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