1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright 2018-2019 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 #ifdef CFG_DT
31 /*
32  * Returns the Job Ring configuration to be used by the TEE
33  *
34  * @fdt         Device Tree handle
35  * @ctrl_base   [out] CAAM Controller base address
36  */
37 void caam_hal_cfg_get_ctrl_dt(void *fdt, vaddr_t *ctrl_base);
38 
39 /*
40  * Returns the Job Ring configuration to be used by the TEE
41  *
42  * @fdt     Device Tree handle
43  * @jrcfg   [out] Job Ring configuration
44  */
45 void caam_hal_cfg_get_jobring_dt(void *fdt, struct caam_jrcfg *jrcfg);
46 
47 /*
48  * Disable the DT node related to the Job Ring used by secure world
49  *
50  * @fdt     Device Tree handle
51  * @jrcfg   Job Ring configuration
52  */
53 void caam_hal_cfg_disable_jobring_dt(void *fdt, struct caam_jrcfg *jrcfg);
54 #else
caam_hal_cfg_get_ctrl_dt(void * fdt __unused,vaddr_t * ctrl_base)55 static inline void caam_hal_cfg_get_ctrl_dt(void *fdt __unused,
56 					    vaddr_t *ctrl_base)
57 {
58 	*ctrl_base = 0;
59 }
60 
61 static inline void
caam_hal_cfg_get_jobring_dt(void * fdt __unused,struct caam_jrcfg * jrcfg)62 caam_hal_cfg_get_jobring_dt(void *fdt __unused,
63 			    struct caam_jrcfg *jrcfg)
64 {
65 	jrcfg->offset = 0;
66 	jrcfg->it_num = 0;
67 }
68 
69 static inline void
caam_hal_cfg_disable_jobring_dt(void * fdt __unused,struct caam_jrcfg * jrcfg __unused)70 caam_hal_cfg_disable_jobring_dt(void *fdt __unused,
71 				struct caam_jrcfg *jrcfg __unused)
72 {
73 }
74 #endif /* CFG_DT */
75 
76 #endif /* __CAAM_HAL_CFG_H__ */
77