]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - drivers/crypto/fsl/jobdesc.c
crypto/fsl: instantiate all rng state handles
[people/ms/u-boot.git] / drivers / crypto / fsl / jobdesc.c
index 6125bbb558d2dce395d4693a76fa0be435f2e1fc..aadf8511014d144979f03e355463cbc0f3ca02bb 100644 (file)
@@ -204,7 +204,7 @@ void inline_cnstr_jobdesc_hash(uint32_t *desc,
        append_store(desc, dma_addr_out, storelen,
                     LDST_CLASS_2_CCB | LDST_SRCDST_BYTE_CONTEXT);
 }
-
+#ifndef CONFIG_SPL_BUILD
 void inline_cnstr_jobdesc_blob_encap(uint32_t *desc, uint8_t *key_idnfr,
                                     uint8_t *plain_txt, uint8_t *enc_blob,
                                     uint32_t in_sz)
@@ -252,12 +252,12 @@ void inline_cnstr_jobdesc_blob_decap(uint32_t *desc, uint8_t *key_idnfr,
 
        append_operation(desc, OP_TYPE_DECAP_PROTOCOL | OP_PCLID_BLOB);
 }
-
+#endif
 /*
  * Descriptor to instantiate RNG State Handle 0 in normal mode and
  * load the JDKEK, TDKEK and TDSK registers
  */
-void inline_cnstr_jobdesc_rng_instantiation(uint32_t *desc)
+void inline_cnstr_jobdesc_rng_instantiation(uint32_t *desc, int handle)
 {
        u32 *jump_cmd;
 
@@ -265,21 +265,24 @@ void inline_cnstr_jobdesc_rng_instantiation(uint32_t *desc)
 
        /* INIT RNG in non-test mode */
        append_operation(desc, OP_TYPE_CLASS1_ALG | OP_ALG_ALGSEL_RNG |
-                        OP_ALG_AS_INIT);
-
-       /* wait for done */
-       jump_cmd = append_jump(desc, JUMP_CLASS_CLASS1);
-       set_jump_tgt_here(desc, jump_cmd);
-
-       /*
-        * load 1 to clear written reg:
-        * resets the done interrrupt and returns the RNG to idle.
-        */
-       append_load_imm_u32(desc, 1, LDST_SRCDST_WORD_CLRW);
-
-       /* generate secure keys (non-test) */
-       append_operation(desc, OP_TYPE_CLASS1_ALG | OP_ALG_ALGSEL_RNG |
-                        OP_ALG_RNG4_SK);
+                       (handle << OP_ALG_AAI_SHIFT) | OP_ALG_AS_INIT);
+
+       /* For SH0, Secure Keys must be generated as well */
+       if (handle == 0) {
+               /* wait for done */
+               jump_cmd = append_jump(desc, JUMP_CLASS_CLASS1);
+               set_jump_tgt_here(desc, jump_cmd);
+
+               /*
+                * load 1 to clear written reg:
+                * resets the done interrupt and returns the RNG to idle.
+                */
+               append_load_imm_u32(desc, 1, LDST_SRCDST_WORD_CLRW);
+
+               /* generate secure keys (non-test) */
+               append_operation(desc, OP_TYPE_CLASS1_ALG | OP_ALG_ALGSEL_RNG |
+                               OP_ALG_RNG4_SK);
+       }
 }
 
 /* Change key size to bytes form bits in calling function*/