Boot the OS when a wakeup alarm rings
Background: some phones can activate the alarm even if they were turned "off". Some users expressed the wish to have this feature on the Librem 5: https://forums.puri.sm/t/will-alarm-clock-apps-be-able-to-wake-up-the-phone-when-its-off/4916/19
Cast:
- The SNVS Real-Time clock aka SVNS_HI RTC. It is able to tigger alarms that wake up the SoC when powered on (6.4.2.2.2 in i.MX 8M Dual/8M QuadLite/8M Quad Applications Processors Reference Manual). Minimal power state "is the lowest power on state for the SoC so IIRC it draws in the uA on nA range"
- The PMIC BD71837 which controls the SVNS domain
- The on-board, accurate RTC
- The kernel
Plot:
- The SVNS RTC was disabled already in https://source.puri.sm/Librem5/linux-next/commit/491f04c6d5039294a7f818f87b22caf49e32c541
- Editing the power state via PMIC is tricky, as exemplified by https://source.puri.sm/Librem5/linux-next/commit/232aba9abca61da4ce67f11f8dd7caf41f3bfd62
- The challenge is in making sure the correct RTC is being used:
You likely want to look into what happens when "rohm,reset-snvs-powered;" is in the pmic stanza. I think SNVS is enabled during powerdown right now so it would be more about re-enabling the SNVS RTC and getting it not to interfere with the RTC chip we have on board
IIRC the "interference" was that Linux was trying to use the SNVS RTC for clock while we wanted it to use the on-board one
- There is a light at the end of the tunnel:
I'm pretty sure the HW is capable it's will just be a matter of having the correct congiguration
- The OS would have to be appropriately notified, and run the alarm app right after boot