drivers: entropy: stm32: add health configuration support

Some STM32 series need to configure health test register
for proper RNG behavior.
In addition, some also require to write a Magic number
before writing the configuration.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
This commit is contained in:
Alexandre Bourdiol 2021-12-14 10:15:10 +01:00 committed by Carles Cufí
commit dc3b2321f3

View file

@ -487,6 +487,18 @@ static int entropy_stm32_rng_init(const struct device *dev)
(clock_control_subsys_t *)&dev_cfg->pclken);
__ASSERT_NO_MSG(res == 0);
#if DT_INST_NODE_HAS_PROP(0, health-test-config)
#if DT_INST_NODE_HAS_PROP(0, health-test-magic)
/* Write Magic number before writing configuration
* Not all stm32 series have a Magic number
*/
LL_RNG_SetHealthConfig(dev_data->rng, DT_INST_PROP(0, health-test-magic));
#endif
/* Write RNG HTCR configuration */
LL_RNG_SetHealthConfig(dev_data->rng, DT_INST_PROP(0, health-test-config));
#endif
LL_RNG_EnableIT(dev_data->rng);
LL_RNG_Enable(dev_data->rng);