Commit a1b03e7a authored by Gatien Chevallier's avatar Gatien Chevallier Committed by Herbert Xu

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: default avatarGatien Chevallier <gatien.chevallier@foss.st.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 28d13f3f
...@@ -62,6 +62,7 @@ struct stm32_rng_private { ...@@ -62,6 +62,7 @@ struct stm32_rng_private {
struct reset_control *rst; struct reset_control *rst;
const struct stm32_rng_data *data; const struct stm32_rng_data *data;
bool ced; bool ced;
bool lock_conf;
}; };
/* /*
...@@ -301,6 +302,9 @@ static int stm32_rng_init(struct hwrng *rng) ...@@ -301,6 +302,9 @@ static int stm32_rng_init(struct hwrng *rng)
reg &= ~RNG_CR_CONDRST; reg &= ~RNG_CR_CONDRST;
reg |= RNG_CR_RNGEN; reg |= RNG_CR_RNGEN;
if (priv->lock_conf)
reg |= RNG_CR_CONFLOCK;
writel_relaxed(reg, priv->base + RNG_CR); writel_relaxed(reg, priv->base + RNG_CR);
err = readl_relaxed_poll_timeout_atomic(priv->base + RNG_CR, reg, err = readl_relaxed_poll_timeout_atomic(priv->base + RNG_CR, reg,
...@@ -439,6 +443,7 @@ static int stm32_rng_probe(struct platform_device *ofdev) ...@@ -439,6 +443,7 @@ static int stm32_rng_probe(struct platform_device *ofdev)
} }
priv->ced = of_property_read_bool(np, "clock-error-detect"); 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); priv->data = of_device_get_match_data(dev);
if (!priv->data) if (!priv->data)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment