drivers: entropy: Add STM32G4X RNG support

Add RNG driver support for STM32G4X SoC series.

Signed-off-by: Richard Osterloh <richard.osterloh@gmail.com>
This commit is contained in:
Richard Osterloh 2019-09-04 09:47:46 +01:00 committed by Andrew Boie
commit 3e5187b458
4 changed files with 22 additions and 3 deletions

View file

@ -13,4 +13,4 @@ menuconfig ENTROPY_STM32_RNG
This option enables the RNG processor, which is a entropy number
generator, based on a continuous analog noise, that provides
a entropy 32-bit value to the host when read. It is available for
F4 (except STM32F401 & STM32F411), L4 and F7 series.
F4 (except STM32F401 & STM32F411), L4, F7 and G4 series.

View file

@ -17,8 +17,8 @@
#include <drivers/clock_control.h>
#include <clock_control/stm32_clock_control.h>
#if !defined(CONFIG_SOC_SERIES_STM32L4X) && !defined(CONFIG_SOC_SERIES_STM32F4X) && !defined(CONFIG_SOC_SERIES_STM32F7X)
#error RNG only available on STM32F4, STM32F7 and STM32L4 series
#if !defined(CONFIG_SOC_SERIES_STM32L4X) && !defined(CONFIG_SOC_SERIES_STM32F4X) && !defined(CONFIG_SOC_SERIES_STM32F7X) && !defined(CONFIG_SOC_SERIES_STM32G4X)
#error RNG only available on STM32F4, STM32F7, STM32L4 and STM32G4 series
#elif defined(CONFIG_SOC_STM32F401XE)
#error RNG not available on STM32F401 based SoCs
#elif defined(CONFIG_SOC_STM32F411XE)
@ -182,6 +182,14 @@ static int entropy_stm32_rng_init(struct device *dev)
* Linear Feedback Shift Register
*/
LL_RCC_SetRNGClockSource(LL_RCC_RNG_CLKSOURCE_PLLSAI1);
#elif CONFIG_SOC_SERIES_STM32G4X
/* Use the HSI48 for the RNG */
LL_RCC_HSI48_Enable();
while (!LL_RCC_HSI48_IsReady()) {
/* Wait for HSI48 to become ready */
}
LL_RCC_SetRNGClockSource(LL_RCC_RNG_CLKSOURCE_HSI48);
#endif /* CONFIG_SOC_SERIES_STM32L4X */
dev_data->clock = device_get_binding(STM32_CLOCK_CONTROL_NAME);

View file

@ -35,5 +35,12 @@ config I2C_STM32_V2
endif # I2C_STM32
if ENTROPY_GENERATOR
config ENTROPY_STM32_RNG
default y
endif # ENTROPY_GENERATOR
endif # GPIO_STM32
endif # SOC_SERIES_STM32G4X

View file

@ -60,6 +60,10 @@
#include <stm32g4xx_ll_adc.h>
#endif
#ifdef CONFIG_ENTROPY_STM32_RNG
#include <stm32g4xx_ll_rng.h>
#endif
#if defined(CONFIG_COUNTER_RTC_STM32)
#include <stm32g4xx_ll_rtc.h>
#include <stm32g4xx_ll_exti.h>