forked from espressif/esp-idf
fix(hal): correct the power up sequence for MPI/ECC peripherals in ESP32-C5
This commit is contained in:
committed by
nilesh.kale
parent
597331d23c
commit
9ff2f9ab2f
@@ -20,6 +20,9 @@ typedef enum {
|
|||||||
ECC_PARAM_K,
|
ECC_PARAM_K,
|
||||||
} ecc_ll_param_t;
|
} ecc_ll_param_t;
|
||||||
|
|
||||||
|
static inline void ecc_ll_power_up(void) {}
|
||||||
|
static inline void ecc_ll_power_down(void) {}
|
||||||
|
|
||||||
static inline void ecc_ll_enable_interrupt(void)
|
static inline void ecc_ll_enable_interrupt(void)
|
||||||
{
|
{
|
||||||
REG_SET_FIELD(ECC_MULT_INT_ENA_REG, ECC_MULT_CALC_DONE_INT_ENA, 1);
|
REG_SET_FIELD(ECC_MULT_INT_ENA_REG, ECC_MULT_CALC_DONE_INT_ENA, 1);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -9,6 +9,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "hal/assert.h"
|
#include "hal/assert.h"
|
||||||
#include "soc/ecc_mult_reg.h"
|
#include "soc/ecc_mult_reg.h"
|
||||||
|
#include "soc/pcr_struct.h"
|
||||||
|
#include "soc/pcr_reg.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -20,6 +22,18 @@ typedef enum {
|
|||||||
ECC_PARAM_K,
|
ECC_PARAM_K,
|
||||||
} ecc_ll_param_t;
|
} ecc_ll_param_t;
|
||||||
|
|
||||||
|
static inline void ecc_ll_power_up(void)
|
||||||
|
{
|
||||||
|
REG_CLR_BIT(PCR_ECC_PD_CTRL_REG, PCR_ECC_MEM_PD);
|
||||||
|
REG_CLR_BIT(PCR_ECC_PD_CTRL_REG, PCR_ECC_MEM_FORCE_PD);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void ecc_ll_power_down(void)
|
||||||
|
{
|
||||||
|
REG_CLR_BIT(PCR_ECC_PD_CTRL_REG, PCR_ECC_MEM_FORCE_PU);
|
||||||
|
REG_SET_BIT(PCR_ECC_PD_CTRL_REG, PCR_ECC_MEM_PD);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void ecc_ll_enable_interrupt(void)
|
static inline void ecc_ll_enable_interrupt(void)
|
||||||
{
|
{
|
||||||
REG_SET_FIELD(ECC_MULT_INT_ENA_REG, ECC_MULT_CALC_DONE_INT_ENA, 1);
|
REG_SET_FIELD(ECC_MULT_INT_ENA_REG, ECC_MULT_CALC_DONE_INT_ENA, 1);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -8,7 +8,10 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "hal/assert.h"
|
#include "hal/assert.h"
|
||||||
|
#include "hal/ecc_types.h"
|
||||||
#include "soc/ecc_mult_reg.h"
|
#include "soc/ecc_mult_reg.h"
|
||||||
|
#include "soc/pcr_struct.h"
|
||||||
|
#include "soc/pcr_reg.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -23,6 +26,18 @@ typedef enum {
|
|||||||
ECC_PARAM_QZ,
|
ECC_PARAM_QZ,
|
||||||
} ecc_ll_param_t;
|
} ecc_ll_param_t;
|
||||||
|
|
||||||
|
static inline void ecc_ll_power_up(void)
|
||||||
|
{
|
||||||
|
REG_CLR_BIT(PCR_ECC_PD_CTRL_REG, PCR_ECC_MEM_PD);
|
||||||
|
REG_CLR_BIT(PCR_ECC_PD_CTRL_REG, PCR_ECC_MEM_FORCE_PD);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void ecc_ll_power_down(void)
|
||||||
|
{
|
||||||
|
REG_CLR_BIT(PCR_ECC_PD_CTRL_REG, PCR_ECC_MEM_FORCE_PU);
|
||||||
|
REG_SET_BIT(PCR_ECC_PD_CTRL_REG, PCR_ECC_MEM_PD);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void ecc_ll_enable_interrupt(void)
|
static inline void ecc_ll_enable_interrupt(void)
|
||||||
{
|
{
|
||||||
REG_SET_FIELD(ECC_MULT_INT_ENA_REG, ECC_MULT_CALC_DONE_INT_ENA, 1);
|
REG_SET_FIELD(ECC_MULT_INT_ENA_REG, ECC_MULT_CALC_DONE_INT_ENA, 1);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: CC0-1.0
|
* SPDX-License-Identifier: CC0-1.0
|
||||||
*/
|
*/
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "test_params.h"
|
#include "test_params.h"
|
||||||
#include "soc/soc_caps.h"
|
#include "soc/soc_caps.h"
|
||||||
#include "hal/ecc_hal.h"
|
#include "hal/ecc_hal.h"
|
||||||
|
#include "hal/ecc_ll.h"
|
||||||
#include "hal/clk_gate_ll.h"
|
#include "hal/clk_gate_ll.h"
|
||||||
|
|
||||||
#include "unity.h"
|
#include "unity.h"
|
||||||
@@ -43,6 +44,7 @@ static void ecc_be_to_le(const uint8_t* be_point, uint8_t *le_point, uint8_t len
|
|||||||
static void ecc_enable_and_reset(void)
|
static void ecc_enable_and_reset(void)
|
||||||
{
|
{
|
||||||
periph_ll_enable_clk_clear_rst(PERIPH_ECC_MODULE);
|
periph_ll_enable_clk_clear_rst(PERIPH_ECC_MODULE);
|
||||||
|
ecc_ll_power_up();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOC_ECC_SUPPORT_POINT_MULT
|
#if SOC_ECC_SUPPORT_POINT_MULT
|
||||||
|
@@ -11,17 +11,20 @@
|
|||||||
#include "esp_private/periph_ctrl.h"
|
#include "esp_private/periph_ctrl.h"
|
||||||
#include "ecc_impl.h"
|
#include "ecc_impl.h"
|
||||||
#include "hal/ecc_hal.h"
|
#include "hal/ecc_hal.h"
|
||||||
|
#include "hal/ecc_ll.h"
|
||||||
|
|
||||||
static void esp_ecc_acquire_hardware(void)
|
static void esp_ecc_acquire_hardware(void)
|
||||||
{
|
{
|
||||||
esp_crypto_ecc_lock_acquire();
|
esp_crypto_ecc_lock_acquire();
|
||||||
|
|
||||||
periph_module_enable(PERIPH_ECC_MODULE);
|
periph_module_enable(PERIPH_ECC_MODULE);
|
||||||
|
ecc_ll_power_up();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void esp_ecc_release_hardware(void)
|
static void esp_ecc_release_hardware(void)
|
||||||
{
|
{
|
||||||
periph_module_disable(PERIPH_ECC_MODULE);
|
periph_module_disable(PERIPH_ECC_MODULE);
|
||||||
|
ecc_ll_power_down();
|
||||||
|
|
||||||
esp_crypto_ecc_lock_release();
|
esp_crypto_ecc_lock_release();
|
||||||
}
|
}
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
#include "mbedtls/platform_util.h"
|
#include "mbedtls/platform_util.h"
|
||||||
#include "esp_private/periph_ctrl.h"
|
#include "esp_private/periph_ctrl.h"
|
||||||
#include "ecdsa/ecdsa_alt.h"
|
#include "ecdsa/ecdsa_alt.h"
|
||||||
|
#include "hal/ecc_ll.h"
|
||||||
|
|
||||||
#define ECDSA_KEY_MAGIC (short) 0xECD5A
|
#define ECDSA_KEY_MAGIC (short) 0xECD5A
|
||||||
#define ECDSA_SHA_LEN 32
|
#define ECDSA_SHA_LEN 32
|
||||||
@@ -26,11 +27,13 @@ static void esp_ecdsa_acquire_hardware(void)
|
|||||||
esp_crypto_ecdsa_lock_acquire();
|
esp_crypto_ecdsa_lock_acquire();
|
||||||
|
|
||||||
periph_module_enable(PERIPH_ECDSA_MODULE);
|
periph_module_enable(PERIPH_ECDSA_MODULE);
|
||||||
|
ecc_ll_power_up();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void esp_ecdsa_release_hardware(void)
|
static void esp_ecdsa_release_hardware(void)
|
||||||
{
|
{
|
||||||
periph_module_disable(PERIPH_ECDSA_MODULE);
|
periph_module_disable(PERIPH_ECDSA_MODULE);
|
||||||
|
ecc_ll_power_down();
|
||||||
|
|
||||||
esp_crypto_ecdsa_lock_release();
|
esp_crypto_ecdsa_lock_release();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user