Skip to content

Commit

Permalink
hwrng: stm32 - fix clock division application
Browse files Browse the repository at this point in the history
Fix clock division application that was not shifted, corrupting
the configuration register.

Signed-off-by: Gatien Chevallier <gatien.chevallier@foss.st.com>
Change-Id: I0594f5343e9e2ee541951b26b6930e1f11b006b2
Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/linux-stm32/+/316193
Tested-by: Gatien CHEVALLIER <gatien.chevallier@st.com>
Reviewed-by: Gatien CHEVALLIER <gatien.chevallier@st.com>
Domain-Review: Gatien CHEVALLIER <gatien.chevallier@st.com>
  • Loading branch information
GseoC authored and fourmone committed Jul 11, 2023
1 parent ec3bd36 commit c233654
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions drivers/char/hw_random/stm32-rng.c
Expand Up @@ -16,11 +16,12 @@
#include <linux/reset.h>
#include <linux/slab.h>

#define RNG_CR 0x00
#define RNG_CR_RNGEN BIT(2)
#define RNG_CR_CED BIT(5)
#define RNG_CR_CONDRST BIT(30)
#define RNG_CR_CONFLOCK BIT(31)
#define RNG_CR 0x00
#define RNG_CR_RNGEN BIT(2)
#define RNG_CR_CED BIT(5)
#define RNG_CR_CLKDIV_SHIFT 16
#define RNG_CR_CONDRST BIT(30)
#define RNG_CR_CONFLOCK BIT(31)

#define RNG_SR 0x04
#define RNG_SR_SEIS BIT(6)
Expand Down Expand Up @@ -135,7 +136,8 @@ static int stm32_rng_init(struct hwrng *rng)
uint clock_div = stm32_rng_clock_freq_restrain(rng);

reg &= ~RNG_NIST_CONFIG_MASK;
reg |= RNG_CR_CONDRST | RNG_NIST_CONFIG_B | clock_div;
reg |= RNG_CR_CONDRST | RNG_NIST_CONFIG_B |
(clock_div << RNG_CR_CLKDIV_SHIFT);
writel_relaxed(reg, priv->base + RNG_CR);
reg &= ~RNG_CR_CONDRST;
reg |= RNG_CR_CONFLOCK;
Expand Down

0 comments on commit c233654

Please sign in to comment.