In my setup, Duo256m is powered from a battery and sleeps most of the time (via linux system sleep) to save energy, then wakeups from PIR sensor signal. The sensor pin is configured as a wakeup source in the device tree.
The wakeup part works perfectly well when using s2idle sleep state, as it is fully handled by os, but fails with s2ram.
Could you please suggest possible options to implement the wakeup from the deep sleep? According to the datasheet (ch 6.4.6.), the RTC subsystem is powered on in this sleep state and can be configured to wakeup system not only using alarm clock, but also using powered gpio as wakeup source, but it lacks details
Ok, let me share my findings. So, my aim is to wake up from deep sleep ( s2ram) via a sensor signal.
As the datasheet is somewhat unclear, the rest is the result of trial and error, I really cannot fully explain why it works that way Your results might vary.
The datasheet mentions RTC_EN_PWR_WAKEUP rtc control register, which can be used to specify wakeup sources. The only applicable value seems to be REQ_WAKEUP ( which probably means “request wakeup”) . So let’s set it
devmem 0x050260bc 32 0x1440
Then there is a register RTC_EN_WAKEUP_REQ to enable this “wakeup request”. Let’s enable it
devmem 0x05026120 32 0x1
Now there is a way to specify which peripheral device can generate a wakeup request via rtcsys_wkup_ctrl register. I want to enable gpio
devmem 0x05025038 32 0x80fd
Next, there is rtcsys_rtc_wkup_ctrl register, which probably somehow translates the settings from step 3 to rtc core (?)
devmem 0x050250a8 32 0xFF00FD
As a result, the board wakes up from mem sleep, but not only from the sensor signal. Probably, other powered gpio pins generate interrupts too. Next I will try to configure interrupt settings for them to see if it helps.