1 /*
2  * Copyright 2017-2021 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef CAAM_H
9 #define CAAM_H
10 
11 #include "caam_io.h"
12 #include "sec_jr_driver.h"
13 
14 
15 /* Job ring 3 is reserved for usage by sec firmware */
16 #define DEFAULT_JR	3
17 
18 #if defined(CONFIG_CHASSIS_3_2) || defined(CONFIG_CHASSIS_2)
19 #define CAAM_JR0_OFFSET			0x10000
20 #define CAAM_JR1_OFFSET			0x20000
21 #define CAAM_JR2_OFFSET			0x30000
22 #define CAAM_JR3_OFFSET			0x40000
23 #endif
24 
25 enum sig_alg {
26 	RSA,
27 	ECC
28 };
29 
30 /* This function does basic SEC Initialization */
31 int sec_init(uintptr_t nxp_caam_addr);
32 int config_sec_block(void);
33 uintptr_t get_caam_addr(void);
34 
35 /* This function is used to submit jobs to JR */
36 int run_descriptor_jr(struct job_descriptor *desc);
37 
38 /* This function is used to instatiate the HW RNG is already not instantiated */
39 int hw_rng_instantiate(void);
40 
41 /* This function is used to return random bytes of byte_len from HW RNG */
42 int get_rand_bytes_hw(uint8_t *bytes, int byte_len);
43 
44 /* This function is used to set the hw unique key from HW CAAM */
45 int get_hw_unq_key_blob_hw(uint8_t *hw_key, int size);
46 
47 /* This function is used to fetch random number from
48  * CAAM of length either of 4 bytes or 8 bytes depending
49  * rngWidth value.
50  */
51 unsigned long long get_random(int rngWidth);
52 
53 #endif /* CAAM_H */
54