Skip to content

Commit a49b553

Browse files
moidxjwnrt
authored andcommitted
[cryptolib] Explicitly enable EDN
The `EDN_CTRL` register uses multi-bit (MUBI) fields to configure the mode of operation. Setting the fields to any value different than `TRUE (0x6)` or `FALSE (0x9)` will result in a recoverable alert. This change explicitly sets all the fields in the register to expected values to avoid triggering recoverable alerts. The `EDN_RECOV_ALERT_STS_REG` is also cleared before enabling the block to avoid starting with previous invalid conditions. Signed-off-by: Miguel Osorio <[email protected]> (Cherry-picked from commit 4831476)
1 parent 2c2012c commit a49b553

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

sw/device/lib/crypto/drivers/entropy.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,10 +584,17 @@ static status_t edn_configure(const edn_config_t *config) {
584584
abs_mmio_write32(base_address + EDN_MAX_NUM_REQS_BETWEEN_RESEEDS_REG_OFFSET,
585585
config->reseed_interval);
586586

587-
uint32_t reg =
588-
bitfield_field32_write(0, EDN_CTRL_EDN_ENABLE_FIELD, kMultiBitBool4True);
587+
// Clear the EDN recoverable alert status register.
588+
abs_mmio_write32(base_address + EDN_RECOV_ALERT_STS_REG_OFFSET, 0);
589+
590+
uint32_t reg = bitfield_field32_write(
591+
EDN_CTRL_REG_RESVAL, EDN_CTRL_EDN_ENABLE_FIELD, kMultiBitBool4True);
589592
reg = bitfield_field32_write(reg, EDN_CTRL_AUTO_REQ_MODE_FIELD,
590593
kMultiBitBool4True);
594+
reg = bitfield_field32_write(reg, EDN_CTRL_BOOT_REQ_MODE_FIELD,
595+
kMultiBitBool4False);
596+
reg = bitfield_field32_write(reg, EDN_CTRL_CMD_FIFO_RST_FIELD,
597+
kMultiBitBool4False);
591598
abs_mmio_write32(base_address + EDN_CTRL_REG_OFFSET, reg);
592599

593600
HARDENED_TRY(edn_ready_block(base_address));

0 commit comments

Comments
 (0)