brcm2708: add linux 4.1 support
[openwrt/svn-archive/archive.git] / target / linux / brcm2708 / patches-4.1 / 0087-gpio-poweroff-Allow-it-to-work-on-Raspberry-Pi.patch
1 From 842fe412d512dabb76d169395086b6337150015a 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/121] 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 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
24
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)
39
40
41 +Name: gpio-poweroff
42 +Info: Drives a GPIO high or low on reboot
43 +Load: gpio-poweroff,<param>=<val>
44 +Params: gpiopin GPIO for signalling (default 26)
45 +
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.
52 +
53 +
54 Name: hifiberry-amp
55 Info: Configures the HifiBerry Amp and Amp+ audio cards
56 Load: dtoverlay=hifiberry-amp
57 --- /dev/null
58 +++ b/arch/arm/boot/dts/overlays/gpio-poweroff-overlay.dts
59 @@ -0,0 +1,34 @@
60 +// Definitions for gpio-poweroff module
61 +/dts-v1/;
62 +/plugin/;
63 +
64 +/ {
65 + compatible = "brcm,bcm2708";
66 +
67 + fragment@0 {
68 + target-path = "/";
69 + __overlay__ {
70 + power_ctrl: power_ctrl {
71 + compatible = "gpio-poweroff";
72 + gpios = <&gpio 26 0>;
73 + force;
74 + };
75 + };
76 + };
77 +
78 + fragment@1 {
79 + target = <&gpio>;
80 + __overlay__ {
81 + power_ctrl_pins: power_ctrl_pins {
82 + brcm,pins = <26>;
83 + brcm,function = <1>; // out
84 + };
85 + };
86 + };
87 +
88 + __overrides__ {
89 + gpiopin = <&power_ctrl>,"gpios:4",
90 + <&power_ctrl_pins>,"brcm,pins:0";
91 + active_low = <&power_ctrl>,"gpios:8";
92 + };
93 +};
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)
98 {
99 bool input = false;
100 + bool force = false;
101
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)) {
106 dev_err(&pdev->dev,
107 "%s: pm_power_off function already registered",
108 __func__);