crypto: caam - enable raw data instead of von Neumann data
authorAlex Porosanu <alexandru.porosanu@freescale.com>
Mon, 11 Aug 2014 08:40:17 +0000 (11:40 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 25 Aug 2014 12:32:37 +0000 (20:32 +0800)
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>
drivers/crypto/caam/ctrl.c
drivers/crypto/caam/regs.h

index 111ac1ffbc11f4de8074a821e407cb164fdf65b4..c6210373b1be43df131cd85d9eee1ca1c6d8504d 100644 (file)
@@ -357,8 +357,17 @@ static void kick_trng(struct platform_device *pdev, int ent_delay)
        wr_reg32(&r4tst->rtfrqmin, ent_delay >> 2);
        /* disable maximum frequency count */
        wr_reg32(&r4tst->rtfrqmax, RTFRQMAX_DISABLE);
+       /* read the control register */
+       val = rd_reg32(&r4tst->rtmctl);
+       /*
+        * select raw sampling in both entropy shifter
+        * and statistical checker
+        */
+       setbits32(&val, RTMCTL_SAMP_MODE_RAW_ES_SC);
        /* put RNG4 into run mode */
-       clrbits32(&r4tst->rtmctl, RTMCTL_PRGM);
+       clrbits32(&val, RTMCTL_PRGM);
+       /* write back the control register */
+       wr_reg32(&r4tst->rtmctl, val);
 }
 
 /**
index 5fa739c290a7d245ec6022fee324e2c6f5b1a1b2..bc9cd62b96e0f87923fda2f0b1420100b797b425 100644 (file)
@@ -269,6 +269,16 @@ struct rngtst {
 /* RNG4 TRNG test registers */
 struct rng4tst {
 #define RTMCTL_PRGM    0x00010000      /* 1 -> program mode, 0 -> run mode */
+#define RTMCTL_SAMP_MODE_VON_NEUMANN_ES_SC     0 /* use von Neumann data in
+                                                    both entropy shifter and
+                                                    statistical checker */
+#define RTMCTL_SAMP_MODE_RAW_ES_SC             1 /* use raw data in both
+                                                    entropy shifter and
+                                                    statistical checker */
+#define RTMCTL_SAMP_MODE_VON_NEUMANN_ES_RAW_SC 2 /* use von Neumann data in
+                                                    entropy shifter, raw data
+                                                    in statistical checker */
+#define RTMCTL_SAMP_MODE_INVALID               3 /* invalid combination */
        u32 rtmctl;             /* misc. control register */
        u32 rtscmisc;           /* statistical check misc. register */
        u32 rtpkrrng;           /* poker range register */