1 /* 2 * Copyright 2021-2023 NXP 3 * All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 #ifndef __FSL_OCOTP_H_ 9 #define __FSL_OCOTP_H_ 10 11 #include "fsl_common.h" 12 /*! 13 * @addtogroup ocotp 14 * @{ 15 */ 16 17 /*! @file */ 18 19 /******************************************************************************* 20 * Definitions 21 ******************************************************************************/ 22 23 /*! @name Driver version */ 24 /*@{*/ 25 /*! @brief OCOTP driver version 2.2.1. */ 26 #define FSL_OCOTP_DRIVER_VERSION (MAKE_VERSION(2, 2, 1)) 27 /*@}*/ 28 29 /*! @brief OCOTP unique ID length. */ 30 #define FSL_OCOTP_UID_LENGTH 16U 31 32 /*! @brief OTP Status Group */ 33 enum 34 { 35 kStatusGroup_OtpGroup = 0x210, 36 }; 37 38 /*! @brief OTP Error Status definitions */ 39 enum 40 { 41 kStatus_OTP_InvalidAddress = MAKE_STATUS(kStatusGroup_OtpGroup, 1), /*!< Invalid OTP address */ 42 kStatus_OTP_Timeout = MAKE_STATUS(kStatusGroup_OtpGroup, 7), /*!< OTP operation time out */ 43 }; 44 45 /******************************************************************************* 46 * API 47 ******************************************************************************/ 48 #if defined(__cplusplus) 49 extern "C" { 50 #endif 51 52 /*! 53 * @brief Initialize OTP controller 54 * 55 * This function enables OTP Controller clock. 56 * 57 * @return kStatus_Success 58 */ 59 status_t OCOTP_OtpInit(void); 60 61 /*! 62 * @brief De-Initialize OTP controller 63 * 64 * This functin disables OTP Controller Clock. 65 * @return kStatus_Success 66 */ 67 status_t OCOTP_OtpDeinit(void); 68 69 /*! 70 * @brief Read Fuse value from OTP Fuse Block 71 * 72 * This function read fuse data from OTP Fuse block to specified data buffer. 73 * 74 * @param addr Fuse address 75 * @param data Buffer to hold the data read from OTP Fuse block 76 * @return kStatus_Success - Data read from OTP Fuse block successfully 77 * kStatus_OTP_Timeout - OTP read timeout 78 * kStatus_InvalidArgument - data pointer is invalid 79 */ 80 status_t OCOTP_OtpFuseRead(uint32_t addr, uint32_t *data); 81 82 /*! 83 * @brief Read Fuse line with specific tag value from SoC OTP 84 * 85 * This function read Fuse line with specific tag value from SoC OTP to specified data buffer. 86 * 87 * @param data Buffer to hold the data read from SoC OTP 88 * @param tag Tag value to match 89 * @return kStatus_Success - Data read from SoC OTP successfully 90 * kStatus_Fail - Data read from SoC OTP failed, or cannot find the tag 91 * kStatus_InvalidArgument - data pointer is invalid 92 */ 93 status_t OCOTP_ReadSocOtp(uint64_t *data, uint32_t tag); 94 95 /*! 96 * @brief Read unique ID from OTP Fuse Block 97 * 98 * This function read unique ID from OTP Fuse block to specified data buffer. 99 * 100 * @param uid The buffer to store unique ID, buffer byte length is FSL_OCOTP_UID_LENGTH. 101 * @param idLen[in/out] The unique ID byte length. Set the length to read, return the length read out. 102 * @return kStatus_Success - Data read from OTP Fuse block successfully 103 * kStatus_OTP_Timeout - OTP read timeout 104 * kStatus_InvalidArgument - data pointer is invalid 105 */ 106 status_t OCOTP_ReadUniqueID(uint8_t *uid, uint32_t *idLen); 107 108 /*! 109 * @brief Read Static Voltage Compansation from SOC OTP 110 * 111 * This function read SVC from OTP Fuse block to specified data buffer. 112 * 113 * @param svc The buffer to store SVC. 114 * @return kStatus_Success - Data read from SOC OTP successfully 115 * kStatus_Fail - SOC OTP read failure 116 */ 117 status_t OCOTP_ReadSVC(uint64_t *svc); 118 119 /*! 120 * @brief Read package type from SOC OTP 121 * 122 * @param pack The buffer to store package type. 123 * @return kStatus_Success - Data read from SOC OTP successfully 124 * kStatus_Fail - SOC OTP read failure 125 */ 126 status_t OCOTP_ReadPackage(uint32_t *pack); 127 128 #if defined(__cplusplus) 129 } 130 #endif 131 132 /*! @}*/ 133 134 #endif /* __FSL_OCOTP_H_ */ 135