diff mbox series

ARM: dts: sun8i-h2-plus-bananapi-m2-zero: add gpio-poweroff to DT

Message ID 20201123161041.2304766-1-michael@fossekall.de (mailing list archive)
State New, archived
Headers show
Series ARM: dts: sun8i-h2-plus-bananapi-m2-zero: add gpio-poweroff to DT | expand

Commit Message

Michael Klein Nov. 23, 2020, 4:10 p.m. UTC
Add gpio-poweroff node to allow the board to power itself off after
shutdown by disabling the SYSTEM and CPUX regulators (U5 resp. U6).
The RST button can be used to restart the board.

Signed-off-by: Michael Klein <michael@fossekall.de>
---
 arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Samuel Holland Nov. 24, 2020, 4:14 a.m. UTC | #1
On 11/23/20 10:10 AM, Michael Klein wrote:
> Add gpio-poweroff node to allow the board to power itself off after
> shutdown by disabling the SYSTEM and CPUX regulators (U5 resp. U6).
> The RST button can be used to restart the board.

The PSCI client will override this driver once the PSCI implementation
is upgraded to v0.2 or newer functions. So having this around should
cause no compatibility issues (although it would print an error in dmesg
at that point). This seems like a reasonable thing to do for the other
H2+/H3 boards that use a similar regulator layout.

Reviewed-by: Samuel Holland <samuel@sholland.org>

> Signed-off-by: Michael Klein <michael@fossekall.de>
> ---
>  arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts b/arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts
> index 4c6704e4c57e..76e79e6db733 100644
> --- a/arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts
> +++ b/arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts
> @@ -46,6 +46,11 @@ sw4 {
>  		};
>  	};
>  
> +	gpio_poweroff {
> +		compatible = "gpio-poweroff";
> +		gpios = <&r_pio 0 8 GPIO_ACTIVE_LOW>; /* PL8 */
> +	};
> +
>  	reg_vdd_cpux: vdd-cpux-regulator {
>  		compatible = "regulator-gpio";
>  		regulator-name = "vdd-cpux";
>
Chen-Yu Tsai Nov. 24, 2020, 4:41 a.m. UTC | #2
On Tue, Nov 24, 2020 at 12:14 PM Samuel Holland <samuel@sholland.org> wrote:
>
> On 11/23/20 10:10 AM, Michael Klein wrote:
> > Add gpio-poweroff node to allow the board to power itself off after
> > shutdown by disabling the SYSTEM and CPUX regulators (U5 resp. U6).
> > The RST button can be used to restart the board.
>
> The PSCI client will override this driver once the PSCI implementation
> is upgraded to v0.2 or newer functions. So having this around should
> cause no compatibility issues (although it would print an error in dmesg
> at that point). This seems like a reasonable thing to do for the other
> H2+/H3 boards that use a similar regulator layout.

I wonder if this (gpio-poweroff) works if those regulators are also in the DT?

> Reviewed-by: Samuel Holland <samuel@sholland.org>
>
> > Signed-off-by: Michael Klein <michael@fossekall.de>
> > ---
> >  arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts b/arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts
> > index 4c6704e4c57e..76e79e6db733 100644
> > --- a/arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts
> > +++ b/arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts
> > @@ -46,6 +46,11 @@ sw4 {
> >               };
> >       };
> >
> > +     gpio_poweroff {
> > +             compatible = "gpio-poweroff";
> > +             gpios = <&r_pio 0 8 GPIO_ACTIVE_LOW>; /* PL8 */
> > +     };
> > +
> >       reg_vdd_cpux: vdd-cpux-regulator {
> >               compatible = "regulator-gpio";
> >               regulator-name = "vdd-cpux";
> >
>
Maxime Ripard Nov. 24, 2020, 1:19 p.m. UTC | #3
On Mon, Nov 23, 2020 at 05:10:41PM +0100, Michael Klein wrote:
> Add gpio-poweroff node to allow the board to power itself off after
> shutdown by disabling the SYSTEM and CPUX regulators (U5 resp. U6).
> The RST button can be used to restart the board.
> 
> Signed-off-by: Michael Klein <michael@fossekall.de>
> ---
>  arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts b/arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts
> index 4c6704e4c57e..76e79e6db733 100644
> --- a/arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts
> +++ b/arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts
> @@ -46,6 +46,11 @@ sw4 {
>  		};
>  	};
>  
> +	gpio_poweroff {

DT nodes are not supposed to have an underscore in their name. The name
should also be the class of the "device", so I guess we can simply use
poweroff here?

Maxime
Maxime Ripard Nov. 24, 2020, 1:21 p.m. UTC | #4
On Tue, Nov 24, 2020 at 12:41:37PM +0800, Chen-Yu Tsai wrote:
> On Tue, Nov 24, 2020 at 12:14 PM Samuel Holland <samuel@sholland.org> wrote:
> >
> > On 11/23/20 10:10 AM, Michael Klein wrote:
> > > Add gpio-poweroff node to allow the board to power itself off after
> > > shutdown by disabling the SYSTEM and CPUX regulators (U5 resp. U6).
> > > The RST button can be used to restart the board.
> >
> > The PSCI client will override this driver once the PSCI implementation
> > is upgraded to v0.2 or newer functions. So having this around should
> > cause no compatibility issues (although it would print an error in dmesg
> > at that point). This seems like a reasonable thing to do for the other
> > H2+/H3 boards that use a similar regulator layout.
> 
> I wonder if this (gpio-poweroff) works if those regulators are also in the DT?

It's probably not going to probe at all, since both would claim the
exclusive usage of the GPIO?

I guess we should model this properly using the regulator framework, and
regulator_force_disable allows to bypass any usage count

Maxime
diff mbox series

Patch

diff --git a/arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts b/arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts
index 4c6704e4c57e..76e79e6db733 100644
--- a/arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts
+++ b/arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts
@@ -46,6 +46,11 @@  sw4 {
 		};
 	};
 
+	gpio_poweroff {
+		compatible = "gpio-poweroff";
+		gpios = <&r_pio 0 8 GPIO_ACTIVE_LOW>; /* PL8 */
+	};
+
 	reg_vdd_cpux: vdd-cpux-regulator {
 		compatible = "regulator-gpio";
 		regulator-name = "vdd-cpux";