1 /*
2  * Copyright 2024 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 #ifndef FSL_ROMAPI_OTP_H_
7 #define FSL_ROMAPI_OTP_H_
8 
9 #include <stdlib.h>
10 #include <stdint.h>
11 #include "fsl_common.h"
12 
13 //!@brief OTP driver API Interface
14 typedef struct
15 {
16     uint32_t version;
17     void (*init)(void);
18     status_t (*deinit)(void);
19     status_t (*p_efuse_read)(uint32_t addr, uint32_t *data);
20     status_t (*p_efuse_program)(uint32_t addr, uint32_t data);
21 } ocotp_driver_t;
22 
23 /*******************************************************************************
24  * API
25  ******************************************************************************/
26 
27 #if defined(__cplusplus)
28 extern "C" {
29 #endif
30 
31 /*
32  * @brief Initialize OTP controller
33  *
34  * This function enables OTP Controller clock.
35  *
36  */
37 void otp_init(void);
38 
39 /*
40  * @brief De-Initialize OTP controller
41  *
42  * This functin disables OTP Controller Clock.
43  *
44  * @return
45  *      kStatus_Success
46  */
47 status_t otp_deinit(void);
48 
49 /*
50  * @brief Read Fuse value from OTP eFuse Block
51  *
52  * This function read fuse data from OTP Fuse block to specified data buffer.
53  *
54  * @param addr Fuse address
55  * @param data Buffer to hold the data read from OTP Fuse block
56  *
57  * @return kStatus_Success - Operation succeeded without error.
58  *         kStatus_Fail - The operation failed with a generic error.
59  *         kStatus_ReadOnly - Requested value cannot be changed because it is read-only.
60  *         kStatus_OutOfRange - Requested value is out of range.
61  *         kStatus_InvalidArgument - The requested command's argument is undefined.
62  *         kStatus_Timeout - A timeout occurred.
63  */
64 status_t otp_fuse_read(uint32_t addr, uint32_t *data);
65 
66 /*
67  * @brief Program value to OTP eFuse block
68  *
69  * This function program data to specified OTP Fuse address.
70  *
71  * @return kStatus_Success - Operation succeeded without error.
72  *         kStatus_Fail - The operation failed with a generic error.
73  *         kStatus_ReadOnly - Requested value cannot be changed because it is read-only.
74  *         kStatus_OutOfRange - Requested value is out of range.
75  *         kStatus_InvalidArgument - The requested command's argument is undefined.
76  *         kStatus_Timeout - A timeout occurred.
77  */
78 status_t otp_fuse_program(uint32_t addr, uint32_t data);
79 
80 /*
81  * @brief Return OTP controller version
82  *
83  * @return Version of the OCOTP controller
84  */
85 uint32_t otp_version(void);
86 #endif /* FSL_ROMAPI_OTP_H_ */
87