2023-09-08 18:21:48

by Gatien CHEVALLIER

[permalink] [raw]
Subject: [PATCH 00/10] hwrng: stm32: support STM32MP13x platforms

The STM32MP13x platforms have a RNG hardware block that supports
customization, a conditional reset sequences that allows to
recover from certain situations and a configuration locking
mechanism.

This series adds support for the mentionned features. Note that
the hardware RNG can and should be managed in the secure world
for this platform, hence the rng not being default enabled on
the STM32MP135F-DK board.

Gatien Chevallier (10):
dt-bindings: rng: introduce new compatible for STM32MP13x
hwrng: stm32 - use devm_platform_get_and_ioremap_resource() API
hwrng: stm32 - implement STM32MP13x support
hwrng: stm32 - implement error concealment
hwrng: stm32 - rework error handling in stm32_rng_read()
hwrng: stm32 - restrain RNG noise source clock
dt-bindings: rng: add st,rng-lock-conf
hwrng: stm32 - support RNG configuration locking mechanism
hwrng: stm32 - rework power management sequences
ARM: dts: stm32: add RNG node for STM32MP13x platforms

.../devicetree/bindings/rng/st,stm32-rng.yaml | 18 +-
arch/arm/boot/dts/st/stm32mp131.dtsi | 8 +
drivers/char/hw_random/stm32-rng.c | 509 +++++++++++++++---
3 files changed, 452 insertions(+), 83 deletions(-)

--
2.25.1


2023-09-08 23:32:52

by Gatien CHEVALLIER

[permalink] [raw]
Subject: [PATCH 08/10] hwrng: stm32 - support RNG configuration locking mechanism

If "st,rng-lock-conf" DT binding property is set for a stm32-rng node,
the RNG configuration will be locked until next hardware block reset
or platform reset.

Signed-off-by: Gatien Chevallier <[email protected]>
---
drivers/char/hw_random/stm32-rng.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/char/hw_random/stm32-rng.c b/drivers/char/hw_random/stm32-rng.c
index 3b77f1fe6aea..0243b889ac54 100644
--- a/drivers/char/hw_random/stm32-rng.c
+++ b/drivers/char/hw_random/stm32-rng.c
@@ -62,6 +62,7 @@ struct stm32_rng_private {
struct reset_control *rst;
const struct stm32_rng_data *data;
bool ced;
+ bool lock_conf;
};

/*
@@ -301,6 +302,9 @@ static int stm32_rng_init(struct hwrng *rng)

reg &= ~RNG_CR_CONDRST;
reg |= RNG_CR_RNGEN;
+ if (priv->lock_conf)
+ reg |= RNG_CR_CONFLOCK;
+
writel_relaxed(reg, priv->base + RNG_CR);

err = readl_relaxed_poll_timeout_atomic(priv->base + RNG_CR, reg,
@@ -439,6 +443,7 @@ static int stm32_rng_probe(struct platform_device *ofdev)
}

priv->ced = of_property_read_bool(np, "clock-error-detect");
+ priv->lock_conf = of_property_read_bool(np, "st,rng-lock-conf");

priv->data = of_device_get_match_data(dev);
if (!priv->data)
--
2.25.1