* [PATCH v4 0/8] phy: qcom-ufs: Enable regulators to be off in suspend
@ 2019-02-13 23:25 Evan Green
2019-02-13 23:25 ` [PATCH v4 1/8] dt-bindings: ufs: Add #reset-cells for Qualcomm controllers Evan Green
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Evan Green @ 2019-02-13 23:25 UTC (permalink / raw)
To: Andy Gross, Kishon Vijay Abraham I
Cc: Stephen Boyd, Marc Gonzalez, Can Guo, Vivek Gautam,
Douglas Anderson, Asutosh Das, Evan Green, Bjorn Andersson,
Arnd Bergmann, Grygorii Strashko, Rob Herring, Vinayak Holikatti,
Jeffrey Hugo, linux-scsi, David Brown, James E.J. Bottomley,
devicetree, liwei, linux-arm-msm, Martin K. Petersen
The goal with this series is to enable shutting off regulators that power
UFS during system suspend.
In "the good life" version of this, we'd just disable the regulators
in phy_poweroff() and be done with it. Unfortunately, that's not symmetric,
as regulators are not enabled during phy_poweron(). Ok, so you might think
we could just move the regulator enable and anything else that needs to
come along into phy_poweron(), so that we can then undo it all in
phy_poweroff(). That's where things get tricky.
The qcom-qmp-phy overloaded the phy_init() and phy_poweron() callbacks,
basically to mean "init phase 1" and "init phase 2". There are two phases
because they have this phy_reset bit outside of the phy (in the UFS
controller registers), and they need to make sure this bit is toggled at
specific points in the phy init sequence. So there's this implicit
sequence in the init dance between ufs-qcom.c and phy-qcom-qmp.c:
1) ufs-qcom asserts the PHY reset bit.
2) phy-qcom-qmp phy_init() does most of its initialization, but exits early.
3) ufs-qcom deasserts the PHY reset bit.
4) phy-qcom-qmp phy_poweron() finishes its initialization.
This init dance is very difficult to follow in the code (since it's split
between two drivers and not spelled out well), and arguably represents a
deficiency in the hardware description of these devices.
In this series I'm proposing tweaking the bindings for the Qualcomm
UFS controller and PHY. In it we expose a reset controller from the
UFS controller, that is then picked up and used from the PHY code.
With this, the phy code can be reorganized to complete its initialization
in a single function, removing the implicit two-phase overloading.
Then I can move most of the phy initialization, including enabling
the regulators, into phy_poweron(). Now, when phy_poweroff() is called,
the phy actually powers off. This finally disables the regulators
and allows me to save power in system suspend.
Because the UFS PHY reset bit is now toggled in the PHY, rather
than in ufs-qcom, this also percolated to all other PHYs using
ufs-qcom, which from what I can see is just 8996.
I removed the calls to phy_poweroff() during clock gating. This
was originally dialing down a clock or two, while leaving the phy powered.
I've now changed the semantics of phy_poweroff() to, well, actually power off.
This works great for userlands that have set UFS's spm_lvl to 5 (off) like
I have, but maybe changes power consumption for devices that have spm_lvl
set to 3. I could try to use phy_init() and phy_poweron() as the two
different possible transitions (fully off, and clocks off respectively),
but I'm not sure if it actually matters, and I like the idea that
phy_poweroff() really does power the thing off.
Also, I don't have an 8996 device to test. If someone is able to test this
out and perhaps point out any (hopefully obvious) bugs in the 8996 portion,
I'd be grateful.
This patch is based atop phy-next, plus the UFS DT nodes, which are now
patch 3, 4, 5 of [1].
[1] https://lore.kernel.org/lkml/20181210192826.241350-1-evgreen@chromium.org/
Changes in v4:
- Do reset_control_* unconditionally since null is handled (Stephen).
- Keep doing reset_control* unconditionally through refactor (Stephen).
Changes in v3:
- Refactor to only expose the reset controller in one change (Stephen).
- Add period to comment (Stephen).
- Reset err to 0 in ignored error case (Stephen).
- Add include of reset-controller.h (Stephen)
- Refactored to move reset control in a single commit (Stephen)
- Use no_pcs_sw_reset as an indicator of UFS reset in qmp-phy (Stephen).
- Assign ret = PTR_ERR() earlier, for better reuse (Stephen).
- Refactor init => poweron for all PHYs and UFS in one step (Stephen)
Changes in v2:
- Added resets to example (Stephen).
- Remove include of reset.h (Stephen)
- Fix error print of phy_power_on (Stephen)
- Comment for reset controller warnings on id != 0 (Stephen)
- Add static to ufs_qcom_reset_ops (Stephen).
- Use devm_* to get the reset (Stephen)
- Clear ufs_reset on error getting it
- Remove needless error print (Stephen)
- Use devm_ to get the reset (Stephen)
- Removed whitespace changes (Stephen)
Evan Green (8):
dt-bindings: ufs: Add #reset-cells for Qualcomm controllers
dt-bindings: phy-qcom-qmp: Add UFS PHY reset
dt-bindings: phy: qcom-ufs: Add resets property
arm64: dts: sdm845: Add UFS PHY reset
arm64: dts: msm8996: Add UFS PHY reset controller
scsi: ufs: qcom: Expose the reset controller for PHY
phy: qcom: Utilize UFS reset controller
phy: ufs-qcom: Refactor all init steps into phy_poweron
.../devicetree/bindings/phy/qcom-qmp-phy.txt | 6 +-
.../devicetree/bindings/ufs/ufs-qcom.txt | 5 +-
.../devicetree/bindings/ufs/ufshcd-pltfrm.txt | 3 +
arch/arm64/boot/dts/qcom/msm8996.dtsi | 4 +-
arch/arm64/boot/dts/qcom/sdm845.dtsi | 3 +
drivers/phy/qualcomm/phy-qcom-qmp.c | 112 +++++++++--------
drivers/phy/qualcomm/phy-qcom-ufs-i.h | 5 +-
drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c | 25 +---
drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c | 25 +---
drivers/phy/qualcomm/phy-qcom-ufs.c | 57 ++++++---
drivers/scsi/ufs/Kconfig | 1 +
drivers/scsi/ufs/ufs-qcom.c | 114 +++++++++++-------
drivers/scsi/ufs/ufs-qcom.h | 4 +
13 files changed, 193 insertions(+), 171 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v4 1/8] dt-bindings: ufs: Add #reset-cells for Qualcomm controllers
2019-02-13 23:25 [PATCH v4 0/8] phy: qcom-ufs: Enable regulators to be off in suspend Evan Green
@ 2019-02-13 23:25 ` Evan Green
2019-02-13 23:25 ` [PATCH v4 2/8] dt-bindings: phy-qcom-qmp: Add UFS PHY reset Evan Green
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Evan Green @ 2019-02-13 23:25 UTC (permalink / raw)
To: Andy Gross, Kishon Vijay Abraham I
Cc: Stephen Boyd, Marc Gonzalez, Can Guo, Vivek Gautam,
Douglas Anderson, Asutosh Das, Evan Green, Rob Herring,
devicetree, liwei, linux-kernel, Subhash Jadavani, Rob Herring,
Martin K. Petersen, Mark Rutland
Enable Qualcomm UFS controllers to expose the PHY reset via a reset
controller.
Signed-off-by: Evan Green <evgreen@chromium.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
index 8cf59452c675..e2460b666ae4 100644
--- a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
+++ b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
@@ -47,6 +47,8 @@ Optional properties:
-lanes-per-direction : number of lanes available per direction - either 1 or 2.
Note that it is assume same number of lanes is used both
directions at once. If not specified, default is 2 lanes per direction.
+- #reset-cells : Must be <1> for Qualcomm UFS controllers that expose
+ PHY reset from the UFS controller.
- resets : reset node register
- reset-names : describe reset node register, the "rst" corresponds to reset the whole UFS IP.
@@ -76,4 +78,5 @@ Example:
reset-names = "rst";
phys = <&ufsphy1>;
phy-names = "ufsphy";
+ #reset-cells = <1>;
};
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 2/8] dt-bindings: phy-qcom-qmp: Add UFS PHY reset
2019-02-13 23:25 [PATCH v4 0/8] phy: qcom-ufs: Enable regulators to be off in suspend Evan Green
2019-02-13 23:25 ` [PATCH v4 1/8] dt-bindings: ufs: Add #reset-cells for Qualcomm controllers Evan Green
@ 2019-02-13 23:25 ` Evan Green
2019-02-13 23:25 ` [PATCH v4 3/8] dt-bindings: phy: qcom-ufs: Add resets property Evan Green
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Evan Green @ 2019-02-13 23:25 UTC (permalink / raw)
To: Andy Gross, Kishon Vijay Abraham I
Cc: Stephen Boyd, Marc Gonzalez, Can Guo, Vivek Gautam,
Douglas Anderson, Asutosh Das, Evan Green, Rob Herring,
devicetree, Mark Rutland, Rob Herring, linux-kernel
Add a required reset to the SDM845 UFS phy to express the PHY reset
bit inside the UFS controller register space. Before this change, this
reset was not expressed in the DT, and the driver utilized two different
callbacks (phy_init and phy_poweron) to implement a two-phase
initialization procedure that involved deasserting this reset between
init and poweron. This abused the two callbacks and diluted their
purpose.
That scheme does not work as regulators cannot be turned off in
phy_poweroff because they were turned on in init, rather than poweron.
The net result is that regulators are left on in suspend that shouldn't
be.
This new scheme gives the UFS reset to the PHY, so that it can fully
initialize itself in a single callback. We can then turn regulators on
during poweron and off during poweroff.
Signed-off-by: Evan Green <evgreen@chromium.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
---
I realize I'm not supposed to add a required property after the fact,
but given that the UFS DT nodes that would use this binding are not
yet upstream (and this would be the first), I was hoping to squeak by.
Changes in v4: None
Changes in v3: None
Changes in v2: None
Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt b/Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt
index 5d181fc3cc18..4a78ba8b85bc 100644
--- a/Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt
+++ b/Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt
@@ -59,7 +59,8 @@ Required properties:
one for each entry in reset-names.
- reset-names: "phy" for reset of phy block,
"common" for phy common block reset,
- "cfg" for phy's ahb cfg block reset.
+ "cfg" for phy's ahb cfg block reset,
+ "ufsphy" for the PHY reset in the UFS controller.
For "qcom,ipq8074-qmp-pcie-phy" must contain:
"phy", "common".
@@ -74,7 +75,8 @@ Required properties:
"phy", "common".
For "qcom,sdm845-qmp-usb3-uni-phy" must contain:
"phy", "common".
- For "qcom,sdm845-qmp-ufs-phy": no resets are listed.
+ For "qcom,sdm845-qmp-ufs-phy": must contain:
+ "ufsphy".
- vdda-phy-supply: Phandle to a regulator supply to PHY core block.
- vdda-pll-supply: Phandle to 1.8V regulator supply to PHY refclk pll block.
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 3/8] dt-bindings: phy: qcom-ufs: Add resets property
2019-02-13 23:25 [PATCH v4 0/8] phy: qcom-ufs: Enable regulators to be off in suspend Evan Green
2019-02-13 23:25 ` [PATCH v4 1/8] dt-bindings: ufs: Add #reset-cells for Qualcomm controllers Evan Green
2019-02-13 23:25 ` [PATCH v4 2/8] dt-bindings: phy-qcom-qmp: Add UFS PHY reset Evan Green
@ 2019-02-13 23:25 ` Evan Green
2019-02-13 23:25 ` [PATCH v4 4/8] arm64: dts: sdm845: Add UFS PHY reset Evan Green
2019-02-13 23:25 ` [PATCH v4 5/8] arm64: dts: msm8996: Add UFS PHY reset controller Evan Green
4 siblings, 0 replies; 6+ messages in thread
From: Evan Green @ 2019-02-13 23:25 UTC (permalink / raw)
To: Andy Gross, Kishon Vijay Abraham I
Cc: Stephen Boyd, Marc Gonzalez, Can Guo, Vivek Gautam,
Douglas Anderson, Asutosh Das, Evan Green, Rob Herring,
devicetree, linux-kernel, Rob Herring, Mark Rutland
Add a resets property to the PHY that represents the PHY reset
register in the UFS controller itself. This better describes the
complete specification of the PHY, and allows the PHY to perform
its initialization in a single function, rather than relying on
back-channel sequencing of initialization through the PHY framework.
Signed-off-by: Evan Green <evgreen@chromium.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
---
Changes in v4: None
Changes in v3: None
Changes in v2:
- Added resets to example (Stephen).
Documentation/devicetree/bindings/ufs/ufs-qcom.txt | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/ufs/ufs-qcom.txt b/Documentation/devicetree/bindings/ufs/ufs-qcom.txt
index 21d9a93db2e9..fd59f93e9556 100644
--- a/Documentation/devicetree/bindings/ufs/ufs-qcom.txt
+++ b/Documentation/devicetree/bindings/ufs/ufs-qcom.txt
@@ -29,6 +29,7 @@ Optional properties:
- vdda-pll-max-microamp : specifies max. load that can be drawn from pll supply
- vddp-ref-clk-supply : phandle to UFS device ref_clk pad power supply
- vddp-ref-clk-max-microamp : specifies max. load that can be drawn from this supply
+- resets : specifies the PHY reset in the UFS controller
Example:
@@ -51,9 +52,11 @@ Example:
<&clock_gcc clk_ufs_phy_ldo>,
<&clock_gcc clk_gcc_ufs_tx_cfg_clk>,
<&clock_gcc clk_gcc_ufs_rx_cfg_clk>;
+ resets = <&ufshc 0>;
};
- ufshc@fc598000 {
+ ufshc: ufshc@fc598000 {
+ #reset-cells = <1>;
...
phys = <&ufsphy1>;
phy-names = "ufsphy";
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 4/8] arm64: dts: sdm845: Add UFS PHY reset
2019-02-13 23:25 [PATCH v4 0/8] phy: qcom-ufs: Enable regulators to be off in suspend Evan Green
` (2 preceding siblings ...)
2019-02-13 23:25 ` [PATCH v4 3/8] dt-bindings: phy: qcom-ufs: Add resets property Evan Green
@ 2019-02-13 23:25 ` Evan Green
2019-02-13 23:25 ` [PATCH v4 5/8] arm64: dts: msm8996: Add UFS PHY reset controller Evan Green
4 siblings, 0 replies; 6+ messages in thread
From: Evan Green @ 2019-02-13 23:25 UTC (permalink / raw)
To: Andy Gross, Kishon Vijay Abraham I
Cc: Stephen Boyd, Marc Gonzalez, Can Guo, Vivek Gautam,
Douglas Anderson, Asutosh Das, Evan Green, devicetree,
linux-arm-msm, linux-kernel, Rob Herring, David Brown,
Mark Rutland
Wire up the reset controller in the Qcom UFS controller for the PHY.
This will be used to toggle PHY reset during initialization of the PHY.
Signed-off-by: Evan Green <evgreen@chromium.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
---
This commit is based atop the series at [1]. Patches 1 and 2 of that
series have landed, but 3, 4, and 5 are still outstanding.
[1] https://lore.kernel.org/lkml/20181210192826.241350-1-evgreen@chromium.org/
Changes in v4: None
Changes in v3: None
Changes in v2: None
arch/arm64/boot/dts/qcom/sdm845.dtsi | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi
index b29332b265d9..029ab66405cf 100644
--- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
@@ -990,6 +990,7 @@
phy-names = "ufsphy";
lanes-per-direction = <2>;
power-domains = <&gcc UFS_PHY_GDSC>;
+ #reset-cells = <1>;
clock-names =
"core_clk",
@@ -1033,6 +1034,8 @@
clocks = <&gcc GCC_UFS_MEM_CLKREF_CLK>,
<&gcc GCC_UFS_PHY_PHY_AUX_CLK>;
+ resets = <&ufs_mem_hc 0>;
+ reset-names = "ufsphy";
status = "disabled";
ufs_mem_phy_lanes: lanes@1d87400 {
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 5/8] arm64: dts: msm8996: Add UFS PHY reset controller
2019-02-13 23:25 [PATCH v4 0/8] phy: qcom-ufs: Enable regulators to be off in suspend Evan Green
` (3 preceding siblings ...)
2019-02-13 23:25 ` [PATCH v4 4/8] arm64: dts: sdm845: Add UFS PHY reset Evan Green
@ 2019-02-13 23:25 ` Evan Green
4 siblings, 0 replies; 6+ messages in thread
From: Evan Green @ 2019-02-13 23:25 UTC (permalink / raw)
To: Andy Gross, Kishon Vijay Abraham I
Cc: Stephen Boyd, Marc Gonzalez, Can Guo, Vivek Gautam,
Douglas Anderson, Asutosh Das, Evan Green, devicetree,
linux-arm-msm, linux-kernel, Rob Herring, David Brown,
Mark Rutland
Add the reset controller for the UFS controller, and wire it up
so that the UFS PHY can initialize itself without relying on
implicit sequencing between the two drivers.
Signed-off-by: Evan Green <evgreen@chromium.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
arch/arm64/boot/dts/qcom/msm8996.dtsi | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi b/arch/arm64/boot/dts/qcom/msm8996.dtsi
index 99b7495455a6..179f1988d45c 100644
--- a/arch/arm64/boot/dts/qcom/msm8996.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi
@@ -663,10 +663,11 @@
clock-names = "ref_clk_src", "ref_clk";
clocks = <&rpmcc RPM_SMD_LN_BB_CLK>,
<&gcc GCC_UFS_CLKREF_CLK>;
+ resets = <&ufshc 0>;
status = "disabled";
};
- ufshc@624000 {
+ ufshc: ufshc@624000 {
compatible = "qcom,ufshc";
reg = <0x624000 0x2500>;
interrupts = <GIC_SPI 265 IRQ_TYPE_LEVEL_HIGH>;
@@ -722,6 +723,7 @@
<0 0>;
lanes-per-direction = <1>;
+ #reset-cells = <1>;
status = "disabled";
ufs_variant {
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-02-13 23:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-13 23:25 [PATCH v4 0/8] phy: qcom-ufs: Enable regulators to be off in suspend Evan Green
2019-02-13 23:25 ` [PATCH v4 1/8] dt-bindings: ufs: Add #reset-cells for Qualcomm controllers Evan Green
2019-02-13 23:25 ` [PATCH v4 2/8] dt-bindings: phy-qcom-qmp: Add UFS PHY reset Evan Green
2019-02-13 23:25 ` [PATCH v4 3/8] dt-bindings: phy: qcom-ufs: Add resets property Evan Green
2019-02-13 23:25 ` [PATCH v4 4/8] arm64: dts: sdm845: Add UFS PHY reset Evan Green
2019-02-13 23:25 ` [PATCH v4 5/8] arm64: dts: msm8996: Add UFS PHY reset controller Evan Green
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).