Skip to content

Commit

Permalink
drivers: crypto: use reset api for crypto peripheral reset
Browse files Browse the repository at this point in the history
Replace direct HAL api by zephyr reset api framework for crypto
peripheral block reset.

Signed-off-by: Saravanan Sekar <[email protected]>
  • Loading branch information
ssekar15 authored and nashif committed Jul 28, 2024
1 parent 2a457d8 commit c143cba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
15 changes: 4 additions & 11 deletions drivers/crypto/crypto_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <zephyr/crypto/crypto.h>
#include <zephyr/drivers/clock_control/stm32_clock_control.h>
#include <zephyr/drivers/clock_control.h>
#include <zephyr/drivers/reset.h>
#include <zephyr/sys/byteorder.h>
#include <soc.h>

Expand Down Expand Up @@ -39,17 +40,8 @@ LOG_MODULE_REGISTER(crypto_stm32);
#endif

#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32_cryp)
#define STM32_RCC_CRYPTO_FORCE_RESET __HAL_RCC_CRYP_FORCE_RESET
#define STM32_RCC_CRYPTO_RELEASE_RESET __HAL_RCC_CRYP_RELEASE_RESET
#define STM32_CRYPTO_TYPEDEF CRYP_TypeDef
#elif DT_HAS_COMPAT_STATUS_OKAY(st_stm32_aes)
#if defined(CONFIG_SOC_SERIES_STM32WBX)
#define STM32_RCC_CRYPTO_FORCE_RESET __HAL_RCC_AES1_FORCE_RESET
#define STM32_RCC_CRYPTO_RELEASE_RESET __HAL_RCC_AES1_RELEASE_RESET
#else
#define STM32_RCC_CRYPTO_FORCE_RESET __HAL_RCC_AES_FORCE_RESET
#define STM32_RCC_CRYPTO_RELEASE_RESET __HAL_RCC_AES_RELEASE_RESET
#endif
#define STM32_CRYPTO_TYPEDEF AES_TypeDef
#endif

Expand Down Expand Up @@ -433,6 +425,7 @@ static int crypto_stm32_session_free(const struct device *dev,
int i;

struct crypto_stm32_data *data = CRYPTO_STM32_DATA(dev);
const struct crypto_stm32_config *cfg = CRYPTO_STM32_CFG(dev);
struct crypto_stm32_session *session = CRYPTO_STM32_SESSN(ctx);

session->in_use = false;
Expand All @@ -454,8 +447,7 @@ static int crypto_stm32_session_free(const struct device *dev,
return -EIO;
}

STM32_RCC_CRYPTO_FORCE_RESET();
STM32_RCC_CRYPTO_RELEASE_RESET();
(void)reset_line_toggle_dt(&cfg->reset);

k_sem_give(&data->session_sem);

Expand Down Expand Up @@ -508,6 +500,7 @@ static struct crypto_stm32_data crypto_stm32_dev_data = {
};

static const struct crypto_stm32_config crypto_stm32_dev_config = {
.reset = RESET_DT_SPEC_INST_GET(0),
.pclken = {
.enr = DT_INST_CLOCKS_CELL(0, bits),
.bus = DT_INST_CLOCKS_CELL(0, bus)
Expand Down
1 change: 1 addition & 0 deletions drivers/crypto/crypto_stm32_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define CRYPTO_STM32_AES_MAX_KEY_LEN (256 / 8)

struct crypto_stm32_config {
const struct reset_dt_spec reset;
struct stm32_pclken pclken;
};

Expand Down

0 comments on commit c143cba

Please sign in to comment.