MLK-17918: imx-common: Ensure CAAM clock is enabled prior getting out_jr_size
authorBreno Lima <breno.lima@nxp.com>
Fri, 23 Mar 2018 20:21:38 +0000 (17:21 -0300)
committerYe Li <ye.li@nxp.com>
Mon, 2 Apr 2018 02:41:35 +0000 (19:41 -0700)
Prior calling sec_in32() we have to ensure CAAM clock is enabled, the
function sec_in32() is reading CAAM registers and if CAAM clock is disabled
the system will hang.

Signed-off-by: Breno Lima <breno.lima@nxp.com>
Reviewed-by: Ye Li <ye.li@nxp.com>
(cherry picked from commit c4da7540e7548f36c6ad90292db7057b828a7956)

arch/arm/imx-common/cmd_dek.c
arch/arm/imx-common/cmd_mfgprot.c

index 2e5b21e..bbbd110 100644 (file)
@@ -31,12 +31,12 @@ static int blob_encap_dek(const u8 *src, u8 *dst, u32 len)
        int ret = 0;
        u32 jr_size = 4;
 
+       hab_caam_clock_enable(1);
+
        u32 out_jr_size = sec_in32(CONFIG_SYS_FSL_JR0_ADDR +
                                   FSL_CAAM_ORSR_JRa_OFFSET);
-       if (out_jr_size != jr_size) {
-               hab_caam_clock_enable(1);
+       if (out_jr_size != jr_size)
                sec_init();
-       }
 
        if (!((len == 128) | (len == 192) | (len == 256))) {
                debug("Invalid DEK size. Valid sizes are 128, 192 and 256b\n");
index 0e7f1fa..2873b5f 100644 (file)
@@ -43,13 +43,14 @@ static int do_mfgprot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 
        /* Enable HAB clock */
        u32 jr_size = 4;
+
+       hab_caam_clock_enable(1);
+
        u32 out_jr_size = sec_in32(CONFIG_SYS_FSL_JR0_ADDR +
                                   FSL_CAAM_ORSR_JRa_OFFSET);
 
-       if (out_jr_size != jr_size) {
-               hab_caam_clock_enable(1);
+       if (out_jr_size != jr_size)
                sec_init();
-       }
 
        if (strcmp(sel, pubk) == 0) {
                dst_ptr = malloc_cache_aligned(FSL_CAAM_MP_PUBK_BYTES);