hw/mcu/dialog: Put OTPC to deep standby
This saves a lot of power.
@@ -101,6 +101,14 @@ void SystemInit(void)
CRG_TOP->PMU_CTRL_REG |= CRG_TOP_PMU_CTRL_REG_RETAIN_CACHE_Msk;
#endif
+ /* Switch OTPC to deep standby (DSTBY) mode */
+ CRG_TOP->CLK_AMBA_REG |= CRG_TOP_CLK_AMBA_REG_OTP_ENABLE_Msk;
+ OTPC->OTPC_MODE_REG = (OTPC->OTPC_MODE_REG &
+ ~OTPC_OTPC_MODE_REG_OTPC_MODE_MODE_Msk) |
+ (1 << OTPC_OTPC_MODE_REG_OTPC_MODE_MODE_Pos);
+ while (!(OTPC->OTPC_STAT_REG & OTPC_OTPC_STAT_REG_OTPC_STAT_MRDY_Msk));
+ CRG_TOP->CLK_AMBA_REG &= ~CRG_TOP_CLK_AMBA_REG_OTP_ENABLE_Msk;
+
/* XXX temporarily enable PD_COM and PD_PER since we do not control them */
da1469x_pd_acquire(MCU_PD_DOMAIN_COM);
da1469x_pd_acquire(MCU_PD_DOMAIN_PER);
