linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [Discussion] how to implement external power down for ARM
Date: Thu, 30 Apr 2015 11:19:41 +0200	[thread overview]
Message-ID: <2214666.Rc6ZJbs8c0@wuerfel> (raw)
In-Reply-To: <CAFEAcA_VSkPPhmMmn+M+AoX5wjB0r66xq0ygMLSfR7zg0yiXnw@mail.gmail.com>

On Thursday 30 April 2015 10:08:05 Peter Maydell wrote:
> On 30 April 2015 at 09:03, Arnd Bergmann <arnd@arndb.de> wrote:
> > On Thursday 30 April 2015 09:03:22 Shannon Zhao wrote:
> >>
> >> I am looking at adding support for external power down and reboot to
> >> ARM VMs.  With ACPI this is fairly straight forward and requires only
> >> adding a GPIO controller to the virt machine model and extending ACPI
> >> appropriately (see code here [1]). In addition Linaro LEG also have
> >> done a test that uses GPIO as power button to shutdown OS on fast model
> >> (see detail here [2]).
> >>
> >> However, we would like for this to work in systems that do not use
> >> ACPI as well. Adding a GPIO controller will still work, but we would
> >> need a generic way to tell Linux how to handle the GPIO events without
> >> adding any board-specific code to the VIRT platform. And what guest
> >> kernel driver do we need? Do we need another user-level daemon like acpid?
> >>
> >> Note that external shutdown can also be accomplished using the qemu
> >> guest agent [3], but maybe this is not a sufficiently stable approach.
> >>
> >> Any input on the approach to take here is very welcome.
> >
> > I would expect drivers/power/reset/gpio-poweroff.c to work in an identical
> > way with ACPI and DT, once you have added an ACPI binding for it.
> 
> Looking at Documentation/devicetree/bindings/gpio/gpio-poweroff.txt
> that appears to be for "let the guest kernel turn off the system
> from the inside by toggling a GPIO line". What we want is the
> opposite: the external system (QEMU, in this case) toggles a GPIO
> line in order to request the guest kernel to do a clean shutdown
> or reboot. Or have I misunderstood what gpio-poweroff can do?
> 
> [I would expect the shutdown itself to be done via PSCI.]

Ok, my mistake. What we need then is a "gpio-keys" device that has
a single gpio with a button that emits KEY_POWER (or a second
one if you also want KEY_RESTART).

An example from arch/arm/boot/dts/kirkwood-dnskw.dtsi would be

        gpio_keys {
                compatible = "gpio-keys";
                #address-cells = <1>;
                #size-cells = <0>;
                pinctrl-0 = <&pmx_button_power &pmx_button_unmount
                             &pmx_button_reset>;
                pinctrl-names = "default";

                button at 1 {
                        label = "Power button";
                        linux,code = <KEY_POWER>;
                        gpios = <&gpio1 2 GPIO_ACTIVE_LOW>;
                };
                button at 2 {
                        label = "USB unmount button";
                        linux,code = <KEY_EJECTCD>;
                        gpios = <&gpio1 15 GPIO_ACTIVE_LOW>;
                };
                button at 3 {
                        label = "Reset button";
                        linux,code = <KEY_RESTART>;
                        gpios = <&gpio1 16 GPIO_ACTIVE_LOW>;
                };
        };

This also includes pinctrl configuration, which you can skip on
qemu, if you assume that the gpio is already configured in the
right way.

>From the user space side, this should work just like the ACPI
button stuff that emits KEY_POWER or KEY_SLEEP on its
input-device.

	Arnd

  reply	other threads:[~2015-04-30  9:19 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-30  1:03 [Discussion] how to implement external power down for ARM Shannon Zhao
2015-04-30  8:03 ` Arnd Bergmann
2015-04-30  9:08   ` Peter Maydell
2015-04-30  9:19     ` Arnd Bergmann [this message]
2015-04-30  9:29     ` Mark Rutland
2015-04-30  9:56       ` Arnd Bergmann
2015-05-04  2:09         ` Shannon Zhao
2015-05-04 15:49           ` Arnd Bergmann
2015-05-05  2:57             ` Joel Stanley
2015-05-05  9:53               ` Arnd Bergmann
2015-05-05 10:51                 ` Christoffer Dall
2015-05-05 10:55                   ` Arnd Bergmann
2015-05-05 11:13                     ` Shannon Zhao
2015-05-06  6:56                       ` Shannon Zhao
2015-05-06  7:29                         ` Arnd Bergmann
2015-05-06  8:19                           ` Shannon Zhao
2015-05-06  8:37                             ` Arnd Bergmann
2015-05-06  8:41                               ` Shannon Zhao
2015-05-06 10:14                             ` Christoffer Dall
2015-05-07  2:39                           ` Shannon Zhao
2015-05-07  8:55                             ` Arnd Bergmann
2015-05-07  9:18                               ` Shannon Zhao
2015-05-07  9:43                                 ` Arnd Bergmann
2015-05-07 12:10                                   ` Shannon Zhao
2015-05-07 12:12                                     ` Peter Maydell
2015-05-07 12:18                                       ` Shannon Zhao
2015-05-07 12:34                                         ` Peter Maydell
2015-05-07 12:48                                           ` Arnd Bergmann
2015-05-07 13:02                                           ` Shannon Zhao
2015-04-30 13:38       ` Hanjun Guo
2015-05-04  1:55         ` Shannon Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2214666.Rc6ZJbs8c0@wuerfel \
    --to=arnd@arndb.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).