#define RTC_CNTL_SCRATCH7_V 0xFFFFFFFF
#define RTC_CNTL_SCRATCH7_S 0
-#define RTC_CNTL_DIAG0_REG (DR_REG_RTCCNTL_BASE + 0xc0)
+#define RTC_CNTL_LOW_POWER_ST_REG (DR_REG_RTCCNTL_BASE + 0xc0)
+/* RTC_CNTL_RDY_FOR_WAKEUP : R/0; bitpos:[19]; default: 0 */
+/*description: 1 if RTC controller is ready to execute WAKE instruction, 0 otherwise */
+#define RTC_CNTL_RDY_FOR_WAKEUP (BIT(19))
+#define RTC_CNTL_RDY_FOR_WAKEUP_M (BIT(19))
+#define RTC_CNTL_RDY_FOR_WAKEUP_V 0x1
+#define RTC_CNTL_RDY_FOR_WAKEUP_S 19
+
+/* Compatibility definition */
+#define RTC_CNTL_DIAG0_REG RTC_CNTL_LOW_POWER_ST_REG
/* RTC_CNTL_LOW_POWER_DIAG0 : RO ;bitpos:[31:0] ;default: 0 ; */
/*description: */
#define RTC_CNTL_LOW_POWER_DIAG0 0xFFFFFFFF
\r
- If the SoC is not in deep sleep mode, and ULP interrupt bit (RTC_CNTL_ULP_CP_INT_ENA) is set in RTC_CNTL_INT_ENA_REG register, RTC interrupt will be triggered.\r
\r
+ Note that before using WAKE instruction, ULP program may needs to wait until RTC controller is ready to wake up the main CPU. This is indicated using RTC_CNTL_RDY_FOR_WAKEUP bit of RTC_CNTL_LOW_POWER_ST_REG register. If WAKE instruction is executed while RTC_CNTL_RDY_FOR_WAKEUP is zero, it has no effect (wake up does not occur).\r
+\r
**Examples**::\r
\r
- 1: WAKE // Trigger wake up\r
- REG_WR 0x006, 24, 24, 0 // Stop ULP timer (clear RTC_CNTL_ULP_CP_SLP_TIMER_EN)\r
- HALT // Stop the ULP program\r
+ 1: is_rdy_for_wakeup: // Read RTC_CNTL_RDY_FOR_WAKEUP bit\r
+ READ_RTC_FIELD(RTC_CNTL_LOW_POWER_ST_REG, RTC_CNTL_RDY_FOR_WAKEUP)\r
+ AND r0, r0, 1\r
+ JUMP is_rdy_for_wakeup, eq // Retry until the bit is set\r
+ WAKE // Trigger wake up\r
+ REG_WR 0x006, 24, 24, 0 // Stop ULP timer (clear RTC_CNTL_ULP_CP_SLP_TIMER_EN)\r
+ HALT // Stop the ULP program\r
// After these instructions, SoC will wake up,\r
// and ULP will not run again until started by the main program.\r
\r
.global wake_up
wake_up:
+ /* Check if the system can be woken up */
+ READ_RTC_FIELD(RTC_CNTL_LOW_POWER_ST_REG, RTC_CNTL_RDY_FOR_WAKEUP)
+ and r0, r0, 1
+ jump wake_up, eq
+
/* Wake up the SoC, end program */
wake
halt
.global wake_up
wake_up:
/* Check if the system can be woken up */
- READ_RTC_REG(RTC_CNTL_DIAG0_REG, 19, 1)
+ READ_RTC_FIELD(RTC_CNTL_LOW_POWER_ST_REG, RTC_CNTL_RDY_FOR_WAKEUP)
and r0, r0, 1
jump exit, eq