blob: 4984b542390dd2305d391d907914e6b860712ebc [file] [log] [blame]
Pankaj Gupta95c7eee2020-12-09 14:02:39 +05301/*
Pankaj Gupta7834b462021-03-25 15:15:52 +05302 * Copyright 2017-2021 NXP
Pankaj Gupta95c7eee2020-12-09 14:02:39 +05303 *
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
25enum sig_alg {
26 RSA,
27 ECC
28};
29
30/* This function does basic SEC Initialization */
31int sec_init(uintptr_t nxp_caam_addr);
32int config_sec_block(void);
33uintptr_t get_caam_addr(void);
34
35/* This function is used to submit jobs to JR */
36int run_descriptor_jr(struct job_descriptor *desc);
37
38/* This function is used to instatiate the HW RNG is already not instantiated */
39int hw_rng_instantiate(void);
40
41/* This function is used to return random bytes of byte_len from HW RNG */
42int 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 */
45int 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 */
51unsigned long long get_random(int rngWidth);
52
53#endif /* CAAM_H */