Discussion:
AllWinner H5 - Orange Pi PC 2, power button for ACPI
(too old to reply)
Menion
2017-04-22 07:40:18 UTC
Permalink
Hi all
I'm running Ubuntu Xenial from Armbian, running a WIP version of Mainline
Kernel 4.10.0 on an Orange PI PC 2.
I am trying to get the power button usable by Ubuntu via ACPI (or something
else)
First of all, acpi_listen doesn't show any event when I press the power
button, but if I look at /proc/interrupts I see that this interrupt source,
increases on CPU0 (by 2) when I press the button:

32: 5 0 0 0 sunxi_pio_edge 3 Edge sw4

So basically the button is working as GPIO and interrupt source in Linux,
but apparently it miss of something for generating the acpi event
Can it be some bindings in the DTS? If so, is there any guidance to set it?
Bye
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
i***@aosc.io
2017-04-22 12:07:50 UTC
Permalink
在 2017-04-22 15:40,Menion 写道:
Post by Menion
Hi all
I'm running Ubuntu Xenial from Armbian, running a WIP version of
Mainline Kernel 4.10.0 on an Orange PI PC 2.
I am trying to get the power button usable by Ubuntu via ACPI (or
something else)
First of all, acpi_listen doesn't show any event when I press the
power button, but if I look at /proc/interrupts I see that this
32: 5 0 0 0 sunxi_pio_edge 3 Edge sw4
So basically the button is working as GPIO and interrupt source in
Linux, but apparently it miss of something for generating the acpi
event
Can it be some bindings in the DTS? If so, is there any guidance to set it?
There's no ACPI on Allwinner ARM platforms (except Windows 10 IoT).

I suggest you run evtest command to investigate more about the power
buton.
Post by Menion
Bye
--
You received this message because you are subscribed to the Google
Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Menion
2017-04-22 12:34:36 UTC
Permalink
That's wrong. I am currently running a Bananapi (A20) with power and reset buttons perfectly working and sending acpi events. Also H3 works (Orange pi pc 1)
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Icenowy Zheng
2017-04-23 04:55:43 UTC
Permalink
Post by Menion
That's wrong. I am currently running a Bananapi (A20) with power and
reset buttons perfectly working and sending acpi events. Also H3 works
(Orange pi pc 1)
Banana Pi has PMIC, but Orange Pi PC2 doesn't.

In the default mainline kernel, the power key on OPi PC2 is not mapped to the KEY_POWER, but a BTN_x code.

You may want to alter the device tree for this (The key is a GPIO-connected one, and used the gpio-keys dt binding)
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Menion
2017-04-23 08:29:40 UTC
Permalink
Hi
I have tried to monitor the button via evtest, but nothing is detected
Can you provide guidance on how modify dts for making this switch
generating a key_power event?
Bye
Post by Icenowy Zheng
Post by Menion
That's wrong. I am currently running a Bananapi (A20) with power and
reset buttons perfectly working and sending acpi events. Also H3 works
(Orange pi pc 1)
Banana Pi has PMIC, but Orange Pi PC2 doesn't.
In the default mainline kernel, the power key on OPi PC2 is not mapped to
the KEY_POWER, but a BTN_x code.
You may want to alter the device tree for this (The key is a
GPIO-connected one, and used the gpio-keys dt binding)
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Menion
2017-04-28 09:24:05 UTC
Permalink
Hello again
I have modified the sun50i-h5-orangepi-pc2.dts

r_gpio_keys {
compatible = "gpio-keys";

sw4 {
label = "sw4";
--- linux,code = <0x100>;
+++ linux,code = <0x74>;
gpios = <0x24 0x0 0x3 0x1>;
};
};

Now, 5sec long press of the power button generate a button/power ACPI event
that can be used with acpid to trigger a power off.
Does anyone know why this gpio, that on this specific HW, is used (or shall
be used) for power down, is bind to BTN_0?
Post by Menion
Hi
I have tried to monitor the button via evtest, but nothing is detected
Can you provide guidance on how modify dts for making this switch
generating a key_power event?
Bye
Post by Icenowy Zheng
Post by Menion
That's wrong. I am currently running a Bananapi (A20) with power and
reset buttons perfectly working and sending acpi events. Also H3 works
(Orange pi pc 1)
Banana Pi has PMIC, but Orange Pi PC2 doesn't.
In the default mainline kernel, the power key on OPi PC2 is not mapped to
the KEY_POWER, but a BTN_x code.
You may want to alter the device tree for this (The key is a
GPIO-connected one, and used the gpio-keys dt binding)
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Michal Suchanek
2017-04-28 09:37:32 UTC
Permalink
Post by Menion
Hello again
I have modified the sun50i-h5-orangepi-pc2.dts
r_gpio_keys {
compatible = "gpio-keys";
sw4 {
label = "sw4";
--- linux,code = <0x100>;
+++ linux,code = <0x74>;
gpios = <0x24 0x0 0x3 0x1>;
};
};
Now, 5sec long press of the power button generate a button/power ACPI event
that can be used with acpid to trigger a power off.
Does anyone know why this gpio, that on this specific HW, is used (or shall
be used) for power down, is bind to BTN_0?
Because it's a bug.

Just send a patch - there is SubmittingPatches somewhere under
Documentation directory in Linux kernel tree in case you wonder how to
do it.

Thanks

Michal
Post by Menion
Post by Menion
Hi
I have tried to monitor the button via evtest, but nothing is detected
Can you provide guidance on how modify dts for making this switch
generating a key_power event?
Bye
Post by Icenowy Zheng
Post by Menion
That's wrong. I am currently running a Bananapi (A20) with power and
reset buttons perfectly working and sending acpi events. Also H3 works
(Orange pi pc 1)
Banana Pi has PMIC, but Orange Pi PC2 doesn't.
In the default mainline kernel, the power key on OPi PC2 is not mapped to
the KEY_POWER, but a BTN_x code.
You may want to alter the device tree for this (The key is a
GPIO-connected one, and used the gpio-keys dt binding)
--
You received this message because you are subscribed to the Google Groups
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Chen-Yu Tsai
2017-04-28 09:44:03 UTC
Permalink
Post by Menion
Hello again
I have modified the sun50i-h5-orangepi-pc2.dts
r_gpio_keys {
compatible = "gpio-keys";
sw4 {
label = "sw4";
--- linux,code = <0x100>;
+++ linux,code = <0x74>;
gpios = <0x24 0x0 0x3 0x1>;
};
};
Now, 5sec long press of the power button generate a button/power ACPI event
that can be used with acpid to trigger a power off.
Does anyone know why this gpio, that on this specific HW, is used (or shall
be used) for power down, is bind to BTN_0?
IIRC this was done on purpose. The button is a simple GPIO trigger.
It does not have the specific function of a power button, like bringing
it back on, or forceful shutdown.

ChenYu
Post by Menion
Post by Menion
Hi
I have tried to monitor the button via evtest, but nothing is detected
Can you provide guidance on how modify dts for making this switch
generating a key_power event?
Bye
Post by Icenowy Zheng
Post by Menion
That's wrong. I am currently running a Bananapi (A20) with power and
reset buttons perfectly working and sending acpi events. Also H3 works
(Orange pi pc 1)
Banana Pi has PMIC, but Orange Pi PC2 doesn't.
In the default mainline kernel, the power key on OPi PC2 is not mapped to
the KEY_POWER, but a BTN_x code.
You may want to alter the device tree for this (The key is a
GPIO-connected one, and used the gpio-keys dt binding)
--
You received this message because you are subscribed to the Google Groups
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Menion
2017-04-28 09:48:33 UTC
Permalink
Yes, but board-wise, apart that this button is labeled as power button, it
is the only way to gracefull shutdown the board, without having to access
the linux terminal somehow.
Force shutdown and restart can be achieved by unplug/plug the power supply.
I see only pro, but I have a limited view of course, to map this button to
KEY_POWER instead of BTN_0, from an usability perspective
Bye
Post by Chen-Yu Tsai
IIRC this was done on purpose. The button is a simple GPIO trigger.
It does not have the specific function of a power button, like bringing
it back on, or forceful shutdown.
ChenYu
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Icenowy Zheng
2017-04-28 11:41:51 UTC
Permalink
Post by Menion
Yes, but board-wise, apart that this button is labeled as power button, it
is the only way to gracefull shutdown the board, without having to access
the linux terminal somehow.
Force shutdown and restart can be achieved by unplug/plug the power supply.
I see only pro, but I have a limited view of course, to map this button to
KEY_POWER instead of BTN_0, from an usability perspective
In fact if you like you can bind it to anything, including KEY_POWER.

Just modify the DT ;-)

If you do not want to modify dt every time you upgrade it, consider usr "fdt" command in u-boot to update it on-the-fly.
Post by Menion
Bye
Il giorno venerdì 28 aprile 2017 11:44:29 UTC+2, Chen-Yu Tsai ha
Post by Chen-Yu Tsai
IIRC this was done on purpose. The button is a simple GPIO trigger.
It does not have the specific function of a power button, like
bringing
Post by Chen-Yu Tsai
it back on, or forceful shutdown.
ChenYu
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...