raspberrypi / linux

Kernel source tree for Raspberry Pi-provided kernel builds. Issues unrelated to the linux kernel should be posted on the community forum at https://forums.raspberrypi.com/
Other
11.16k stars 5k forks source link

Any circumstances in which gpio-poweroff overlay partially works? #1802

Closed MrSurly closed 7 years ago

MrSurly commented 7 years ago

I've posted this over at the Adafruit forums where the gpio-poweroff overlay only partially works.

Using the Adafruit 4.4.27-v7+ kernel that's available for the PiTFT Plus. This enables framebuffer output to the PiTFT via SPI.

While using the Adafruit kernel, the gpio-poweroff overlay partially works. The line goes high while the device is on, but fails to go low on poweroff.

Using the stock Raspbian Jessie kernel (4.4.34-v7+), the gpio-poweroff overlay works correctly, with the same hardware.

Here's the relevant section from /boot/config.txt, which is the same for both.

dtoverlay=gpio-poweroff,gpiopin=6,active_low="y"

Both kernels have CONFIG_POWER_RESET=y and CONFIG_POWER_RESET_GPIO=y.

I have tried using other available GPIO pins, with the same results.

pelwell commented 7 years ago

Apart from the (harmless but unnecessary) quotes in active_low="y" that all looks fine. I'm not sure what you are expecting us to do - the gpio-poweroff code and overlay in the Adafruit kernel appear to be unmodified from the standard RPi versions, so something else must have broken it.

If I were debugging this I would first add some pr_err() calls to significant points in the gpio-poweroff driver and rebuild the kernel, then use a serial port to capture the kernel output (make sure there is no 'quiet' in cmdline.txt and include 'loglevel=8').

MrSurly commented 7 years ago

I'm not sure what you are expecting us to do - the gpio-poweroff code and overlay in the Adafruit kernel appear to be unmodified from the standard RPi versions, so something else must have broken it.

Was hoping something along the lines of "oh yeah, that version is broken," though searching issues didn't yield an answer. Your confirmation of "should work" is very helpful on it's own. Thank you.

MrSurly commented 7 years ago

Turns out that the rpi_power_switch module (written by Adafruit) prevents this from working correctly. I haven't dug into it too deeply, but I assume this module intercepts the shutdown. I'll raise an issue with Adafruit, even if it's just updating the docs to say "this breaks gpio-poweroff.

Thanks for your time.

pelwell commented 7 years ago

Yes - pm_power_off is a global pointer to a single power-off handling function, and both modules are competing for it.

MrSurly commented 7 years ago

Understood, thank you. I am (at best) a very amateur kernel hacker.