mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
feat(efuse): Support efuses for ESP32-P4 ECO5
This commit is contained in:
@@ -452,8 +452,31 @@ static inline bool ecdsa_ll_is_deterministic_mode_supported(void)
|
||||
*/
|
||||
__attribute__((always_inline)) static inline void ecdsa_ll_set_ecdsa_key_blk(ecdsa_curve_t curve, int efuse_blk)
|
||||
{
|
||||
#ifdef EFUSE_CFG_ECDSA_BLK
|
||||
(void) curve;
|
||||
EFUSE.conf.cfg_ecdsa_blk = efuse_blk;
|
||||
#else
|
||||
uint8_t efuse_blk_low = 0;
|
||||
uint8_t efuse_blk_high = 0;
|
||||
switch (curve) {
|
||||
case ECDSA_CURVE_SECP192R1:
|
||||
EFUSE.ecdsa.cfg_ecdsa_p192_blk = efuse_blk;
|
||||
break;
|
||||
case ECDSA_CURVE_SECP256R1:
|
||||
EFUSE.ecdsa.cfg_ecdsa_p256_blk = efuse_blk;
|
||||
break;
|
||||
case ECDSA_CURVE_SECP384R1:
|
||||
// ECDSA-p384 uses two efuse blocks to store the key. These two blocks are stored in a single integer
|
||||
// where the least significant 4 bits store the low key block number and the next 4 more significant bits store the high key block number.
|
||||
HAL_ECDSA_EXTRACT_KEY_BLOCKS(efuse_blk, efuse_blk_high, efuse_blk_low);
|
||||
EFUSE.ecdsa.cfg_ecdsa_p384_h_blk = efuse_blk_high;
|
||||
EFUSE.ecdsa.cfg_ecdsa_p384_l_blk = efuse_blk_low;
|
||||
break;
|
||||
default:
|
||||
HAL_ASSERT(false && "Unsupported curve");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -142,17 +142,29 @@ __attribute__((always_inline)) static inline uint32_t efuse_ll_get_controller_st
|
||||
|
||||
__attribute__((always_inline)) static inline uint32_t efuse_ll_get_active_hp_dbias(void)
|
||||
{
|
||||
#ifdef EFUSE_ACTIVE_HP_DBIAS
|
||||
return EFUSE.rd_mac_sys_4.active_hp_dbias;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline uint32_t efuse_ll_get_active_lp_dbias(void)
|
||||
{
|
||||
#ifdef EFUSE_ACTIVE_LP_DBIAS
|
||||
return EFUSE.rd_mac_sys_4.active_lp_dbias;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline int32_t efuse_ll_get_dbias_vol_gap(void)
|
||||
{
|
||||
#ifdef EFUSE_LP_DCDC_DBIAS_VOL_GAP
|
||||
return EFUSE.rd_mac_sys_5.lp_dcdc_dbias_vol_gap;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/******************* eFuse control functions *************************/
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "hal/pmu_types.h"
|
||||
#include "soc/pmu_struct.h"
|
||||
#include "soc/efuse_struct.h"
|
||||
#include "hal/config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -68,14 +69,16 @@ static inline bool ldo_ll_is_valid_ldo_channel(int ldo_chan)
|
||||
__attribute__((always_inline))
|
||||
static inline void ldo_ll_voltage_to_dref_mul(int ldo_unit, int voltage_mv, uint8_t *dref, uint8_t *mul, bool *use_rail_voltage)
|
||||
{
|
||||
uint8_t efuse_k = 0;
|
||||
uint8_t efuse_vos = 0;
|
||||
uint8_t efuse_c = 0;
|
||||
// to avoid using FPU, enlarge the constants by 1000 as fixed point
|
||||
int K_1000 = 1000;
|
||||
int Vos_1000 = 0;
|
||||
int C_1000 = 1000;
|
||||
|
||||
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) < 300
|
||||
uint8_t efuse_k = 0;
|
||||
uint8_t efuse_vos = 0;
|
||||
uint8_t efuse_c = 0;
|
||||
|
||||
if (efuse_hal_blk_version() >= 1) {
|
||||
// load the calibration values from the eFuse
|
||||
if (ldo_unit == 2) {
|
||||
@@ -99,6 +102,7 @@ static inline void ldo_ll_voltage_to_dref_mul(int ldo_unit, int voltage_mv, uint
|
||||
C_1000 = efuse_c & 0x20 ? -1 * (efuse_c & 0x1F) + 990 : efuse_c + 990;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// iterate all the possible dref and mul values to find the best match
|
||||
int min_voltage_diff = 400000000;
|
||||
@@ -120,6 +124,7 @@ static inline void ldo_ll_voltage_to_dref_mul(int ldo_unit, int voltage_mv, uint
|
||||
}
|
||||
}
|
||||
|
||||
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) < 300
|
||||
if (efuse_hal_blk_version() >= 1) {
|
||||
// For unit0 and unit1, the mul and dref value are calibrated and saved in the efuse, load them when available
|
||||
if (ldo_unit == 0 && voltage_mv == 1800) {
|
||||
@@ -135,6 +140,7 @@ static inline void ldo_ll_voltage_to_dref_mul(int ldo_unit, int voltage_mv, uint
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
*dref = matched_dref;
|
||||
*mul = matched_mul;
|
||||
|
||||
@@ -270,10 +270,14 @@ static inline void temperature_sensor_ll_set_sample_rate(uint16_t rate)
|
||||
*/
|
||||
static inline int temperature_sensor_ll_load_calib_param(void)
|
||||
{
|
||||
#ifdef EFUSE_TEMPERATURE_SENSOR
|
||||
uint32_t cal_temp = EFUSE.rd_sys_part2_data3.temperature_sensor;
|
||||
// BIT(8) stands for sign: 1: negative, 0: positive
|
||||
int tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return tsens_cal;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user