diff mbox series

[RFC,v1,5/5] ARM64: verdin-imx8mm: use regulator power domain to model sleep-moci

Message ID 20220609150851.23084-6-max.oss.09@gmail.com
State New
Headers show
Series [v1,1/5] dt-bindings: power: Add bindings for a power domain controlled by a regulator | expand

Commit Message

Max Krummenacher June 9, 2022, 3:08 p.m. UTC
From: Max Krummenacher <max.krummenacher@toradex.com>

The Verdin CTRL_SLEEP_MOCI# pin signals the carrier board that the module
is in sleep and it may switch off unneeded power.

Control this pin with a regulator power domain controller which uses a
fixed regulator with a gpio enable.

Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>

---

 .../dts/freescale/imx8mm-verdin-dahlia.dtsi   |  1 +
 .../boot/dts/freescale/imx8mm-verdin-dev.dtsi |  2 ++
 .../boot/dts/freescale/imx8mm-verdin.dtsi     | 35 +++++++++++++------
 3 files changed, 28 insertions(+), 10 deletions(-)

Comments

Max Krummenacher June 15, 2022, 3:32 p.m. UTC | #1
Hi

On Tue, Jun 14, 2022 at 9:29 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Max,
>
> On Thu, Jun 9, 2022 at 5:16 PM Max Krummenacher <max.oss.09@gmail.com> wrote:
> > From: Max Krummenacher <max.krummenacher@toradex.com>
> >
> > The Verdin CTRL_SLEEP_MOCI# pin signals the carrier board that the module
> > is in sleep and it may switch off unneeded power.
> >
> > Control this pin with a regulator power domain controller which uses a
> > fixed regulator with a gpio enable.
> >
> > Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
>
> Thanks for your patch!
>
> > --- a/arch/arm64/boot/dts/freescale/imx8mm-verdin-dahlia.dtsi
> > +++ b/arch/arm64/boot/dts/freescale/imx8mm-verdin-dahlia.dtsi
> > @@ -92,6 +92,7 @@
> >
> >  /* Verdin PCIE_1 */
> >  &pcie0 {
> > +       power-domains = <&pd_sleep_moci>;
>
> This overrides "power-domains = <&pgc_pcie>;" from imx8mm.dtsi...
>
> >         status = "okay";
> >  };
>
> > --- a/arch/arm64/boot/dts/freescale/imx8mm-verdin.dtsi
> > +++ b/arch/arm64/boot/dts/freescale/imx8mm-verdin.dtsi
> > @@ -53,6 +53,14 @@
> >                 };
> >         };
> >
> > +       pd_sleep_moci: power-domain-sleep-moci {
> > +               compatible = "regulator-pm-pd";
> > +               label = "pd_sleep_moci";
> > +               power-domains = <&pgc_pcie>;
>
> ... and here you work around that by re-binding <&pgc_pcie>.
>
> I think you:
>   1. must not override the power-domains property for pcie0, as
>      conceptually, the PCIe bus is still in the on-SoC power
>      domain. What if some lanes are connected to devices in
>      pd_sleep_moci, but other lanes are not?
>   2. should only use pd_sleep_moci for the off-chip devices that
>       are actually controlled by the corresponding regulator.

I fully agree.
I wanted to send along the implementation commits for the power
domain controller something which actually uses it and which
did work in my testing.
That is why I marked this as RFC and I know that more
work is needed.

Cheers
Max

>
> > +               power-supply = <&reg_sleep_moci>;
> > +               #power-domain-cells = <0>;
> > +       };
> > +
> >         /* Carrier Board Supplies */
> >         reg_1p8v: regulator-1p8v {
> >                 compatible = "regulator-fixed";
>
> Gr{oetje,eeting}s,
>
>                         Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds
diff mbox series

Patch

diff --git a/arch/arm64/boot/dts/freescale/imx8mm-verdin-dahlia.dtsi b/arch/arm64/boot/dts/freescale/imx8mm-verdin-dahlia.dtsi
index c2a5c2f7b204..03416dc593d8 100644
--- a/arch/arm64/boot/dts/freescale/imx8mm-verdin-dahlia.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mm-verdin-dahlia.dtsi
@@ -92,6 +92,7 @@ 
 
 /* Verdin PCIE_1 */
 &pcie0 {
+	power-domains = <&pd_sleep_moci>;
 	status = "okay";
 };
 
diff --git a/arch/arm64/boot/dts/freescale/imx8mm-verdin-dev.dtsi b/arch/arm64/boot/dts/freescale/imx8mm-verdin-dev.dtsi
index 73cc3fafa018..f887b907fdde 100644
--- a/arch/arm64/boot/dts/freescale/imx8mm-verdin-dev.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mm-verdin-dev.dtsi
@@ -50,6 +50,7 @@ 
 	/* Audio Codec */
 	nau8822_1a: audio-codec@1a {
 		compatible = "nuvoton,nau8822";
+		power-domains = <&pd_sleep_moci>;
 		reg = <0x1a>;
 	};
 };
@@ -59,6 +60,7 @@ 
 	linux,rs485-enabled-at-boot-time;
 	rs485-rts-active-low;
 	rs485-rx-during-tx;
+	power-domains = <&pd_sleep_moci>;
 };
 
 /* Limit frequency on dev board due to long traces and bad signal integrity */
diff --git a/arch/arm64/boot/dts/freescale/imx8mm-verdin.dtsi b/arch/arm64/boot/dts/freescale/imx8mm-verdin.dtsi
index eafa88d980b3..b5daa8f83bef 100644
--- a/arch/arm64/boot/dts/freescale/imx8mm-verdin.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mm-verdin.dtsi
@@ -53,6 +53,14 @@ 
 		};
 	};
 
+	pd_sleep_moci: power-domain-sleep-moci {
+		compatible = "regulator-pm-pd";
+		label = "pd_sleep_moci";
+		power-domains = <&pgc_pcie>;
+		power-supply = <&reg_sleep_moci>;
+		#power-domain-cells = <0>;
+	};
+
 	/* Carrier Board Supplies */
 	reg_1p8v: regulator-1p8v {
 		compatible = "regulator-fixed";
@@ -90,6 +98,19 @@ 
 		startup-delay-us = <200000>;
 	};
 
+	reg_sleep_moci: regulator-sleep-moci {
+		compatible = "regulator-fixed";
+		enable-active-high;
+		gpio = <&gpio5 1 GPIO_ACTIVE_HIGH>;
+		off-on-delay = <2000>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_ctrl_sleep_moci>;
+		regulator-max-microvolt = <1800000>;
+		regulator-min-microvolt = <1800000>;
+		regulator-name = "CTRL_SLEEP_MOCI#";
+		startup-delay-us = <2000>;
+	};
+
 	reg_usb_otg1_vbus: regulator-usb-otg1 {
 		compatible = "regulator-fixed";
 		enable-active-high;
@@ -109,6 +130,7 @@ 
 		gpio = <&gpio1 14 GPIO_ACTIVE_HIGH>;
 		pinctrl-names = "default";
 		pinctrl-0 = <&pinctrl_reg_usb2_en>;
+		power-domains = <&pd_sleep_moci>;
 		regulator-max-microvolt = <5000000>;
 		regulator-min-microvolt = <5000000>;
 		regulator-name = "USB_2_EN";
@@ -198,6 +220,7 @@ 
 		interrupts-extended = <&gpio1 6 IRQ_TYPE_EDGE_FALLING>;
 		pinctrl-names = "default";
 		pinctrl-0 = <&pinctrl_can1_int>;
+		power-domains = <&pd_sleep_moci>;
 		reg = <0>;
 		spi-max-frequency = <8500000>;
 	};
@@ -305,16 +328,6 @@ 
 			  "SODIMM_212",
 			  "SODIMM_151",
 			  "SODIMM_153";
-
-	ctrl-sleep-moci-hog {
-		gpio-hog;
-		/* Verdin CTRL_SLEEP_MOCI# (SODIMM 256) */
-		gpios = <1 GPIO_ACTIVE_HIGH>;
-		line-name = "CTRL_SLEEP_MOCI#";
-		output-high;
-		pinctrl-names = "default";
-		pinctrl-0 = <&pinctrl_ctrl_sleep_moci>;
-	};
 };
 
 /* On-module I2C */
@@ -560,6 +573,7 @@ 
 		enable-gpios = <&gpio3 3 GPIO_ACTIVE_HIGH>;
 		pinctrl-names = "default";
 		pinctrl-0 = <&pinctrl_gpio_10_dsi>;
+		power-domains = <&pd_sleep_moci>;
 		reg = <0x2c>;
 		status = "disabled";
 	};
@@ -576,6 +590,7 @@ 
 		compatible = "lontium,lt8912b";
 		pinctrl-names = "default";
 		pinctrl-0 = <&pinctrl_gpio_10_dsi>, <&pinctrl_pwm_3_dsi_hpd_gpio>;
+		power-domains = <&pd_sleep_moci>;
 		reg = <0x48>;
 		/* Verdin GPIO_9_DSI (LT8912 INT, SODIMM 17, unused) */
 		/* Verdin GPIO_10_DSI (SODIMM 21) */