aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlex Porosanu <alexandru.porosanu@freescale.com>2014-08-11 04:40:17 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2014-08-25 08:32:37 -0400
commite5ffbfc182bc148f44840bdd3970ea4c8bf80c3c (patch)
tree0e9673d21a24695118b8ac4d15907f92b5e11b9f /drivers
parenteeaa1724a2e9c8958a8621b3c10d5ca0667e78fa (diff)
crypto: caam - enable raw data instead of von Neumann data
The sampling of the oscillator can be done in multiple modes for generating the entropy value. By default, this is set to von Neumann. This patch changes the sampling to raw data, since it has been discovered that the generated entropy has a better 'quality'. Signed-off-by: Alex Porosanu <alexandru.porosanu@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/crypto/caam/ctrl.c11
-rw-r--r--drivers/crypto/caam/regs.h10
2 files changed, 20 insertions, 1 deletions
diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c
index 111ac1ffbc11..c6210373b1be 100644
--- a/drivers/crypto/caam/ctrl.c
+++ b/drivers/crypto/caam/ctrl.c
@@ -357,8 +357,17 @@ static void kick_trng(struct platform_device *pdev, int ent_delay)
357 wr_reg32(&r4tst->rtfrqmin, ent_delay >> 2); 357 wr_reg32(&r4tst->rtfrqmin, ent_delay >> 2);
358 /* disable maximum frequency count */ 358 /* disable maximum frequency count */
359 wr_reg32(&r4tst->rtfrqmax, RTFRQMAX_DISABLE); 359 wr_reg32(&r4tst->rtfrqmax, RTFRQMAX_DISABLE);
360 /* read the control register */
361 val = rd_reg32(&r4tst->rtmctl);
362 /*
363 * select raw sampling in both entropy shifter
364 * and statistical checker
365 */
366 setbits32(&val, RTMCTL_SAMP_MODE_RAW_ES_SC);
360 /* put RNG4 into run mode */ 367 /* put RNG4 into run mode */
361 clrbits32(&r4tst->rtmctl, RTMCTL_PRGM); 368 clrbits32(&val, RTMCTL_PRGM);
369 /* write back the control register */
370 wr_reg32(&r4tst->rtmctl, val);
362} 371}
363 372
364/** 373/**
diff --git a/drivers/crypto/caam/regs.h b/drivers/crypto/caam/regs.h
index 5fa739c290a7..bc9cd62b96e0 100644
--- a/drivers/crypto/caam/regs.h
+++ b/drivers/crypto/caam/regs.h
@@ -269,6 +269,16 @@ struct rngtst {
269/* RNG4 TRNG test registers */ 269/* RNG4 TRNG test registers */
270struct rng4tst { 270struct rng4tst {
271#define RTMCTL_PRGM 0x00010000 /* 1 -> program mode, 0 -> run mode */ 271#define RTMCTL_PRGM 0x00010000 /* 1 -> program mode, 0 -> run mode */
272#define RTMCTL_SAMP_MODE_VON_NEUMANN_ES_SC 0 /* use von Neumann data in
273 both entropy shifter and
274 statistical checker */
275#define RTMCTL_SAMP_MODE_RAW_ES_SC 1 /* use raw data in both
276 entropy shifter and
277 statistical checker */
278#define RTMCTL_SAMP_MODE_VON_NEUMANN_ES_RAW_SC 2 /* use von Neumann data in
279 entropy shifter, raw data
280 in statistical checker */
281#define RTMCTL_SAMP_MODE_INVALID 3 /* invalid combination */
272 u32 rtmctl; /* misc. control register */ 282 u32 rtmctl; /* misc. control register */
273 u32 rtscmisc; /* statistical check misc. register */ 283 u32 rtscmisc; /* statistical check misc. register */
274 u32 rtpkrrng; /* poker range register */ 284 u32 rtpkrrng; /* poker range register */