1 From f8d5316066987cfd355c2da083a411ff41515ed4 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 087/148] gpio-poweroff: Allow it to work on Raspberry Pi
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.
10 This patch introduces a "force" DT property that overrides that
11 behaviour, and also adds a DT overlay to enable and control it.
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.
18 arch/arm/boot/dts/overlays/Makefile | 1 +
19 arch/arm/boot/dts/overlays/README | 13 +++++++++
20 .../boot/dts/overlays/gpio-poweroff-overlay.dts | 34 ++++++++++++++++++++++
21 drivers/power/reset/gpio-poweroff.c | 4 ++-
22 4 files changed, 51 insertions(+), 1 deletion(-)
23 create mode 100644 arch/arm/boot/dts/overlays/gpio-poweroff-overlay.dts
25 --- a/arch/arm/boot/dts/overlays/Makefile
26 +++ b/arch/arm/boot/dts/overlays/Makefile
27 @@ -16,6 +16,7 @@ dtb-$(RPI_DT_OVERLAYS) += ads7846-overla
28 dtb-$(RPI_DT_OVERLAYS) += bmp085_i2c-sensor-overlay.dtb
29 dtb-$(RPI_DT_OVERLAYS) += dht11-overlay.dtb
30 dtb-$(RPI_DT_OVERLAYS) += enc28j60-overlay.dtb
31 +dtb-$(RPI_DT_OVERLAYS) += gpio-poweroff-overlay.dtb
32 dtb-$(RPI_DT_OVERLAYS) += hifiberry-amp-overlay.dtb
33 dtb-$(RPI_DT_OVERLAYS) += hifiberry-dac-overlay.dtb
34 dtb-$(RPI_DT_OVERLAYS) += hifiberry-dacplus-overlay.dtb
35 --- a/arch/arm/boot/dts/overlays/README
36 +++ b/arch/arm/boot/dts/overlays/README
37 @@ -192,6 +192,19 @@ Params: int_pin GPIO us
38 speed SPI bus speed (default 12000000)
42 +Info: Drives a GPIO high or low on reboot
43 +Load: gpio-poweroff,<param>=<val>
44 +Params: gpiopin GPIO for signalling (default 26)
46 + active_low Set if the power control device requires a
47 + high->low transition to trigger a power-down.
48 + Note that this will require the support of a
49 + custom dt-blob.bin to prevent a power-down
50 + during the boot process, and that a reboot
51 + will also cause the pin to go low.
55 Info: Configures the HifiBerry Amp and Amp+ audio cards
56 Load: dtoverlay=hifiberry-amp
58 +++ b/arch/arm/boot/dts/overlays/gpio-poweroff-overlay.dts
60 +// Definitions for gpio-poweroff module
65 + compatible = "brcm,bcm2708";
70 + power_ctrl: power_ctrl {
71 + compatible = "gpio-poweroff";
72 + gpios = <&gpio 26 0>;
81 + power_ctrl_pins: power_ctrl_pins {
83 + brcm,function = <1>; // out
89 + gpiopin = <&power_ctrl>,"gpios:4",
90 + <&power_ctrl_pins>,"brcm,pins:0";
91 + active_low = <&power_ctrl>,"gpios:8";
94 --- a/drivers/power/reset/gpio-poweroff.c
95 +++ b/drivers/power/reset/gpio-poweroff.c
96 @@ -48,9 +48,11 @@ static void gpio_poweroff_do_poweroff(vo
97 static int gpio_poweroff_probe(struct platform_device *pdev)
100 + bool force = false;
102 /* If a pm_power_off function has already been added, leave it alone */
103 - if (pm_power_off != NULL) {
104 + force = of_property_read_bool(pdev->dev.of_node, "force");
105 + if (!force && (pm_power_off != NULL)) {
107 "%s: pm_power_off function already registered",