]> git.sur5r.net Git - u-boot/blobdiff - drivers/crypto/fsl/jobdesc.c
imx_lpi2c: Update lpi2c driver to support imx8
[u-boot] / drivers / crypto / fsl / jobdesc.c
index 375ff9d0e38fec807bc69c9fb1f560d77d10de75..317f73c42bdbf6844b5b9b37961082245f86ab11 100644 (file)
@@ -1,11 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * SEC Descriptor Construction Library
  * Basic job descriptor construction
  *
  * Copyright 2014 Freescale Semiconductor, Inc.
  *
- * SPDX-License-Identifier:    GPL-2.0+
- *
  */
 
 #include <common.h>
@@ -257,7 +256,7 @@ void inline_cnstr_jobdesc_blob_decap(uint32_t *desc, uint8_t *key_idnfr,
  * 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 +264,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*/