brcm2708: update to latest patches from the RPi foundation
[openwrt/staging/lynxis.git] / target / linux / brcm2708 / patches-4.19 / 950-0130-Add-ability-to-export-gpio-used-by-gpio-poweroff.patch
1 From 3e25c39320a501e57a5e232f6e98740357bd5bc6 Mon Sep 17 00:00:00 2001
2 From: Nick Bulleid <nedbulleid@fastmail.com>
3 Date: Thu, 10 May 2018 21:57:02 +0100
4 Subject: [PATCH 130/725] Add ability to export gpio used by gpio-poweroff
5
6 Signed-off-by: Nick Bulleid <nedbulleid@fastmail.com>
7
8 Added export feature to gpio-poweroff documentation
9
10 Signed-off-by: Nick Bulleid <nedbulleid@fastmail.com>
11 ---
12 .../devicetree/bindings/power/reset/gpio-poweroff.txt | 1 +
13 drivers/power/reset/gpio-poweroff.c | 9 +++++++++
14 2 files changed, 10 insertions(+)
15
16 --- a/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt
17 +++ b/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt
18 @@ -29,6 +29,7 @@ Optional properties:
19 inactive state.
20 - timeout-ms: Time to wait before asserting a WARN_ON(1). If nothing is
21 specified, 3000 ms is used.
22 +- export : Export the GPIO line to the sysfs system
23
24 Examples:
25
26 --- a/drivers/power/reset/gpio-poweroff.c
27 +++ b/drivers/power/reset/gpio-poweroff.c
28 @@ -52,6 +52,7 @@ static int gpio_poweroff_probe(struct pl
29 bool input = false;
30 enum gpiod_flags flags;
31 bool force = false;
32 + bool export = false;
33
34 /* If a pm_power_off function has already been added, leave it alone */
35 force = of_property_read_bool(pdev->dev.of_node, "force");
36 @@ -74,6 +75,12 @@ static int gpio_poweroff_probe(struct pl
37 if (IS_ERR(reset_gpio))
38 return PTR_ERR(reset_gpio);
39
40 + export = of_property_read_bool(pdev->dev.of_node, "export");
41 + if (export) {
42 + gpiod_export(reset_gpio, false);
43 + gpiod_export_link(&pdev->dev, "poweroff-gpio", reset_gpio);
44 + }
45 +
46 pm_power_off = &gpio_poweroff_do_poweroff;
47 return 0;
48 }
49 @@ -83,6 +90,8 @@ static int gpio_poweroff_remove(struct p
50 if (pm_power_off == &gpio_poweroff_do_poweroff)
51 pm_power_off = NULL;
52
53 + gpiod_unexport(reset_gpio);
54 +
55 return 0;
56 }
57