Lines Matching full:rng
61 * struct stm32_rng_config - RNG configuration data
63 * @cr: RNG configuration. 0 means default hardware RNG configuration
74 struct hwrng rng; member
86 * Extracts from the STM32 RNG specification when RNG supports CONDRST.
88 * When a noise source (or seed) error occurs, the RNG stops generating
94 * Indeed, when SEIS is set and SECS is cleared it means RNG performed
101 * cleared by RNG. The random number generation is now back to normal.
115 /* RNG auto-reset (step 2.) */ in stm32_rng_conceal_seed_error_cond_reset()
143 * Extracts from the STM32 RNG specification, when CONDRST is not supported
145 * When a noise source (or seed) error occurs, the RNG stops generating
150 * error after the RNG initialization:
173 static int stm32_rng_conceal_seed_error(struct hwrng *rng) in stm32_rng_conceal_seed_error() argument
175 struct stm32_rng_private *priv = container_of(rng, struct stm32_rng_private, rng); in stm32_rng_conceal_seed_error()
186 static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool wait) in stm32_rng_read() argument
188 struct stm32_rng_private *priv = container_of(rng, struct stm32_rng_private, rng); in stm32_rng_read()
198 stm32_rng_conceal_seed_error(rng); in stm32_rng_read()
204 * care of initial delay time when enabling the RNG. in stm32_rng_read()
222 err = stm32_rng_conceal_seed_error(rng); in stm32_rng_read()
233 if (WARN_ONCE((sr & RNG_SR_CEIS), "RNG clock too slow - %x\n", sr)) in stm32_rng_read()
240 err = stm32_rng_conceal_seed_error(rng); in stm32_rng_read()
264 static uint stm32_rng_clock_freq_restrain(struct hwrng *rng) in stm32_rng_clock_freq_restrain() argument
267 container_of(rng, struct stm32_rng_private, rng); in stm32_rng_clock_freq_restrain()
281 pr_debug("RNG clk rate : %lu\n", clk_get_rate(priv->clk_bulk[0].clk) >> clock_div); in stm32_rng_clock_freq_restrain()
286 static int stm32_rng_init(struct hwrng *rng) in stm32_rng_init() argument
289 container_of(rng, struct stm32_rng_private, rng); in stm32_rng_init()
303 * Keep default RNG configuration if none was specified. in stm32_rng_init()
307 uint clock_div = stm32_rng_clock_freq_restrain(rng); in stm32_rng_init()
338 /* Handle all RNG versions by checking if conditional reset should be set */ in stm32_rng_init()
405 /* Do not save that RNG is enabled as it will be handled at resume */ in stm32_rng_suspend()
517 .compatible = "st,stm32mp25-rng",
521 .compatible = "st,stm32mp13-rng",
525 .compatible = "st,stm32-rng",
556 priv->lock_conf = of_property_read_bool(np, "st,rng-lock-conf"); in stm32_rng_probe()
565 priv->rng.name = dev_driver_string(dev); in stm32_rng_probe()
566 priv->rng.init = stm32_rng_init; in stm32_rng_probe()
567 priv->rng.read = stm32_rng_read; in stm32_rng_probe()
568 priv->rng.quality = 900; in stm32_rng_probe()
596 return devm_hwrng_register(dev, &priv->rng); in stm32_rng_probe()
601 .name = "stm32-rng",
613 MODULE_DESCRIPTION("STMicroelectronics STM32 RNG device driver");