All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] clk: qcom: gdsc: Handle supply regulators
@ 2020-04-17  7:00 Bjorn Andersson
  2020-04-17  7:00 ` [PATCH v2 1/4] clk: qcom: gdsc: Handle GDSC regulator supplies Bjorn Andersson
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Bjorn Andersson @ 2020-04-17  7:00 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Michael Turquette, Stephen Boyd,
	Rob Herring
  Cc: linux-arm-msm, linux-clk, devicetree, linux-kernel

Handle supply regulators for GDSCs to allow probe deferral when regulators are
not yet present/enabled and to allow the GDSC to enable/disable dependencies as
needed.

Bjorn Andersson (3):
  clk: qcom: gdsc: Handle GDSC regulator supplies
  clk: qcom: mmcc-msm8996: Properly describe GPU_GX gdsc
  arm64: dts: qcom: msm8996: Make GPU node control GPU_GX GDSC

Rajendra Nayak (1):
  arm64: dts: qcom: db820c: Add vdd_gfx and tie it into mmcc

 .../devicetree/bindings/clock/qcom,mmcc.yaml  |  4 ++++
 arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi  | 14 +++++++++++
 arch/arm64/boot/dts/qcom/msm8996.dtsi         |  2 +-
 arch/arm64/boot/dts/qcom/pmi8994.dtsi         |  6 +++++
 drivers/clk/qcom/gdsc.c                       | 23 +++++++++++++++++++
 drivers/clk/qcom/gdsc.h                       |  4 ++++
 drivers/clk/qcom/mmcc-msm8996.c               |  2 ++
 7 files changed, 54 insertions(+), 1 deletion(-)

-- 
2.24.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 1/4] clk: qcom: gdsc: Handle GDSC regulator supplies
  2020-04-17  7:00 [PATCH v2 0/4] clk: qcom: gdsc: Handle supply regulators Bjorn Andersson
@ 2020-04-17  7:00 ` Bjorn Andersson
  2020-05-14 21:23   ` Stephen Boyd
  2020-04-17  7:00 ` [PATCH v2 2/4] clk: qcom: mmcc-msm8996: Properly describe GPU_GX gdsc Bjorn Andersson
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Bjorn Andersson @ 2020-04-17  7:00 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Rob Herring
  Cc: Andy Gross, linux-arm-msm, linux-clk, devicetree, linux-kernel

Certain GDSCs, such as the GPU_GX on MSM8996, requires that the upstream
regulator supply is powered in order to be turned on.

It's not guaranteed that the bootloader will leave these supplies on and
the driver core will attempt to enable any GDSCs before allowing the
individual drivers to probe defer on the PMIC regulator driver not yet
being present.

So the gdsc driver needs to be made aware of supplying regulators and
probe defer on their absence, and it needs to enable and disable the
regulator accordingly.

Voltage adjustments of the supplying regulator are deferred to the
client drivers themselves.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---

Changes since v1:
- Sorted includes
- Dropped unnecessary comment

 drivers/clk/qcom/gdsc.c | 23 +++++++++++++++++++++++
 drivers/clk/qcom/gdsc.h |  4 ++++
 2 files changed, 27 insertions(+)

diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c
index a250f59708d8..04944f11659b 100644
--- a/drivers/clk/qcom/gdsc.c
+++ b/drivers/clk/qcom/gdsc.c
@@ -11,6 +11,7 @@
 #include <linux/ktime.h>
 #include <linux/pm_domain.h>
 #include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
 #include <linux/reset-controller.h>
 #include <linux/slab.h>
 #include "gdsc.h"
@@ -112,6 +113,12 @@ static int gdsc_toggle_logic(struct gdsc *sc, enum gdsc_status status)
 	int ret;
 	u32 val = (status == GDSC_ON) ? 0 : SW_COLLAPSE_MASK;
 
+	if (status == GDSC_ON && sc->rsupply) {
+		ret = regulator_enable(sc->rsupply);
+		if (ret < 0)
+			return ret;
+	}
+
 	ret = regmap_update_bits(sc->regmap, sc->gdscr, SW_COLLAPSE_MASK, val);
 	if (ret)
 		return ret;
@@ -143,6 +150,13 @@ static int gdsc_toggle_logic(struct gdsc *sc, enum gdsc_status status)
 
 	ret = gdsc_poll_status(sc, status);
 	WARN(ret, "%s status stuck at 'o%s'", sc->pd.name, status ? "ff" : "n");
+
+	if (!ret && status == GDSC_OFF && sc->rsupply) {
+		ret = regulator_disable(sc->rsupply);
+		if (ret < 0)
+			return ret;
+	}
+
 	return ret;
 }
 
@@ -371,6 +385,15 @@ int gdsc_register(struct gdsc_desc *desc,
 	if (!data->domains)
 		return -ENOMEM;
 
+	for (i = 0; i < num; i++) {
+		if (!scs[i] || !scs[i]->supply)
+			continue;
+
+		scs[i]->rsupply = devm_regulator_get(dev, scs[i]->supply);
+		if (IS_ERR(scs[i]->rsupply))
+			return PTR_ERR(scs[i]->rsupply);
+	}
+
 	data->num_domains = num;
 	for (i = 0; i < num; i++) {
 		if (!scs[i])
diff --git a/drivers/clk/qcom/gdsc.h b/drivers/clk/qcom/gdsc.h
index 64cdc8cf0d4d..c36fc26dcdff 100644
--- a/drivers/clk/qcom/gdsc.h
+++ b/drivers/clk/qcom/gdsc.h
@@ -10,6 +10,7 @@
 #include <linux/pm_domain.h>
 
 struct regmap;
+struct regulator;
 struct reset_controller_dev;
 
 /**
@@ -52,6 +53,9 @@ struct gdsc {
 	struct reset_controller_dev	*rcdev;
 	unsigned int			*resets;
 	unsigned int			reset_count;
+
+	const char 			*supply;
+	struct regulator		*rsupply;
 };
 
 struct gdsc_desc {
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 2/4] clk: qcom: mmcc-msm8996: Properly describe GPU_GX gdsc
  2020-04-17  7:00 [PATCH v2 0/4] clk: qcom: gdsc: Handle supply regulators Bjorn Andersson
  2020-04-17  7:00 ` [PATCH v2 1/4] clk: qcom: gdsc: Handle GDSC regulator supplies Bjorn Andersson
@ 2020-04-17  7:00 ` Bjorn Andersson
  2020-04-29 21:35   ` Rob Herring
  2020-05-14 21:24   ` Stephen Boyd
  2020-04-17  7:00 ` [PATCH v2 3/4] arm64: dts: qcom: db820c: Add vdd_gfx and tie it into mmcc Bjorn Andersson
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 9+ messages in thread
From: Bjorn Andersson @ 2020-04-17  7:00 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Rob Herring
  Cc: Andy Gross, linux-arm-msm, linux-clk, devicetree, linux-kernel

The GPU_GX GDSC depends on both GPU GDSC being enabled and that the
VDD_GX rail is powered, so update the description of the node to cover
these requirements.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---

Changes since v1:
- vdd_gfx -> vdd-gfx

 Documentation/devicetree/bindings/clock/qcom,mmcc.yaml | 4 ++++
 drivers/clk/qcom/mmcc-msm8996.c                        | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/clock/qcom,mmcc.yaml b/Documentation/devicetree/bindings/clock/qcom,mmcc.yaml
index acc31b3991bd..1b16a863b355 100644
--- a/Documentation/devicetree/bindings/clock/qcom,mmcc.yaml
+++ b/Documentation/devicetree/bindings/clock/qcom,mmcc.yaml
@@ -67,6 +67,10 @@ properties:
     description:
        Protected clock specifier list as per common clock binding
 
+  vdd-gfx-supply:
+    description:
+      Regulator supply for the GPU_GX GDSC
+
 required:
   - compatible
   - reg
diff --git a/drivers/clk/qcom/mmcc-msm8996.c b/drivers/clk/qcom/mmcc-msm8996.c
index 6c7592ddf8bb..3b3aac07fb2d 100644
--- a/drivers/clk/qcom/mmcc-msm8996.c
+++ b/drivers/clk/qcom/mmcc-msm8996.c
@@ -3064,7 +3064,9 @@ static struct gdsc gpu_gx_gdsc = {
 		.name = "gpu_gx",
 	},
 	.pwrsts = PWRSTS_OFF_ON,
+	.parent = &gpu_gdsc.pd,
 	.flags = CLAMP_IO,
+	.supply = "vdd-gfx",
 };
 
 static struct clk_regmap *mmcc_msm8996_clocks[] = {
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 3/4] arm64: dts: qcom: db820c: Add vdd_gfx and tie it into mmcc
  2020-04-17  7:00 [PATCH v2 0/4] clk: qcom: gdsc: Handle supply regulators Bjorn Andersson
  2020-04-17  7:00 ` [PATCH v2 1/4] clk: qcom: gdsc: Handle GDSC regulator supplies Bjorn Andersson
  2020-04-17  7:00 ` [PATCH v2 2/4] clk: qcom: mmcc-msm8996: Properly describe GPU_GX gdsc Bjorn Andersson
@ 2020-04-17  7:00 ` Bjorn Andersson
  2020-04-17  7:00 ` [PATCH v2 4/4] arm64: dts: qcom: msm8996: Make GPU node control GPU_GX GDSC Bjorn Andersson
  2020-05-14 17:11 ` [PATCH v2 0/4] clk: qcom: gdsc: Handle supply regulators Vinod Koul
  4 siblings, 0 replies; 9+ messages in thread
From: Bjorn Andersson @ 2020-04-17  7:00 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson
  Cc: Michael Turquette, Stephen Boyd, Rob Herring, linux-arm-msm,
	linux-clk, devicetree, linux-kernel

From: Rajendra Nayak <rnayak@codeaurora.org>

Add the SPMI regulator node in the PMI8994, use it to give us VDD_GX
at a fixed max nominal voltage for the db820c and specify this as supply
for the MMSS GPU_GX GDSC.

With the introduction of CPR support the range for VDD_GX should be
expanded.

Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
[bjorn: Split between pmi8994 and db820c, changed voltage, rewrote commit message]
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---

Changes since v1:
- Polished commit message
- vdd_gfx -> vdd-gfx

 arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi | 14 ++++++++++++++
 arch/arm64/boot/dts/qcom/pmi8994.dtsi        |  6 ++++++
 2 files changed, 20 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi b/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
index 4692b7ad16b7..fc23b381c5e4 100644
--- a/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
+++ b/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
@@ -251,6 +251,10 @@ &mdss {
 	status = "okay";
 };
 
+&mmcc {
+	vdd-gfx-supply = <&vdd_gfx>;
+};
+
 &msmgpio {
 	gpio-line-names =
 		"[SPI0_DOUT]", /* GPIO_0, BLSP1_SPI_MOSI, LSEC pin 14 */
@@ -688,6 +692,16 @@ pinconf {
 	};
 };
 
+
+&pmi8994_spmi_regulators {
+	vdd_gfx: s2@1700 {
+		reg = <0x1700 0x100>;
+		regulator-name = "VDD_GFX";
+		regulator-min-microvolt = <980000>;
+		regulator-max-microvolt = <980000>;
+	};
+};
+
 &rpm_requests {
 	pm8994-regulators {
 		compatible = "qcom,rpm-pm8994-regulators";
diff --git a/arch/arm64/boot/dts/qcom/pmi8994.dtsi b/arch/arm64/boot/dts/qcom/pmi8994.dtsi
index 21e05215abe4..e5ed28ab9b2d 100644
--- a/arch/arm64/boot/dts/qcom/pmi8994.dtsi
+++ b/arch/arm64/boot/dts/qcom/pmi8994.dtsi
@@ -26,5 +26,11 @@ pmic@3 {
 		reg = <0x3 SPMI_USID>;
 		#address-cells = <1>;
 		#size-cells = <0>;
+
+		pmi8994_spmi_regulators: regulators {
+			compatible = "qcom,pmi8994-regulators";
+			#address-cells = <1>;
+			#size-cells = <1>;
+		};
 	};
 };
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 4/4] arm64: dts: qcom: msm8996: Make GPU node control GPU_GX GDSC
  2020-04-17  7:00 [PATCH v2 0/4] clk: qcom: gdsc: Handle supply regulators Bjorn Andersson
                   ` (2 preceding siblings ...)
  2020-04-17  7:00 ` [PATCH v2 3/4] arm64: dts: qcom: db820c: Add vdd_gfx and tie it into mmcc Bjorn Andersson
@ 2020-04-17  7:00 ` Bjorn Andersson
  2020-05-14 17:11 ` [PATCH v2 0/4] clk: qcom: gdsc: Handle supply regulators Vinod Koul
  4 siblings, 0 replies; 9+ messages in thread
From: Bjorn Andersson @ 2020-04-17  7:00 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson
  Cc: Michael Turquette, Stephen Boyd, Rob Herring, linux-arm-msm,
	linux-clk, devicetree, linux-kernel

Presumably the GPU node needs to control both the GPU and GPU GX power
domains, but given that GPU GX now depends on the GPU GDSC both can
effectively be controlled by controlling GPU GX. So use this instead.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---

Changes since v1:
- None

 arch/arm64/boot/dts/qcom/msm8996.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi b/arch/arm64/boot/dts/qcom/msm8996.dtsi
index 895202d07a8b..af1f4977b97d 100644
--- a/arch/arm64/boot/dts/qcom/msm8996.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi
@@ -639,7 +639,7 @@ gpu@b00000 {
 				"mem",
 				"mem_iface";
 
-			power-domains = <&mmcc GPU_GDSC>;
+			power-domains = <&mmcc GPU_GX_GDSC>;
 			iommus = <&adreno_smmu 0>;
 
 			nvmem-cells = <&gpu_speed_bin>;
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/4] clk: qcom: mmcc-msm8996: Properly describe GPU_GX gdsc
  2020-04-17  7:00 ` [PATCH v2 2/4] clk: qcom: mmcc-msm8996: Properly describe GPU_GX gdsc Bjorn Andersson
@ 2020-04-29 21:35   ` Rob Herring
  2020-05-14 21:24   ` Stephen Boyd
  1 sibling, 0 replies; 9+ messages in thread
From: Rob Herring @ 2020-04-29 21:35 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Michael Turquette, Stephen Boyd, Andy Gross, linux-arm-msm,
	linux-clk, devicetree, linux-kernel

On Fri, 17 Apr 2020 00:00:42 -0700, Bjorn Andersson wrote:
> The GPU_GX GDSC depends on both GPU GDSC being enabled and that the
> VDD_GX rail is powered, so update the description of the node to cover
> these requirements.
> 
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
> 
> Changes since v1:
> - vdd_gfx -> vdd-gfx
> 
>  Documentation/devicetree/bindings/clock/qcom,mmcc.yaml | 4 ++++
>  drivers/clk/qcom/mmcc-msm8996.c                        | 2 ++
>  2 files changed, 6 insertions(+)
> 

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 0/4] clk: qcom: gdsc: Handle supply regulators
  2020-04-17  7:00 [PATCH v2 0/4] clk: qcom: gdsc: Handle supply regulators Bjorn Andersson
                   ` (3 preceding siblings ...)
  2020-04-17  7:00 ` [PATCH v2 4/4] arm64: dts: qcom: msm8996: Make GPU node control GPU_GX GDSC Bjorn Andersson
@ 2020-05-14 17:11 ` Vinod Koul
  4 siblings, 0 replies; 9+ messages in thread
From: Vinod Koul @ 2020-05-14 17:11 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Andy Gross, Michael Turquette, Stephen Boyd, Rob Herring,
	linux-arm-msm, linux-clk, devicetree, linux-kernel

On 17-04-20, 00:00, Bjorn Andersson wrote:
> Handle supply regulators for GDSCs to allow probe deferral when regulators are
> not yet present/enabled and to allow the GDSC to enable/disable dependencies as
> needed.

Reviewed-by: Vinod Koul <vkoul@kernel.org>

-- 
~Vinod

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/4] clk: qcom: gdsc: Handle GDSC regulator supplies
  2020-04-17  7:00 ` [PATCH v2 1/4] clk: qcom: gdsc: Handle GDSC regulator supplies Bjorn Andersson
@ 2020-05-14 21:23   ` Stephen Boyd
  0 siblings, 0 replies; 9+ messages in thread
From: Stephen Boyd @ 2020-05-14 21:23 UTC (permalink / raw)
  To: Bjorn Andersson, Michael Turquette, Rob Herring
  Cc: Andy Gross, linux-arm-msm, linux-clk, devicetree, linux-kernel

Quoting Bjorn Andersson (2020-04-17 00:00:41)
> Certain GDSCs, such as the GPU_GX on MSM8996, requires that the upstream
> regulator supply is powered in order to be turned on.
> 
> It's not guaranteed that the bootloader will leave these supplies on and
> the driver core will attempt to enable any GDSCs before allowing the
> individual drivers to probe defer on the PMIC regulator driver not yet
> being present.
> 
> So the gdsc driver needs to be made aware of supplying regulators and
> probe defer on their absence, and it needs to enable and disable the
> regulator accordingly.
> 
> Voltage adjustments of the supplying regulator are deferred to the
> client drivers themselves.
> 
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/4] clk: qcom: mmcc-msm8996: Properly describe GPU_GX gdsc
  2020-04-17  7:00 ` [PATCH v2 2/4] clk: qcom: mmcc-msm8996: Properly describe GPU_GX gdsc Bjorn Andersson
  2020-04-29 21:35   ` Rob Herring
@ 2020-05-14 21:24   ` Stephen Boyd
  1 sibling, 0 replies; 9+ messages in thread
From: Stephen Boyd @ 2020-05-14 21:24 UTC (permalink / raw)
  To: Bjorn Andersson, Michael Turquette, Rob Herring
  Cc: Andy Gross, linux-arm-msm, linux-clk, devicetree, linux-kernel

Quoting Bjorn Andersson (2020-04-17 00:00:42)
> The GPU_GX GDSC depends on both GPU GDSC being enabled and that the
> VDD_GX rail is powered, so update the description of the node to cover
> these requirements.
> 
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-05-14 21:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-17  7:00 [PATCH v2 0/4] clk: qcom: gdsc: Handle supply regulators Bjorn Andersson
2020-04-17  7:00 ` [PATCH v2 1/4] clk: qcom: gdsc: Handle GDSC regulator supplies Bjorn Andersson
2020-05-14 21:23   ` Stephen Boyd
2020-04-17  7:00 ` [PATCH v2 2/4] clk: qcom: mmcc-msm8996: Properly describe GPU_GX gdsc Bjorn Andersson
2020-04-29 21:35   ` Rob Herring
2020-05-14 21:24   ` Stephen Boyd
2020-04-17  7:00 ` [PATCH v2 3/4] arm64: dts: qcom: db820c: Add vdd_gfx and tie it into mmcc Bjorn Andersson
2020-04-17  7:00 ` [PATCH v2 4/4] arm64: dts: qcom: msm8996: Make GPU node control GPU_GX GDSC Bjorn Andersson
2020-05-14 17:11 ` [PATCH v2 0/4] clk: qcom: gdsc: Handle supply regulators Vinod Koul

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.