1 /** mbed Microcontroller Library
2   ******************************************************************************
3   * @file    efuse_api.h
4   * @author
5   * @version V1.0.0
6   * @brief   This file provides mbed EFUSE API.
7   ******************************************************************************
8   * @attention
9   *
10   * Copyright (c) 2015, Realtek Semiconductor Corp.
11   * All rights reserved.
12   *
13   * This module is a confidential and proprietary property of RealTek and
14   * possession or use of this module requires written permission of RealTek.
15   ******************************************************************************
16   */
17 
18 #ifndef MBED_EXT_EFUSE_API_EXT_H
19 #define MBED_EXT_EFUSE_API_EXT_H
20 
21 #include "device.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /** @addtogroup efuse EFUSE
28  *  @ingroup    hal
29  *  @brief      efuse functions
30  *  @{
31  */
32 
33 ///@name Ameba Common
34 ///@{
35 
36 /**
37   * @brief  Get remaining efuse length
38   * @retval : remaining efuse length
39   */
40 int efuse_get_remaining_length(void);
41 
42 /**
43   * @brief  Read efuse contant of specified user
44   * @param  data: Specified the address to save the readback data.
45   * @retval none
46   */
47 void efuse_mtp_read(uint8_t * data);
48 
49 /**
50   * @brief  Write user's contant to efuse
51   * @param  data: Specified the data to be programmed.
52   * @param  len: Specifies the data length of programmed data.
53   * @retval value:
54   *          - 0~32: Success
55   *          - -1: Failure
56   */
57 int efuse_mtp_write(uint8_t *data, uint8_t len);
58 
59 /**
60   * @brief  Read efuse OTP contant
61   * @param  address: Specifies the offset of the OTP.
62   * @param  len: Specifies the length of readback data.
63   * @param  buf: Specified the address to save the readback data.
64   * @retval 0: Success
65   * @retval -1: Failure
66   */
67 int efuse_otp_read(u8 address, u8 len, u8 *buf);
68 
69 /**
70   * @brief  Write user's contant to OTP efuse
71   * @param  address: Specifies the offset of the programmed OTP.
72   * @param  len: Specifies the data length of programmed data.
73   * @param  buf: Specified the data to be programmed.
74   * @retval 0: Success
75   * @retval -1: Failure
76   */
77 int efuse_otp_write(u8 address, u8 len, u8 *buf);
78 
79 /**
80   * @brief  ckeck user's contant to OTP efuse
81   * @param  buf: Specified the data to be programmed.
82   * @param  len: Specifies the data length of programmed data.
83   * @retval 0: Success
84   * @retval -1: Failure
85   */
86 int efuse_otp_chk(u8 len, u8 *buf);
87 
88 /**
89   * @brief  Disable jtag
90   * @retval 0: Success
91   */
92 int efuse_disable_jtag(void);
93 
94 
95 ///@}
96 
97 #if defined(CONFIG_PLATFORM_8195A) && (CONFIG_PLATFORM_8195A == 1)
98 ///@name Ameba1 Only
99 ///@{
100 /**
101   * @brief  Write key1 to efuse
102   * @param  address: Specifies the offset of the programmed efuse.
103   * @param  len: Specifies the data length of programmed data.
104   * @param  buf: Specified the data to be programmed.
105   * @retval 0: Success
106   * @retval -1: Failure
107   */
108 int efuse_key1_write(u8 address, u8 len, u8 *buf);
109 
110 /**
111   * @brief  Write key2 to efuse
112   * @param  address: Specifies the offset of the programmed efuse.
113   * @param  len: Specifies the data length of programmed data.
114   * @param  buf: Specified the data to be programmed.
115   * @retval 0: Success
116   * @retval -1: Failure
117   */
118 int efuse_key2_write(u8 address, u8 len, u8 *buf);
119 ///@}
120 #endif //CONFIG_PLATFORM_8195A
121 
122 #if defined(CONFIG_PLATFORM_8711B) && (CONFIG_PLATFORM_8711B == 1)
123 ///@name AmebaZ Only
124 ///@{
125 /**
126   * @brief  Set RDP Enable.
127   * @param  none
128   * @note  can not change or read back after write.
129   */
130 void efuse_rdp_enable(void);
131 
132 /**
133   * @brief  Set 16B RDP key into EFUSE.
134   * @param  rdp_key: 16B EFUSE KEY
135   * @note  can not change or read back after write.
136   */
137 void efuse_rdp_keyset(u8 *rdp_key);
138 
139 /**
140   * @brief  Set 16B OTF key into EFUSE.
141   * @param  OtfKey: 16B EFUSE KEY
142   * @note  can not change or read back after write.
143   */
144 
145 void efuse_otf_keyset(u8 *otf_key);
146 ///@}
147 #endif //CONFIG_PLATFORM_8711B
148 
149 #if defined(CONFIG_PLATFORM_8195BLP) && (CONFIG_PLATFORM_8195BLP == 1)
150 ///@name AmebaPro Only
151 ///@{
152 /**
153   * @brief  Disable LP jtag
154   * @retval 0: Success
155   */
156 int efuse_disable_lp_jtag(void);
157 
158 /**
159   * @brief  Disable HS secure jtag
160   * @retval 0: Success
161   */
162 int efuse_disable_sec_jtag(void);
163 
164 /**
165   * @brief  Disable HS nonsecure jtag
166   * @retval 0: Success
167   */
168 int efuse_disable_nonsec_jtag(void);
169 ///@}
170 #endif  // end of "#if defined(CONFIG_PLATFORM_8195BLP)"
171 
172 #if defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)
173 ///@name AmebaPro Only
174 ///@{
175 /**
176   * @brief  Write secure key to efuse
177   * @param  buf: Specified the 32-byte security key to be programmed.
178   * @retval 0: Success
179   * @retval -1: Failure
180   */
181 int efuse_sec_key_write(u8 *buf);
182 
183 /**
184   * @brief  Write super secure key to efuse
185   * @param  buf: Specified the 32-byte super security key to be programmed.
186   * @retval 0: Success
187   * @retval -1: Failure
188   */
189 int efuse_susec_key_write(u8 *buf);
190 ///@}
191 #endif  // end of "#if defined(CONFIG_PLATFORM_8195BHP)"
192 
193 /*\@}*/
194 
195 #ifdef __cplusplus
196 }
197 #endif
198 
199 #endif // MBED_EXT_EFUSE_API_EXT_H
200