72b7697de886b6ab4a7ab47008874a0fd8fff65e
[openwrt.git] / target / linux / brcm2708 / patches-4.4 / 0081-gpio-poweroff-Allow-it-to-work-on-Raspberry-Pi.patch
1 From 5a7fddeb5dfd0dd291363dcab556006a02297d13 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Thu, 25 Jun 2015 12:16:11 +0100
4 Subject: [PATCH 081/127] gpio-poweroff: Allow it to work on Raspberry Pi
5
6 The Raspberry Pi firmware manages the power-down and reboot
7 process. To do this it installs a pm_power_off handler, causing
8 the gpio-poweroff module to abort the probe function.
9
10 This patch introduces a "force" DT property that overrides that
11 behaviour, and also adds a DT overlay to enable and control it.
12
13 Note that running in an active-low configuration (DT parameter
14 "active_low") requires a custom dt-blob.bin and probably won't
15 allow a reboot without switching off, so an external inversion
16 of the trigger signal may be preferable.
17 ---
18  drivers/power/reset/gpio-poweroff.c | 4 +++-
19  1 file changed, 3 insertions(+), 1 deletion(-)
20
21 --- a/drivers/power/reset/gpio-poweroff.c
22 +++ b/drivers/power/reset/gpio-poweroff.c
23 @@ -49,9 +49,11 @@ static int gpio_poweroff_probe(struct pl
24  {
25         bool input = false;
26         enum gpiod_flags flags;
27 +       bool force = false;
28  
29         /* If a pm_power_off function has already been added, leave it alone */
30 -       if (pm_power_off != NULL) {
31 +       force = of_property_read_bool(pdev->dev.of_node, "force");
32 +       if (!force && (pm_power_off != NULL)) {
33                 dev_err(&pdev->dev,
34                         "%s: pm_power_off function already registered",
35                        __func__);