BPI-CM4 suspend and wakeup with GPIO

I’m working on a handheld device based on BPi CM4. Having a reliable suspend-to-rum is essential for the project. Unfortunately, I wasn’t able to get it to work with a default firmware (images listed here: Banana Pi BPI-CM4 Amlogic A311D computer module Kit | BananaPi Docs). The main issue at the moment is a lack of wake-up from the GPIO. The u-boot source code that I found is consistent with this issue, as GPIO wakeup just wasn’t fully implemented.

Maybe I’m looking at the wrong source? Banana Pi wiki led me to this: https://docs.u-boot.org/en/latest/board/amlogic/bananapi-cm4io.html And docs suggest to use GitHub - Dangku/amlogic-u-boot: u-boot for bananapi m5/m2pro, m2s, cm4 · GitHub (branch khadas-g12b-v2015.01-m2s). I compiled and flashed this U-Boot (with the intention to fix the GPIO wakeup code from pwr_ctrl.c), but it doesn’t work. The best I could get is this:

Load FIP HDR from SD, src: 0x00010200, des: 0x01700000, size: 0x00004000, part: 0
Load BL3X from SD, src: 0x0003c200, des: 0x0172c000, size: 0x000a4000, part: 0
BL33 CHK: 0x0000003a ADDR 01763b70
reset...

I looked at Armbian build tools. They take mainline U-Boot and pre-built FIP files. It works with BPi CM4, but no wakeup support, and I couldn’t find any suspend/wakeup-related code that I could edit.

The only way I got BPi CM4 + Armbian + suspend/wakeup is with a bootloader from Radxa Zero 2 (same A311D chip):

U-Boot latest-2023.07.02-7-ee55c65b-gee55c65b (Oct 23 2023 - 09:28:34 +0000) radxa-zero-2pro

One small problem: the wake-up GPIO on Zero2 is hardcoded to GPIOAO_3, and on the BPi CM4 it is used as TF_IOVDD_EN and not routed to any connector. I poke it with a needle to test.

So, I need some advice on which direction to take to get working suspend/wakeup with a modern Linux image. Ideally, with mainline U-Boot, but I’m not sure if it is possible.

Or maybe there is some undocumented GPIO/ADC/UART input that already works?