Skip to content

Commit

Permalink
[hmac,sw] Poll HMAC IDLE state
Browse files Browse the repository at this point in the history
- Add HMAC idle polling to be sure that the HW is ready after the
temporary workaround for context switching.

Signed-off-by: Martin Velay <[email protected]>
  • Loading branch information
martin-velay authored and vogelpi committed Nov 7, 2024
1 parent 7f32449 commit 2b072c4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sw/device/lib/crypto/drivers/hmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ static void msg_fifo_write(const uint8_t *message, size_t message_len) {
*
* @param[out] ctx Context to which values are written.
*/
static void tmp_avoid_hw_hang(hmac_ctx_t *ctx) {
static status_t tmp_avoid_hw_hang(hmac_ctx_t *ctx) {
// Insert delay which should be equivalent to at least 80 clock cycles
ibex_timeout_t timeout;
timeout.cycles = kNumIterTimeout / 2; // 1/2 as a loop is 2 instructions
Expand All @@ -297,6 +297,9 @@ static void tmp_avoid_hw_hang(hmac_ctx_t *ctx) {
uint32_t cmd_reg = abs_mmio_read32(kHmacBaseAddr + HMAC_CMD_REG_OFFSET);
cmd_reg = bitfield_bit32_write(cmd_reg, HMAC_CMD_HASH_PROCESS_BIT, true);
abs_mmio_write32(kHmacBaseAddr + HMAC_CMD_REG_OFFSET, cmd_reg);

// Wait for HMAC HWIP operation to be completed.
return hmac_idle_wait();
}

/**
Expand Down

0 comments on commit 2b072c4

Please sign in to comment.