# Power Configuration

The SYSCTRL_CRYPTOCELL_PWR_CFG register is responsible for configuring power to the Arm CryptoCell-312 module.

IMPORTANT: The SYSCTRL_CRYPTOCELL_PWR_CFG_PWR_KEY bit field in the SYSCTRL_CRYPTOCELL_PWR_CFG register must be written with the correct key at the same time that the desired operation is written to the register.

The SYSCTRL_CRYPTOCELL_PWR_CFG_CC_POWER_STARTUP and SYSCTRL_CRYPTOCELL_PWR_CFG_CC_POWER_ENABLE bit fields, in the same register, control the enabling and disabling of the power to the Arm CryptoCell-312 module. The module can be powered down when not in use, to save power in Low Power Modes, particularly in the lowest-powered configuration of Sleep Mode.

Powering down the Arm CryptoCell-312 module during Run Mode results in a restart of the device. At this point the debug port does not function but the device otherwise operates as normal. The CryptoCell Always-On feature (CCAO) is not reset in this case, so the Arm CryptoCell-312 block remains powered down, as the power bits are stuck as inactive. Only a power-on-reset can reset the CCAO to its default enabled state, allowing the user to connect to the debug port.

The following procedure is used to power up the Arm CryptoCell-312 module:

ACS->PWR_CTRL = ((ACS->PWR_CTRL) & ~(1 << ACS_PWR_CTRL_CCAO_PWR_EN_Pos)) | ACS_PWR_KEY | ACS_CCAO_POWERED;

ACS->PWR_CTRL = ((ACS->PWR_CTRL) & ~(1 << ACS_PWR_CTRL_CCAO_ISOLATE_Pos)) | ACS_PWR_KEY | ACS_CCAO_NOT_ISOLATE;

/* Note that there is a 1.3usec delay automatically added when writing these registers */

SYSCTRL->CRYPTOCELL_PWR_CFG = CC_WRITE_KEY | CC_POWER_STARTUP | CC_POWER_DISABLE | CC_ISOLATE;

SYSCTRL->CRYPTOCELL_PWR_CFG = CC_WRITE_KEY | CC_POWER_STARTUP | CC_POWER_ENABLE | CC_ISOLATE;

SYSCTRL->CRYPTOCELL_PWR_CFG = CC_WRITE_KEY | CC_POWER_STARTUP | CC_POWER_ENABLE | CC_NOT_ISOLATE;

The following procedure is used to power down the Arm CryptoCell-312 module:

SYSCTRL->CRYPTOCELL_PWR_CFG = CC_WRITE_KEY | CC_POWER_STARTUP | CC_POWER_ENABLE | CC_ISOLATE;

SYSCTRL->CRYPTOCELL_PWR_CFG = CC_WRITE_KEY | CC_POWER_STARTUP | CC_POWER_DISABLE | CC_ISOLATE;

SYSCTRL->CRYPTOCELL_PWR_CFG = CC_WRITE_KEY | CC_POWER_OFF | CC_POWER_DISABLE | CC_ISOLATE;

ACS->PWR_CTRL = ((ACS->PWR_CTRL) & ~(1 << ACS_PWR_CTRL_CCAO_ISOLATE_Pos)) | ACS_PWR_KEY | ACS_CCAO_ISOLATE;

ACS->PWR_CTRL = ((ACS->PWR_CTRL) & ~(1 << ACS_PWR_CTRL_CCAO_PWR_EN_Pos)) | ACS_PWR_KEY | ACS_CCAO_SHUTDOWN;

The Arm CryptoCell-312 Always On block (and its register contents) are retained after the RSL15 wakes up from Sleep Mode. The CryptoCell-312 System control registers, however, are reset to their default values.

The following procedure is used to re-configure the CryptoCell-312 system control registers after a custom boot (waking up from sleep and using a RAM vector to restart):

/* Note that there is a 1.3usec delay automatically added when writing these registers */

SYSCTRL->CRYPTOCELL_PWR_CFG = CC_WRITE_KEY | CC_POWER_STARTUP | CC_POWER_DISABLE | CC_ISOLATE;

SYSCTRL->CRYPTOCELL_PWR_CFG = CC_WRITE_KEY | CC_POWER_STARTUP | CC_POWER_ENABLE | CC_ISOLATE;

SYSCTRL->CRYPTOCELL_PWR_CFG = CC_WRITE_KEY | CC_POWER_STARTUP | CC_POWER_ENABLE | CC_NOT_ISOLATE;

NOTE: The Arm-provided CryptoCell library initialization function (CC_LibInit()) only needs to be called once per cold boot (full system reset) cycle. This function does not need to be called again after a custom boot.