u32 val;
/* Put RNG in program mode */
- setbits_le32(CAAM_RTMCTL, RTMCTL_PGM);
+ /* Setting both RTMCTL:PRGM and RTMCTL:TRNG_ACC causes TRNG to
+ * properly invalidate the entropy in the entropy register and
+ * force re-generation.
+ */
+ setbits_le32(CAAM_RTMCTL, RTMCTL_PGM | RTMCTL_ACC);
+
/* Configure the RNG Entropy Delay
* Performance-wise, it does not make sense to
* set the delay to a value that is lower
val >>= BS_TRNG_ENT_DLY;
if (ent_delay < val) {
/* Put RNG4 into run mode */
- clrbits_le32(CAAM_RTMCTL, RTMCTL_PGM);
+ clrbits_le32(CAAM_RTMCTL, RTMCTL_PGM | RTMCTL_ACC);
return;
}
val &= ~BM_TRNG_SAMP_MODE;
val |= TRNG_SAMP_MODE_RAW_ES_SC;
/* Put RNG4 into run mode */
- val &= ~RTMCTL_PGM;
+ val &= ~(RTMCTL_PGM | RTMCTL_ACC);
/*test with sample mode only */
__raw_writel(val, CAAM_RTMCTL);
#define RTMCTL_PGM BIT(16)
#define RTMCTL_ERR BIT(12)
#define RTMCTL_RST BIT(6)
+#define RTMCTL_ACC BIT(5)
#define RDSTA_IF0 (1)
#define RDSTA_IF1 (2)
#define RDSTA_SKVN BIT(30)