1 /*
2 * file otp.h
3 *
4 * API and data structures for OTP driver.
5 *
6 * ============================================================================
7 * (C) Copyright 2012, Texas Instruments, Inc.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the
19 * distribution.
20 *
21 * Neither the name of Texas Instruments Incorporated nor the names of
22 * its contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 * \par
38 */
40 #ifndef OTP_H_
41 #define OTP_H_
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
47 #include <ti/csl/tistdtypes.h>
49 /* SMEK, SMPK Defines */
50 #define OTP_SMEK_SIZE_32BIT_WORDS ((Uint16) 5) /* 4 key words + 1 ECC word */
51 #define OTP_SMPK_SIZE_32BIT_WORDS ((Uint16) 10) /* 8 hash words + 2 ECC words */
53 /* eFuse Programming defines */
54 #define OTP_MAX_WRITE_ATTEMPTS ((Uint16) 0xF)
56 /* OTP status */
57 typedef enum {
58 /* EFUSE return codes */
60 /** No error - Instruction completed successfully */
61 Otp_status_INSTRUCTION_SUCCESSFUL = 0,
62 /** Error: Time-out */
63 Otp_status_TIMEOUT = 1,
64 /** Error: Autoload - Not enough data to fill scan chain */
65 Otp_status_AUTOLOAD_NOT_ENOUGH_DATA = 2,
66 /** Error: Autoload - Wrong signature */
67 Otp_status_AUTOLOAD_WRONG_SIGNATURE = 3,
68 /** Error: Autoload or program operation interrupted */
69 Otp_status_PROGRAM_INTERRUPTION = 4,
71 /** Value of 5 not used */
73 /** Error: Write protection bit is set */
74 Otp_status_WRITE_PROTECT_SET = 6,
75 /** Error: Exceeded max write attempts allowed */
76 Otp_status_EXCEEDED_MAX_WR_ATTEMPTS = 7,
77 /** Error: Exceeded max control bit write attempts allowed */
78 Otp_status_EXCEEDED_MAX_CNTRL_BIT_WR_ATTEMPTS = 8,
79 /** Error: Some found to be set by test unprogrammed instruction */
80 Otp_status_TEST_RAW_SOME_BIT_SET = 9,
82 /** Value of 10 not used */
84 /** Error: Exceeded max CRA write attempts allowed */
85 Otp_status_EXCEEDED_MAX_CRA_WR_ATTEMTPS = 11,
86 /** Error: Address previously programmed with same data */
87 Otp_status_ADDRESS_PROGRAMMED_WITH_SAME_DATA = 12,
88 /** Inform: Program_compare_disable set when programming. */
89 Otp_status_PROGRAM_COMP_DISABLE_SET_DURING_WR = 13,
90 /** Error: Program aborted due to no row repair but repair bit set */
91 Otp_status_ABORT_PROGRAM_INVALID_ROW_REPAIR = 14,
92 /** Error: Program instruction executed with improper key value */
93 Otp_status_IMPROPER_KEY_VALUE = 15,
95 /** Values of 16 and 17 not used */
97 /** Error: Autoload operation incomplete */
98 Otp_status_INCOMPLETE_AUTOLOAD = 18,
99 /** Error: Autoload last row stuck */
100 Otp_status_AUTOLOAD_LAST_ROW_STUCK = 19,
102 /* OTP Driver error codes */
104 /** Error: The Key Mgr or Key specified is out of the hardware's range */
105 Otp_status_KEY_MGR_OR_KEY_OUT_OF_RANGE = 20,
106 /** Error: A read protect on a row was attempted without write protect being
107 * set as well */
108 Otp_status_READ_PROTECT_WITHOUT_WRITE_PROTECT = 21,
109 /** Error: Data read from eFuse just after write was not the same. Write error */
110 Otp_status_READ_DATA_NOT_SAME_AS_WRITTEN = 22
111 } Otp_Status;
113 typedef struct
114 {
115 Uint16 maxWrAttempts;
116 /* Once writeProtect is set no further private bit settings can occur.
117 * readProtect cannot be set without writeProtect. An error will be returned if this is attempted */
118 Bool writeProtect;
119 Bool readProtect;
120 } Otp_writeCfg;
122 /* SMEK APIs */
123 extern Otp_Status Otp_smekWrite (Uint32 *smekDataPtr, Otp_writeCfg *otpWrCfg);
125 /* SMPK APIs */
126 extern Otp_Status Otp_smpkWrite (Uint32 *smpkDataPtr, Otp_writeCfg *otpWrCfg);
128 /* OTP APIs */
129 extern Otp_Status Otp_otpWrite (Uint32 *otpDataPtr, Uint16 otpKeyMgr, Uint16 otpKey,
130 Otp_writeCfg *otpWrCfg);
131 extern Otp_Status Otp_otpSetPrivate (Uint16 otpKeyMgr, Uint16 otpKey, Otp_writeCfg *otpWrCfg);
133 #ifdef __cplusplus
134 }
135 #endif
137 #endif /* OTP_H_ */