mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-30 16:35:37 +00:00
rng: stm32: Implement configurable RNG clock error detection
RNG clock error detection is now enabled if the "clock-error-detect" property is set in the device tree. Signed-off-by: Gatien Chevallier <gatien.chevallier@foss.st.com> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
This commit is contained in:
parent
81a751dcd9
commit
2d2574b405
1 changed files with 17 additions and 5 deletions
|
@ -40,6 +40,7 @@ struct stm32_rng_plat {
|
||||||
struct clk clk;
|
struct clk clk;
|
||||||
struct reset_ctl rst;
|
struct reset_ctl rst;
|
||||||
const struct stm32_rng_data *data;
|
const struct stm32_rng_data *data;
|
||||||
|
bool ced;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int stm32_rng_read(struct udevice *dev, void *data, size_t len)
|
static int stm32_rng_read(struct udevice *dev, void *data, size_t len)
|
||||||
|
@ -97,25 +98,34 @@ static int stm32_rng_init(struct stm32_rng_plat *pdata)
|
||||||
|
|
||||||
cr = readl(pdata->base + RNG_CR);
|
cr = readl(pdata->base + RNG_CR);
|
||||||
|
|
||||||
/* Disable CED */
|
|
||||||
cr |= RNG_CR_CED;
|
|
||||||
if (pdata->data->has_cond_reset) {
|
if (pdata->data->has_cond_reset) {
|
||||||
cr |= RNG_CR_CONDRST;
|
cr |= RNG_CR_CONDRST;
|
||||||
|
if (pdata->ced)
|
||||||
|
cr &= ~RNG_CR_CED;
|
||||||
|
else
|
||||||
|
cr |= RNG_CR_CED;
|
||||||
writel(cr, pdata->base + RNG_CR);
|
writel(cr, pdata->base + RNG_CR);
|
||||||
cr &= ~RNG_CR_CONDRST;
|
cr &= ~RNG_CR_CONDRST;
|
||||||
|
cr |= RNG_CR_RNGEN;
|
||||||
writel(cr, pdata->base + RNG_CR);
|
writel(cr, pdata->base + RNG_CR);
|
||||||
err = readl_poll_timeout(pdata->base + RNG_CR, cr,
|
err = readl_poll_timeout(pdata->base + RNG_CR, cr,
|
||||||
(!(cr & RNG_CR_CONDRST)), 10000);
|
(!(cr & RNG_CR_CONDRST)), 10000);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
} else {
|
||||||
|
if (pdata->ced)
|
||||||
|
cr &= ~RNG_CR_CED;
|
||||||
|
else
|
||||||
|
cr |= RNG_CR_CED;
|
||||||
|
|
||||||
|
cr |= RNG_CR_RNGEN;
|
||||||
|
|
||||||
|
writel(cr, pdata->base + RNG_CR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clear error indicators */
|
/* clear error indicators */
|
||||||
writel(0, pdata->base + RNG_SR);
|
writel(0, pdata->base + RNG_SR);
|
||||||
|
|
||||||
cr |= RNG_CR_RNGEN;
|
|
||||||
writel(cr, pdata->base + RNG_CR);
|
|
||||||
|
|
||||||
err = readl_poll_timeout(pdata->base + RNG_SR, sr,
|
err = readl_poll_timeout(pdata->base + RNG_SR, sr,
|
||||||
sr & RNG_SR_DRDY, 10000);
|
sr & RNG_SR_DRDY, 10000);
|
||||||
return err;
|
return err;
|
||||||
|
@ -165,6 +175,8 @@ static int stm32_rng_of_to_plat(struct udevice *dev)
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
pdata->ced = dev_read_bool(dev, "clock-error-detect");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue