drivers: entropy: esp32: enable rng driver

for esp32c3 allowing wifi subsystem to use inside
its driver.

Signed-off-by: Felipe Neves <felipe.neves@espressif.com>
This commit is contained in:
Felipe Neves 2021-08-10 12:55:34 -03:00 committed by Christopher Friedt
commit d4ed7f69d4
6 changed files with 34 additions and 8 deletions

View file

@ -5,7 +5,7 @@
config ENTROPY_ESP32_RNG
bool "ESP32 entropy number generator driver"
depends on SOC_ESP32
depends on SOC_ESP32 || SOC_ESP32C3
select ENTROPY_HAS_DRIVER
default y
help

View file

@ -7,18 +7,20 @@
#define DT_DRV_COMPAT espressif_esp32_trng
#include <string.h>
#include <drivers/entropy.h>
#include <soc/dport_reg.h>
#include <hal/cpu_hal.h>
#include <esp_clk.h>
#include <soc/rtc.h>
#include <soc/wdev_reg.h>
#include <soc/rtc_cntl_reg.h>
#include <soc/apb_ctrl_reg.h>
#include <esp_system.h>
#include <soc.h>
#include <xtensa/core-macros.h>
#include <drivers/entropy.h>
extern int esp_clk_cpu_freq(void);
extern int esp_clk_apb_freq(void);
#ifdef CONFIG_SOC_ESP32
#include <xtensa/core-macros.h>
#include <soc/dport_reg.h>
#endif
static inline uint32_t entropy_esp32_get_u32(void)
{
@ -37,9 +39,10 @@ static inline uint32_t entropy_esp32_get_u32(void)
uint32_t ccount;
do {
ccount = XTHAL_GET_CCOUNT();
ccount = cpu_hal_get_cycle_count();
} while (ccount - last_ccount < cpu_to_apb_freq_ratio * 16);
last_ccount = ccount;
return REG_READ(WDEV_RND_REG);
}