xref: /optee_os/core/drivers/crypto/caam/include/caam_hal_cfg.h (revision 75be62aebb3981aa5e6c6b7159228af77d46374f)
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright 2018-2019, 2024 NXP
4  *
5  * Brief   CAAM Configuration header.
6  */
7 #ifndef __CAAM_HAL_CFG_H__
8 #define __CAAM_HAL_CFG_H__
9 
10 #include <caam_jr.h>
11 
12 /*
13  * Returns the Job Ring Configuration to be used by the TEE
14  *
15  * @jrcfg   [out] Job Ring Configuration
16  *
17  * Returns:
18  * CAAM_NO_ERROR   Success
19  * CAAM_FAILURE    An error occurred
20  */
21 enum caam_status caam_hal_cfg_get_conf(struct caam_jrcfg *jrcfg);
22 
23 /*
24  * Setup the Non-Secure Job Ring
25  *
26  * @jrcfg   Job Ring configuration
27  */
28 void caam_hal_cfg_setup_nsjobring(struct caam_jrcfg *jrcfg);
29 
30 /*
31  * Removes the JR used by HAB from dtb and backup its DID
32  *
33  * @jrcfg   Job Ring configuration of HAB JR
34  */
35 void caam_hal_cfg_hab_jr_mgmt(struct caam_jrcfg *jrcfg);
36 
37 /*
38  * Indicate if the job ring is used by the HAB
39  *
40  * @jr_offset   Job Ring offset
41  */
42 bool caam_hal_cfg_is_hab_jr(paddr_t jr_offset);
43 
44 #ifdef CFG_DT
45 /*
46  * Returns the Job Ring configuration to be used by the TEE
47  *
48  * @fdt         Device Tree handle
49  * @ctrl_base   [out] CAAM Controller base address
50  */
51 void caam_hal_cfg_get_ctrl_dt(void *fdt, vaddr_t *ctrl_base);
52 
53 /*
54  * Returns the Job Ring configuration to be used by the TEE
55  *
56  * @fdt     Device Tree handle
57  * @jrcfg   [out] Job Ring configuration
58  */
59 void caam_hal_cfg_get_jobring_dt(void *fdt, struct caam_jrcfg *jrcfg);
60 
61 /*
62  * Disable the DT node related to the Job Ring used by secure world
63  *
64  * @fdt     Device Tree handle
65  * @jrcfg   Job Ring configuration
66  */
67 void caam_hal_cfg_disable_jobring_dt(void *fdt, struct caam_jrcfg *jrcfg);
68 #else
caam_hal_cfg_get_ctrl_dt(void * fdt __unused,vaddr_t * ctrl_base)69 static inline void caam_hal_cfg_get_ctrl_dt(void *fdt __unused,
70 					    vaddr_t *ctrl_base)
71 {
72 	*ctrl_base = 0;
73 }
74 
75 static inline void
caam_hal_cfg_get_jobring_dt(void * fdt __unused,struct caam_jrcfg * jrcfg)76 caam_hal_cfg_get_jobring_dt(void *fdt __unused,
77 			    struct caam_jrcfg *jrcfg)
78 {
79 	jrcfg->offset = 0;
80 	jrcfg->it_num = 0;
81 }
82 
83 static inline void
caam_hal_cfg_disable_jobring_dt(void * fdt __unused,struct caam_jrcfg * jrcfg __unused)84 caam_hal_cfg_disable_jobring_dt(void *fdt __unused,
85 				struct caam_jrcfg *jrcfg __unused)
86 {
87 }
88 #endif /* CFG_DT */
89 
90 #endif /* __CAAM_HAL_CFG_H__ */
91