-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
STM32WB0: add TRNG support #83152
STM32WB0: add TRNG support #83152
Conversation
659c1e3
to
c7a87e3
Compare
|
drivers/entropy/entropy_stm32.c
Outdated
@@ -124,6 +140,68 @@ static struct entropy_stm32_rng_dev_data entropy_stm32_rng_data = { | |||
.rng = (RNG_TypeDef *)DT_INST_REG_ADDR(0), | |||
}; | |||
|
|||
/* Cross-series LL compatibility wrappers */ | |||
static inline void ll_rng_EnableIT(RNG_TypeDef *RNGx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use rather: ll_rng_enable_it
drivers/entropy/entropy_stm32.c
Outdated
@@ -124,6 +140,68 @@ static struct entropy_stm32_rng_dev_data entropy_stm32_rng_data = { | |||
.rng = (RNG_TypeDef *)DT_INST_REG_ADDR(0), | |||
}; | |||
|
|||
/* Cross-series LL compatibility wrappers */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move wrappers in a header file
drivers/entropy/entropy_stm32.c
Outdated
#else /* DT_INST_NUM_IRQS(0) == 0 */ | ||
/* DT_PROP_OR is used to remove noise from error message */ | ||
BUILD_ASSERT(DT_INST_NODE_HAS_PROP(0, generation_delay_ns), | ||
"RNG '" DT_NODE_FULL_NAME(DT_DRV_INST(0)) "' has no interrupt line " | ||
"but lacks the mandatory 'generation-delay-ns' property"); | ||
#define TRNG_GENERATION_DELAY K_NSEC(DT_INST_PROP_OR(0, generation_delay_ns, 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please modify bindings so they can catch this issue and get rid of this
Add a new binding for STM32 RNG instances without interrupt lines, such as the one present in the STM32WB05/06/07 SoCs. Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
Add Device Tree nodes corresponding to TRNG of STM32WB0 series SoCs. Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
c7a87e3
to
256023f
Compare
Add support for TRNG peripherals that lack interrupt lines in the STM32 entropy driver. This enables usage of the TRNG of STM32WB05/06/07 SoCs with the driver. Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
Add overlay to allow testing of RNG driver on STM32WB0 hardware. Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
256023f
to
d06bee5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise LGTM
drivers/entropy/entropy_stm32.h
Outdated
#if defined(CONFIG_SOC_STM32WB09XX) | ||
LL_RNG_EnableEnErrorIrq(RNGx); | ||
LL_RNG_EnableEnFfFullIrq(RNGx); | ||
#else /* !CONFIG_SOC_SERIES_STM32WB0X */ | ||
LL_RNG_EnableIT(RNGx); | ||
#endif /* CONFIG_SOC_SERIES_STM32WB0X */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use consistent style in the file.
Add support for the STM32WB09-specific TRNG IP in STM32 entropy driver. Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
Add overlay to allow testing of RNG driver on STM32WB0 hardware. Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
Add overlay to allow testing of TRNG on STM32WB07. Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
d06bee5
to
636fd1d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't check the entropy driver source changes but the rest looks good!
* This node is valid for STM32WB05, STM32WB06 and | ||
* STM32WB07, all equipped with the same IRQ-less | ||
* TRNG instance. Since all those properties are | ||
* also valid on STM32SWB09, except "compatible", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* also valid on STM32SWB09, except "compatible", | |
* also valid on STM32SWB09 except "compatible", |
@ceolin PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Add support for TRNG of STM32WB0 series to existing STM32 driver. Test overlay for Nucleo-WB05KZ and Nucleo-WB09KE is also added so that correct behavior can be verified.
Tested OK using standard
tests/drivers/entropy/api
and modified version that also verifies entropy_get_entropy_from_isr and large buffer sizes. Also tested on Nucleo-WB07CC, but board is not upstream yet.Potentially supersedes #83109 - driver modification is split in two commits and PR is marked as draft for this reason.