Hello, guys!

I'm trying to make use of gpio-poweroff procedure. I'm trying to understand the consequences of the approach I've used.

Here's what I did

1) Added

power_ctrl: power_ctrl {
compatible = "gpio-poweroff";
gpios = <&pio 6 11 GPIO_ACTIVE_HIGH>;
force;
};

to arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-neo-plus2.dts

2) Recompiled the device tree blob and put it where it belongs

The gpio-poweroff's code got probed but failed due to `pm_poweroff_handler` being set to something. So I figured it out that it's set to `psci_sys_poweroff` in [drivers/firmware/psci.c](https://github.com/friendlyarm/linux/bl ... sci.c#L518).

3) I commented this line out

4) Rebooted with a new kernel and issued `poweroff` on command line

5) The GPIO was driven high as expected

6) The board is switched off by external circuitry

I'm very eager to know if this is an OK thing to do on an embedded system? It seems like I do something nasty. The only reasonable approach that comes to mind is to use some kind of chain of callbacks with GPIO poweroff handler's priority set to low. So that I could toggle GPIO and then use the PSCI logic to properly shutdown. But the RFC with this approach got rejected and nobody seems to be stepping in.

Another solution is to make an ugly hack in gpio-poweroff.c and save the old callback to a variable and call it after gpio toggled.

So what do you guys think?