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:
parent
bb881407fb
commit
d4ed7f69d4
6 changed files with 34 additions and 8 deletions
|
@ -7,6 +7,9 @@ config BOARD
|
||||||
default "esp32c3"
|
default "esp32c3"
|
||||||
depends on BOARD_ESP32C3_DEVKITM
|
depends on BOARD_ESP32C3_DEVKITM
|
||||||
|
|
||||||
|
config ENTROPY_ESP32_RNG
|
||||||
|
default y if ENTROPY_GENERATOR
|
||||||
|
|
||||||
if BT
|
if BT
|
||||||
|
|
||||||
config HEAP_MEM_POOL_SIZE
|
config HEAP_MEM_POOL_SIZE
|
||||||
|
|
|
@ -23,3 +23,7 @@
|
||||||
status = "okay";
|
status = "okay";
|
||||||
current-speed = <115200>;
|
current-speed = <115200>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
&trng0 {
|
||||||
|
status = "okay";
|
||||||
|
};
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
config ENTROPY_ESP32_RNG
|
config ENTROPY_ESP32_RNG
|
||||||
bool "ESP32 entropy number generator driver"
|
bool "ESP32 entropy number generator driver"
|
||||||
depends on SOC_ESP32
|
depends on SOC_ESP32 || SOC_ESP32C3
|
||||||
select ENTROPY_HAS_DRIVER
|
select ENTROPY_HAS_DRIVER
|
||||||
default y
|
default y
|
||||||
help
|
help
|
||||||
|
|
|
@ -7,18 +7,20 @@
|
||||||
#define DT_DRV_COMPAT espressif_esp32_trng
|
#define DT_DRV_COMPAT espressif_esp32_trng
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <drivers/entropy.h>
|
#include <hal/cpu_hal.h>
|
||||||
#include <soc/dport_reg.h>
|
#include <esp_clk.h>
|
||||||
#include <soc/rtc.h>
|
#include <soc/rtc.h>
|
||||||
#include <soc/wdev_reg.h>
|
#include <soc/wdev_reg.h>
|
||||||
#include <soc/rtc_cntl_reg.h>
|
#include <soc/rtc_cntl_reg.h>
|
||||||
#include <soc/apb_ctrl_reg.h>
|
#include <soc/apb_ctrl_reg.h>
|
||||||
#include <esp_system.h>
|
#include <esp_system.h>
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
#include <xtensa/core-macros.h>
|
#include <drivers/entropy.h>
|
||||||
|
|
||||||
extern int esp_clk_cpu_freq(void);
|
#ifdef CONFIG_SOC_ESP32
|
||||||
extern int esp_clk_apb_freq(void);
|
#include <xtensa/core-macros.h>
|
||||||
|
#include <soc/dport_reg.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline uint32_t entropy_esp32_get_u32(void)
|
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;
|
uint32_t ccount;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ccount = XTHAL_GET_CCOUNT();
|
ccount = cpu_hal_get_cycle_count();
|
||||||
} while (ccount - last_ccount < cpu_to_apb_freq_ratio * 16);
|
} while (ccount - last_ccount < cpu_to_apb_freq_ratio * 16);
|
||||||
last_ccount = ccount;
|
last_ccount = ccount;
|
||||||
|
|
||||||
return REG_READ(WDEV_RND_REG);
|
return REG_READ(WDEV_RND_REG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,9 @@
|
||||||
/ {
|
/ {
|
||||||
#address-cells = <1>;
|
#address-cells = <1>;
|
||||||
#size-cells = <1>;
|
#size-cells = <1>;
|
||||||
|
chosen {
|
||||||
|
zephyr,entropy = &trng0;
|
||||||
|
};
|
||||||
|
|
||||||
cpus {
|
cpus {
|
||||||
#address-cells = <1>;
|
#address-cells = <1>;
|
||||||
|
@ -37,6 +40,13 @@
|
||||||
label = "UART_0";
|
label = "UART_0";
|
||||||
status = "disabled";
|
status = "disabled";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
trng0: trng@3ff700b0 {
|
||||||
|
compatible = "espressif,esp32-trng";
|
||||||
|
reg = <0x3FF700B0 0x4>;
|
||||||
|
label = "TRNG_0";
|
||||||
|
status = "disabled";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -130,6 +130,12 @@ SECTIONS
|
||||||
*libzephyr.a:log_backend_uart.*(.literal .text .literal.* .text.*)
|
*libzephyr.a:log_backend_uart.*(.literal .text .literal.* .text.*)
|
||||||
*liblib__libc__minimal.a:string.*(.literal .text .literal.* .text.*)
|
*liblib__libc__minimal.a:string.*(.literal .text .literal.* .text.*)
|
||||||
*libgcov.a:(.literal .text .literal.* .text.*)
|
*libgcov.a:(.literal .text .literal.* .text.*)
|
||||||
|
|
||||||
|
*libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.*)
|
||||||
|
*libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.*)
|
||||||
|
*libnet80211.a:( .wifirxiram .wifirxiram.* .wifislprxiram .wifislprxiram.*)
|
||||||
|
*libpp.a:( .wifirxiram .wifirxiram.* .wifislprxiram .wifislprxiram.*)
|
||||||
|
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
_init_end = ABSOLUTE(.);
|
_init_end = ABSOLUTE(.);
|
||||||
_iram_text_end = ABSOLUTE(.); *(.srodata)
|
_iram_text_end = ABSOLUTE(.); *(.srodata)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue