esp32: drivers: Add Entropy Device tree support
- Add TRNG module to esp32.dtsi - Updated the note about TRNG register address Signed-off-by: Mohamed ElShahawi <ExtremeGTX@hotmail.com>
This commit is contained in:
parent
22e7449b73
commit
55471982f6
6 changed files with 46 additions and 9 deletions
|
@ -70,3 +70,7 @@
|
||||||
sda-pin = <18>;
|
sda-pin = <18>;
|
||||||
scl-pin = <5>;
|
scl-pin = <5>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
&trng0 {
|
||||||
|
status = "okay";
|
||||||
|
};
|
||||||
|
|
|
@ -8,6 +8,7 @@ config ENTROPY_ESP32_RNG
|
||||||
bool "ESP32 entropy number generator driver"
|
bool "ESP32 entropy number generator driver"
|
||||||
depends on SOC_ESP32
|
depends on SOC_ESP32
|
||||||
select ENTROPY_HAS_DRIVER
|
select ENTROPY_HAS_DRIVER
|
||||||
|
select HAS_DTS_ENTROPY
|
||||||
help
|
help
|
||||||
This option enables the entropy number generator for ESP32 SoCs.
|
This option enables the entropy number generator for ESP32 SoCs.
|
||||||
|
|
||||||
|
|
|
@ -9,14 +9,15 @@
|
||||||
|
|
||||||
static inline u32_t entropy_esp32_get_u32(void)
|
static inline u32_t entropy_esp32_get_u32(void)
|
||||||
{
|
{
|
||||||
/* The documentation specifies the random number generator at the
|
/*
|
||||||
* following address, which is at odds with the SDK, that specifies
|
* APB Address: 0x60035144 (Safe,slower writes)
|
||||||
* it at 0x60035144. The fact that they're 0x200c0000 bytes apart
|
* DPORT Address: 0x3ff75144 (write bug, fast writes)
|
||||||
* (lower 16 bits are the same) suggests this might be the same
|
* In this case it won't make a difference because it is read only
|
||||||
* register, just mirrored somewhere else in the address space.
|
* More info available at:
|
||||||
* Confirmation is required.
|
* https://www.esp32.com/viewtopic.php?f=2&t=3033&p=14227
|
||||||
|
* also check: ECO and Workarounds for Bugs Document, point 3.3
|
||||||
*/
|
*/
|
||||||
volatile u32_t *rng_data_reg = (u32_t *)0x3ff75144;
|
volatile u32_t *rng_data_reg = (u32_t *)DT_INST_0_ESPRESSIF_ESP32_TRNG_BASE_ADDRESS;
|
||||||
|
|
||||||
/* Read just once. This is not optimal as the generator has
|
/* Read just once. This is not optimal as the generator has
|
||||||
* limited throughput due to scarce sources of entropy, specially
|
* limited throughput due to scarce sources of entropy, specially
|
||||||
|
@ -53,7 +54,7 @@ static struct entropy_driver_api entropy_esp32_api_funcs = {
|
||||||
.get_entropy = entropy_esp32_get_entropy
|
.get_entropy = entropy_esp32_get_entropy
|
||||||
};
|
};
|
||||||
|
|
||||||
DEVICE_AND_API_INIT(entropy_esp32, CONFIG_ENTROPY_NAME,
|
DEVICE_AND_API_INIT(entropy_esp32, DT_INST_0_ESPRESSIF_ESP32_TRNG_LABEL,
|
||||||
entropy_esp32_init, NULL, NULL,
|
entropy_esp32_init, NULL, NULL,
|
||||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||||
&entropy_esp32_api_funcs);
|
&entropy_esp32_api_funcs);
|
||||||
|
|
23
dts/bindings/rng/espressif,esp32-trng.yaml
Normal file
23
dts/bindings/rng/espressif,esp32-trng.yaml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# Copyright (c) 2019, Mohamed ElShahawi <ExtremeGTX@hotmail.com>
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
title: Espressif ESP32 TRNG (True Random Number Generator)
|
||||||
|
|
||||||
|
description: >
|
||||||
|
The TRNG use the noise in the Wi-Fi/BT RF system.
|
||||||
|
When Wi-Fi and BT are disabled, the random number generator will give out
|
||||||
|
pseudo-random numbers.
|
||||||
|
|
||||||
|
compatible: "espressif,esp32-trng"
|
||||||
|
|
||||||
|
include: base.yaml
|
||||||
|
|
||||||
|
properties:
|
||||||
|
reg:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
interrupts:
|
||||||
|
required: false
|
||||||
|
|
||||||
|
label:
|
||||||
|
required: true
|
|
@ -92,5 +92,13 @@
|
||||||
label = "I2C_1";
|
label = "I2C_1";
|
||||||
status = "disabled";
|
status = "disabled";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
trng0: trng@3ff75144 {
|
||||||
|
compatible = "espressif,esp32-trng";
|
||||||
|
reg = <0x3FF75144 0x4>;
|
||||||
|
/* interrupts = <33 0>; - FIXME: Enable interrupts when interrupt-controller got supported in device tree */
|
||||||
|
label = "TRNG_0";
|
||||||
|
status = "disabled";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
/* SoC level DTS fixup file */
|
/* SoC level DTS fixup file */
|
||||||
|
|
||||||
#define DT_CPU_CLOCK_FREQUENCY DT_CADENCE_TENSILICA_XTENSA_LX6_0_CLOCK_FREQUENCY
|
#define DT_CPU_CLOCK_FREQUENCY DT_CADENCE_TENSILICA_XTENSA_LX6_0_CLOCK_FREQUENCY
|
||||||
|
#define CONFIG_ENTROPY_NAME DT_INST_0_ESPRESSIF_ESP32_TRNG_LABEL
|
||||||
/* End of SoC Level DTS fixup file */
|
/* End of SoC Level DTS fixup file */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue