imx6ul: power-up using the RTC
guy.shapiro at mobi-wize.com
Wed Jan 18 06:49:11 PST 2017
I'm trying to use the low power RTC of the i.MX6UL to start from
I started by hopefully running:
# echo +30 > /sys/class/rtc/rtc0/wakealarm && shutdown -h now
The system was powered down, but it didn't come up after 30 seconds as
So I dug into the datasheet and the source...
To activate the power on alarm, the flags SRTC_ENV, LPTA_EN and LPWUI_EN
on the SNVS_LP Control register (LPCR) should be asserted. The wakeup
time should be written to the SNVS_LP Time alarm register (LPTA). The
code that does this is on drivers/rtc/rtc-snvs.c:snvs_rtc_set_alarm().
The first problem I found was with the use of the syscon-poweroff
driver. The "Turn off System Power" flag is part of the same register
(LPCR). The current code of syscon-poweroff set the register to the
"mask" property from the device tree on power off, overriding all the
After setting the "mask" property on the device tree to 0x6b instead of
0x60 (asserting the mentioned bits), the system do power up on timer, as
However, I didn't like the idea of keeping those flags on even when no
one set the alarm.
As a quick test, I modified the syscon-poweroff driver to ignore the
bits that are not on the mask:
diff --git a/drivers/power/reset/syscon-poweroff.c
index b683383..a5da02b 100644
@@ -33,7 +33,7 @@ static u32 mask;
static void syscon_poweroff(void)
/* Issue the poweroff */
- regmap_write(map, offset, mask);
+ regmap_update_bits(map, offset, mask, mask);
After applying this fix, the wake up alarm didn't work. Strangely, when
I added some debug prints to investigate the case, it worked again
(sometimes... depends on the exact places I add the prints).
I suspect that some other driver clears the flags during the power down,
but I couldn't find such driver.
Do you have any clue what code may change this register during the
Any other insights are welcomed as well :)
More information about the linux-arm-kernel