diff options
author | Ulises Cardenas <raul.casas@nxp.com> | 2016-02-02 04:39:39 -0600 |
---|---|---|
committer | Stefano Babic <sbabic@denx.de> | 2016-02-21 11:20:54 +0100 |
commit | f91e65a74eff93d5187a3b27e1badd80c2a35fed (patch) | |
tree | 5e48d11e83ccc63f8d433268d7ef4062f36b3005 /drivers | |
parent | 2b8e8d2671227473c9698859db38fefa328b87d0 (diff) | |
download | u-boot-imx-f91e65a74eff93d5187a3b27e1badd80c2a35fed.zip u-boot-imx-f91e65a74eff93d5187a3b27e1badd80c2a35fed.tar.gz u-boot-imx-f91e65a74eff93d5187a3b27e1badd80c2a35fed.tar.bz2 |
imx: Refactoring CAAM Job Ring structure and Secure Memory for imx7
Refactored data structure for CAAM's job ring and Secure Memory
to support i.MX7.
The new memory map use macros to resolve SM's offset by version.
This will solve the versioning issue caused by the new version of
secure memory of i.MX7
Signed-off-by: Ulises Cardenas <raul.casas@nxp.com>
Reviewed-by: Stefano Babic <sbabic@denx.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/crypto/fsl/jobdesc.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/drivers/crypto/fsl/jobdesc.c b/drivers/crypto/fsl/jobdesc.c index 5695bef..fd0c4f7 100644 --- a/drivers/crypto/fsl/jobdesc.c +++ b/drivers/crypto/fsl/jobdesc.c @@ -14,7 +14,7 @@ #include "jobdesc.h" #include "rsa_caam.h" -#ifdef CONFIG_MX6 +#if defined(CONFIG_MX6) || defined(CONFIG_MX7) /*! * Secure memory run command * @@ -25,10 +25,14 @@ uint32_t secmem_set_cmd(uint32_t sec_mem_cmd) { uint32_t temp_reg; - sec_out32(CAAM_SMCJR0, sec_mem_cmd); + ccsr_sec_t *sec = (void *)CONFIG_SYS_FSL_SEC_ADDR; + uint32_t sm_vid = SM_VERSION(sec_in32(&sec->smvid)); + uint32_t jr_id = 0; + + sec_out32(CAAM_SMCJR(sm_vid, jr_id), sec_mem_cmd); do { - temp_reg = sec_in32(CAAM_SMCSJR0); + temp_reg = sec_in32(CAAM_SMCSJR(sm_vid, jr_id)); } while (temp_reg & CMD_COMPLETE); return temp_reg; @@ -51,6 +55,10 @@ int caam_page_alloc(uint8_t page_num, uint8_t partition_num) { uint32_t temp_reg; + ccsr_sec_t *sec = (void *)CONFIG_SYS_FSL_SEC_ADDR; + uint32_t sm_vid = SM_VERSION(sec_in32(&sec->smvid)); + uint32_t jr_id = 0; + /* * De-Allocate partition_num if already allocated to ARM core */ @@ -64,9 +72,9 @@ int caam_page_alloc(uint8_t page_num, uint8_t partition_num) } /* set the access rights to allow full access */ - sec_out32(CAAM_SMAG1JR0(partition_num), 0xF); - sec_out32(CAAM_SMAG2JR0(partition_num), 0xF); - sec_out32(CAAM_SMAPJR0(partition_num), 0xFF); + sec_out32(CAAM_SMAG1JR(sm_vid, jr_id, partition_num), 0xF); + sec_out32(CAAM_SMAG2JR(sm_vid, jr_id, partition_num), 0xF); + sec_out32(CAAM_SMAPJR(sm_vid, jr_id, partition_num), 0xFF); /* Now need to allocate partition_num of secure RAM. */ /* De-Allocate page_num by starting with a page inquiry command */ @@ -105,6 +113,10 @@ int caam_page_alloc(uint8_t page_num, uint8_t partition_num) int inline_cnstr_jobdesc_blob_dek(uint32_t *desc, const uint8_t *plain_txt, uint8_t *dek_blob, uint32_t in_sz) { + ccsr_sec_t *sec = (void *)CONFIG_SYS_FSL_SEC_ADDR; + uint32_t sm_vid = SM_VERSION(sec_in32(&sec->smvid)); + uint32_t jr_id = 0; + uint32_t ret = 0; u32 aad_w1, aad_w2; /* output blob will have 32 bytes key blob in beginning and @@ -133,9 +145,9 @@ int inline_cnstr_jobdesc_blob_dek(uint32_t *desc, const uint8_t *plain_txt, flush_dcache_range(start, end); /* Now configure the access rights of the partition */ - sec_out32(CAAM_SMAG1JR0(PARTITION_1), KS_G1); /* set group 1 */ - sec_out32(CAAM_SMAG2JR0(PARTITION_1), 0); /* clear group 2 */ - sec_out32(CAAM_SMAPJR0(PARTITION_1), PERM); /* set perm & locks */ + sec_out32(CAAM_SMAG1JR(sm_vid, jr_id, PARTITION_1), KS_G1); + sec_out32(CAAM_SMAG2JR(sm_vid, jr_id, PARTITION_1), 0); + sec_out32(CAAM_SMAPJR(sm_vid, jr_id, PARTITION_1), PERM); /* construct aad for AES */ aad_w1 = (in_sz << OP_ALG_ALGSEL_SHIFT) | KEY_AES_SRC | LD_CCM_MODE; |