diff mbox series

[7/7] arm64: dts: renesas: r9a09g047e57-smarc: Enable SDHI1

Message ID 20250126134616.37334-8-biju.das.jz@bp.renesas.com (mailing list archive)
State New
Delegated to: Geert Uytterhoeven
Headers show
Series Add RZ/G3E SDHI support | expand

Commit Message

Biju Das Jan. 26, 2025, 1:46 p.m. UTC
Enable SDHI1 on the RZ/G3E SMARC EVK platform using gpio regulator for
voltage switching.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 .../boot/dts/renesas/r9a09g047e57-smarc.dts   | 65 +++++++++++++++++++
 .../boot/dts/renesas/renesas-smarc2.dtsi      |  9 +++
 2 files changed, 74 insertions(+)

Comments

Tommaso Merciai Jan. 26, 2025, 7:02 p.m. UTC | #1
On Sun, Jan 26, 2025 at 01:46:09PM +0000, Biju Das wrote:
> Enable SDHI1 on the RZ/G3E SMARC EVK platform using gpio regulator for
> voltage switching.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  .../boot/dts/renesas/r9a09g047e57-smarc.dts   | 65 +++++++++++++++++++
>  .../boot/dts/renesas/renesas-smarc2.dtsi      |  9 +++
>  2 files changed, 74 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts b/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
> index c063d47e2952..0e3d4ff31285 100644
> --- a/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
> +++ b/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
> @@ -12,10 +12,40 @@
>  #include "rzg3e-smarc-som.dtsi"
>  #include "renesas-smarc2.dtsi"
>  
> +/*
> + * To enable uSD card on SDIO_USD:
> + *
> + * Switch bank - SW_OPT_MUX-1 (SW_SDIO_M2E):
> + *	0 - SMARC SDIO signal is connected to uSD1
> + *	1 - SMARC SDIO signal is connected to M.2 Key E connector
> + */
> +
>  / {
>  	model = "Renesas SMARC EVK version 2 based on r9a09g047e57";
>  	compatible = "renesas,smarc2-evk", "renesas,rzg3e-smarcm",
>  		     "renesas,r9a09g047e57", "renesas,r9a09g047";
> +
> +	usd_vdd_3p3v: regulator-usd-vdd-3p3v {
> +		compatible = "regulator-fixed";
> +		regulator-name = "fixed-3.3V";
> +		regulator-min-microvolt = <3300000>;
> +		regulator-max-microvolt = <3300000>;
> +		regulator-boot-on;
> +		regulator-always-on;
> +	};
> +
> +	vqmmc_sdhi1_ext: regulator-vqmmc-sdhi1-ext {
> +		compatible = "regulator-gpio";
> +
> +		regulator-name = "SDHI1 VccQ";
> +		regulator-min-microvolt = <1800000>;
> +		regulator-max-microvolt = <3300000>;
> +
> +		gpios = <&pinctrl RZG3E_GPIO(1, 5) GPIO_ACTIVE_HIGH>;
> +
> +		gpios-states = <0>;
> +		states = <3300000 0>, <1800000 1>;
> +	};
>  };
>  
>  &pinctrl {
> @@ -23,9 +53,44 @@ scif_pins: scif {
>  		pins = "SCIF_TXD", "SCIF_RXD";
>  		renesas,output-impedance = <1>;
>  	};
> +
> +	sd1-pwr-en {
> +		gpio-hog;
> +		gpios = <RZG3E_GPIO(1, 6) GPIO_ACTIVE_HIGH>;
> +		output-high;
> +		line-name = "sd1_pwr_en";
> +	};
> +
> +	sdhi1_pins: sd1 {
> +		sd1-cd {
> +			pinmux = <RZG3E_PORT_PINMUX(1, 4, 8)>; /* SD1CD */
> +		};
> +
> +		sd1-data {
> +			pinmux = <RZG3E_PORT_PINMUX(G, 2, 1)>, /* SD1DAT0 */
> +				 <RZG3E_PORT_PINMUX(G, 3, 1)>, /* SD1DAT1 */
> +				 <RZG3E_PORT_PINMUX(G, 4, 1)>, /* SD1DAT2 */
> +				 <RZG3E_PORT_PINMUX(G, 5, 1)>; /* SD1DAT3 */
> +		};
> +
> +		sd1-ctrl {
> +			pinmux = <RZG3E_PORT_PINMUX(G, 0, 1)>, /* SD1CLK */
> +				 <RZG3E_PORT_PINMUX(G, 1, 1)>; /* SD1CMD */
> +		};
> +	};
>  };
>  
>  &scif0 {
>  	pinctrl-0 = <&scif_pins>;
>  	pinctrl-names = "default";
>  };
> +
> +&sdhi1 {
> +	pinctrl-0 = <&sdhi1_pins>;
> +	pinctrl-1 = <&sdhi1_pins>;
> +	pinctrl-names = "default", "state_uhs";
> +
> +	vmmc-supply = <&usd_vdd_3p3v>;
> +	vqmmc-supply = <&vqmmc_sdhi1_ext>;
> +	/delete-node/ vqmmc_regulator;
> +};
> diff --git a/arch/arm64/boot/dts/renesas/renesas-smarc2.dtsi b/arch/arm64/boot/dts/renesas/renesas-smarc2.dtsi
> index e378d55e6e9b..ec79452393b0 100644
> --- a/arch/arm64/boot/dts/renesas/renesas-smarc2.dtsi
> +++ b/arch/arm64/boot/dts/renesas/renesas-smarc2.dtsi
> @@ -16,9 +16,18 @@ chosen {
>  
>  	aliases {
>  		serial3 = &scif0;
> +		mmc1 = &sdhi1;
>  	};
>  };
>  
>  &scif0 {
>  	status = "okay";
>  };
> +
> +&sdhi1 {
> +	bus-width = <4>;
> +	sd-uhs-sdr50;
> +	sd-uhs-sdr104;
> +
> +	status = "okay";
> +};
> -- 
> 2.43.0
> 
Reviewed-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Geert Uytterhoeven Jan. 28, 2025, 2:04 p.m. UTC | #2
Hi Biju,

On Sun, 26 Jan 2025 at 14:46, Biju Das <biju.das.jz@bp.renesas.com> wrote:
> Enable SDHI1 on the RZ/G3E SMARC EVK platform using gpio regulator for
> voltage switching.
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>

Thanks for your patch!

> --- a/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
> +++ b/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
> @@ -12,10 +12,40 @@
>  #include "rzg3e-smarc-som.dtsi"
>  #include "renesas-smarc2.dtsi"
>
> +/*
> + * To enable uSD card on SDIO_USD:
> + *
> + * Switch bank - SW_OPT_MUX-1 (SW_SDIO_M2E):
> + *     0 - SMARC SDIO signal is connected to uSD1
> + *     1 - SMARC SDIO signal is connected to M.2 Key E connector
> + */
> +
>  / {
>         model = "Renesas SMARC EVK version 2 based on r9a09g047e57";
>         compatible = "renesas,smarc2-evk", "renesas,rzg3e-smarcm",
>                      "renesas,r9a09g047e57", "renesas,r9a09g047";
> +
> +       usd_vdd_3p3v: regulator-usd-vdd-3p3v {
> +               compatible = "regulator-fixed";
> +               regulator-name = "fixed-3.3V";
> +               regulator-min-microvolt = <3300000>;
> +               regulator-max-microvolt = <3300000>;
> +               regulator-boot-on;
> +               regulator-always-on;
> +       };

Can't you just reuse reg_3p3v from rzg3e-smarc-som.dtsi?

> +
> +       vqmmc_sdhi1_ext: regulator-vqmmc-sdhi1-ext {
> +               compatible = "regulator-gpio";
> +
> +               regulator-name = "SDHI1 VccQ";
> +               regulator-min-microvolt = <1800000>;
> +               regulator-max-microvolt = <3300000>;
> +
> +               gpios = <&pinctrl RZG3E_GPIO(1, 5) GPIO_ACTIVE_HIGH>;

arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts:44.37-38 syntax error

Missing #include <dt-bindings/gpio/gpio.h>

> +
> +               gpios-states = <0>;
> +               states = <3300000 0>, <1800000 1>;
> +       };

Is there a specific reason why you are using an external regulator...

>  };
>
>  &pinctrl {
> @@ -23,9 +53,44 @@ scif_pins: scif {
>                 pins = "SCIF_TXD", "SCIF_RXD";
>                 renesas,output-impedance = <1>;
>         };
> +
> +       sd1-pwr-en {
> +               gpio-hog;
> +               gpios = <RZG3E_GPIO(1, 6) GPIO_ACTIVE_HIGH>;
> +               output-high;
> +               line-name = "sd1_pwr_en";
> +       };

... and external (fixed) power enable, instead of the internal regulator,
which uses the same two pins?

The rest LGTM.

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
Biju Das Jan. 28, 2025, 2:14 p.m. UTC | #3
Hi Geert,

Thanks for the feedback.

> -----Original Message-----
> From: Geert Uytterhoeven <geert@linux-m68k.org>
> Sent: 28 January 2025 14:05
> Subject: Re: [PATCH 7/7] arm64: dts: renesas: r9a09g047e57-smarc: Enable SDHI1
> 
> Hi Biju,
> 
> On Sun, 26 Jan 2025 at 14:46, Biju Das <biju.das.jz@bp.renesas.com> wrote:
> > Enable SDHI1 on the RZ/G3E SMARC EVK platform using gpio regulator for
> > voltage switching.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> 
> Thanks for your patch!
> 
> > --- a/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
> > +++ b/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
> > @@ -12,10 +12,40 @@
> >  #include "rzg3e-smarc-som.dtsi"
> >  #include "renesas-smarc2.dtsi"
> >
> > +/*
> > + * To enable uSD card on SDIO_USD:
> > + *
> > + * Switch bank - SW_OPT_MUX-1 (SW_SDIO_M2E):
> > + *     0 - SMARC SDIO signal is connected to uSD1
> > + *     1 - SMARC SDIO signal is connected to M.2 Key E connector
> > + */
> > +
> >  / {
> >         model = "Renesas SMARC EVK version 2 based on r9a09g047e57";
> >         compatible = "renesas,smarc2-evk", "renesas,rzg3e-smarcm",
> >                      "renesas,r9a09g047e57", "renesas,r9a09g047";
> > +
> > +       usd_vdd_3p3v: regulator-usd-vdd-3p3v {
> > +               compatible = "regulator-fixed";
> > +               regulator-name = "fixed-3.3V";
> > +               regulator-min-microvolt = <3300000>;
> > +               regulator-max-microvolt = <3300000>;
> > +               regulator-boot-on;
> > +               regulator-always-on;
> > +       };
> 
> Can't you just reuse reg_3p3v from rzg3e-smarc-som.dtsi?

OK.

> 
> > +
> > +       vqmmc_sdhi1_ext: regulator-vqmmc-sdhi1-ext {
> > +               compatible = "regulator-gpio";
> > +
> > +               regulator-name = "SDHI1 VccQ";
> > +               regulator-min-microvolt = <1800000>;
> > +               regulator-max-microvolt = <3300000>;
> > +
> > +               gpios = <&pinctrl RZG3E_GPIO(1, 5) GPIO_ACTIVE_HIGH>;
> 
> arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts:44.37-38 syntax error
> 
> Missing #include <dt-bindings/gpio/gpio.h>

Oops missed it. It was part of out of tree ethernet patch.
I will fix it.

> 
> > +
> > +               gpios-states = <0>;
> > +               states = <3300000 0>, <1800000 1>;
> > +       };
> 
> Is there a specific reason why you are using an external regulator...

I have tested both. I just want to give an example for user,
how to choose external regulator and also, previously I tested SDIO using
M.2 Key E connector(WLAN,BT) with RZ/G3E board testing software.
So, thought of using similar changes here in mainline. 

> 
> >  };
> >
> >  &pinctrl {
> > @@ -23,9 +53,44 @@ scif_pins: scif {
> >                 pins = "SCIF_TXD", "SCIF_RXD";
> >                 renesas,output-impedance = <1>;
> >         };
> > +
> > +       sd1-pwr-en {
> > +               gpio-hog;
> > +               gpios = <RZG3E_GPIO(1, 6) GPIO_ACTIVE_HIGH>;
> > +               output-high;
> > +               line-name = "sd1_pwr_en";
> > +       };
> 
> ... and external (fixed) power enable, instead of the internal regulator, which uses the same two
> pins?

Same as above.

Cheers,
Biju
Geert Uytterhoeven Jan. 28, 2025, 3:48 p.m. UTC | #4
Hi Biju,

On Sun, 26 Jan 2025 at 14:46, Biju Das <biju.das.jz@bp.renesas.com> wrote:
> Enable SDHI1 on the RZ/G3E SMARC EVK platform using gpio regulator for
> voltage switching.
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>

> --- a/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
> +++ b/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
> @@ -23,9 +53,44 @@ scif_pins: scif {
>                 pins = "SCIF_TXD", "SCIF_RXD";
>                 renesas,output-impedance = <1>;
>         };
> +
> +       sd1-pwr-en {

arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dtb: sd1-pwr-en:
$nodename:0: 'sd1-pwr-en' does not match
'^(hog-[0-9]+|.+-hog(-[0-9]+)?)$'
        from schema $id: http://devicetree.org/schemas/gpio/gpio-hog.yaml#

> +               gpio-hog;
> +               gpios = <RZG3E_GPIO(1, 6) GPIO_ACTIVE_HIGH>;
> +               output-high;
> +               line-name = "sd1_pwr_en";
> +       };

Gr{oetje,eeting}s,

                        Geert
Biju Das Jan. 29, 2025, 3:41 p.m. UTC | #5
Hi Geert,

Thanks for the feedback.

> -----Original Message-----
> From: Geert Uytterhoeven <geert@linux-m68k.org>
> Sent: 28 January 2025 15:49
> Subject: Re: [PATCH 7/7] arm64: dts: renesas: r9a09g047e57-smarc: Enable SDHI1
> 
> Hi Biju,
> 
> On Sun, 26 Jan 2025 at 14:46, Biju Das <biju.das.jz@bp.renesas.com> wrote:
> > Enable SDHI1 on the RZ/G3E SMARC EVK platform using gpio regulator for
> > voltage switching.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> 
> > --- a/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
> > +++ b/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
> > @@ -23,9 +53,44 @@ scif_pins: scif {
> >                 pins = "SCIF_TXD", "SCIF_RXD";
> >                 renesas,output-impedance = <1>;
> >         };
> > +
> > +       sd1-pwr-en {
> 
> arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dtb: sd1-pwr-en:
> $nodename:0: 'sd1-pwr-en' does not match '^(hog-[0-9]+|.+-hog(-[0-9]+)?)$'
>         from schema $id: http://devicetree.org/schemas/gpio/gpio-hog.yaml#

Oops. I ran a selective dtbs_check which ignored this warning. I have fixed this
Now.

Cheers,
Biju
diff mbox series

Patch

diff --git a/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts b/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
index c063d47e2952..0e3d4ff31285 100644
--- a/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
+++ b/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
@@ -12,10 +12,40 @@ 
 #include "rzg3e-smarc-som.dtsi"
 #include "renesas-smarc2.dtsi"
 
+/*
+ * To enable uSD card on SDIO_USD:
+ *
+ * Switch bank - SW_OPT_MUX-1 (SW_SDIO_M2E):
+ *	0 - SMARC SDIO signal is connected to uSD1
+ *	1 - SMARC SDIO signal is connected to M.2 Key E connector
+ */
+
 / {
 	model = "Renesas SMARC EVK version 2 based on r9a09g047e57";
 	compatible = "renesas,smarc2-evk", "renesas,rzg3e-smarcm",
 		     "renesas,r9a09g047e57", "renesas,r9a09g047";
+
+	usd_vdd_3p3v: regulator-usd-vdd-3p3v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-3.3V";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		regulator-boot-on;
+		regulator-always-on;
+	};
+
+	vqmmc_sdhi1_ext: regulator-vqmmc-sdhi1-ext {
+		compatible = "regulator-gpio";
+
+		regulator-name = "SDHI1 VccQ";
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <3300000>;
+
+		gpios = <&pinctrl RZG3E_GPIO(1, 5) GPIO_ACTIVE_HIGH>;
+
+		gpios-states = <0>;
+		states = <3300000 0>, <1800000 1>;
+	};
 };
 
 &pinctrl {
@@ -23,9 +53,44 @@  scif_pins: scif {
 		pins = "SCIF_TXD", "SCIF_RXD";
 		renesas,output-impedance = <1>;
 	};
+
+	sd1-pwr-en {
+		gpio-hog;
+		gpios = <RZG3E_GPIO(1, 6) GPIO_ACTIVE_HIGH>;
+		output-high;
+		line-name = "sd1_pwr_en";
+	};
+
+	sdhi1_pins: sd1 {
+		sd1-cd {
+			pinmux = <RZG3E_PORT_PINMUX(1, 4, 8)>; /* SD1CD */
+		};
+
+		sd1-data {
+			pinmux = <RZG3E_PORT_PINMUX(G, 2, 1)>, /* SD1DAT0 */
+				 <RZG3E_PORT_PINMUX(G, 3, 1)>, /* SD1DAT1 */
+				 <RZG3E_PORT_PINMUX(G, 4, 1)>, /* SD1DAT2 */
+				 <RZG3E_PORT_PINMUX(G, 5, 1)>; /* SD1DAT3 */
+		};
+
+		sd1-ctrl {
+			pinmux = <RZG3E_PORT_PINMUX(G, 0, 1)>, /* SD1CLK */
+				 <RZG3E_PORT_PINMUX(G, 1, 1)>; /* SD1CMD */
+		};
+	};
 };
 
 &scif0 {
 	pinctrl-0 = <&scif_pins>;
 	pinctrl-names = "default";
 };
+
+&sdhi1 {
+	pinctrl-0 = <&sdhi1_pins>;
+	pinctrl-1 = <&sdhi1_pins>;
+	pinctrl-names = "default", "state_uhs";
+
+	vmmc-supply = <&usd_vdd_3p3v>;
+	vqmmc-supply = <&vqmmc_sdhi1_ext>;
+	/delete-node/ vqmmc_regulator;
+};
diff --git a/arch/arm64/boot/dts/renesas/renesas-smarc2.dtsi b/arch/arm64/boot/dts/renesas/renesas-smarc2.dtsi
index e378d55e6e9b..ec79452393b0 100644
--- a/arch/arm64/boot/dts/renesas/renesas-smarc2.dtsi
+++ b/arch/arm64/boot/dts/renesas/renesas-smarc2.dtsi
@@ -16,9 +16,18 @@  chosen {
 
 	aliases {
 		serial3 = &scif0;
+		mmc1 = &sdhi1;
 	};
 };
 
 &scif0 {
 	status = "okay";
 };
+
+&sdhi1 {
+	bus-width = <4>;
+	sd-uhs-sdr50;
+	sd-uhs-sdr104;
+
+	status = "okay";
+};