0080-gpio-poweroff-Allow-it-to-work-on-Raspberry-Pi.patch 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. From 1ad569f9f83546073951ea911702cf3cb18affe3 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] gpio-poweroff: Allow it to work on Raspberry Pi
  5. The Raspberry Pi firmware manages the power-down and reboot
  6. process. To do this it installs a pm_power_off handler, causing
  7. the gpio-poweroff module to abort the probe function.
  8. This patch introduces a "force" DT property that overrides that
  9. behaviour, and also adds a DT overlay to enable and control it.
  10. Note that running in an active-low configuration (DT parameter
  11. "active_low") requires a custom dt-blob.bin and probably won't
  12. allow a reboot without switching off, so an external inversion
  13. of the trigger signal may be preferable.
  14. ---
  15. drivers/power/reset/gpio-poweroff.c | 4 +++-
  16. 1 file changed, 3 insertions(+), 1 deletion(-)
  17. --- a/drivers/power/reset/gpio-poweroff.c
  18. +++ b/drivers/power/reset/gpio-poweroff.c
  19. @@ -49,9 +49,11 @@ static int gpio_poweroff_probe(struct pl
  20. {
  21. bool input = false;
  22. enum gpiod_flags flags;
  23. + bool force = false;
  24. /* If a pm_power_off function has already been added, leave it alone */
  25. - if (pm_power_off != NULL) {
  26. + force = of_property_read_bool(pdev->dev.of_node, "force");
  27. + if (!force && (pm_power_off != NULL)) {
  28. dev_err(&pdev->dev,
  29. "%s: pm_power_off function already registered",
  30. __func__);