efuse-api.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright (C) 2021 Alibaba Group Holding Limited.
  4. *
  5. */
  6. #ifndef _EFUSE_API_H
  7. #define _EFUSE_API_H
  8. typedef enum {
  9. USR_DSP0_JTAG = 0,
  10. USR_DSP1_JTAG,
  11. USR_C910T_JTAG,
  12. USR_C910R_JTAG,
  13. USR_C906_JTAG,
  14. USR_E902_JTAG,
  15. USR_CHIP_DBG,
  16. USR_DFT,
  17. } efuse_dbg_type_t;
  18. typedef enum {
  19. DBG_MODE_ENABLE = 0,
  20. DBG_MODE_PWD_PROTECT,
  21. DBG_MODE_DISABLE,
  22. } efuse_dbg_mode_t;
  23. typedef enum {
  24. BROM_USBBOOT_EN= 0,
  25. BROM_USBBOOT_DIS = 0x5a5a5a5a,
  26. } brom_usbboot_st_t;
  27. typedef enum {
  28. BROM_CCT_EN= 0,
  29. BROM_CCT_DIS = 0x5a5a5a5a,
  30. } brom_cct_st_t;
  31. typedef enum {
  32. IMAGE_ENCRYPT_DIS= 0,
  33. IMAGE_ENCRYPT_EN = 0x5a5a5a5a,
  34. } img_encrypt_st_t;
  35. typedef enum {
  36. SECURE_BOOT_DIS= 0,
  37. SECURE_BOOT_EN = 0x5a5a5a5a,
  38. } sboot_st_t;
  39. /**
  40. * csi_efuse_get_chipid() - Get chip id in eFuse
  41. *
  42. * @chip_id: pointer to the buffer to store chip id
  43. *
  44. * Return: 0 on success or negative code on failure
  45. */
  46. int csi_efuse_get_chipid(void *chip_id);
  47. /**
  48. * csi_efuse_get_user_dbg_mode() - Get debug mode in user area
  49. *
  50. * @type: Debug type
  51. *
  52. * @dbg_mode: pointer to the buffer store debug mode
  53. *
  54. * Return: 0 on success or negative code on failure
  55. */
  56. int csi_efuse_get_user_dbg_mode(efuse_dbg_type_t type, efuse_dbg_mode_t *dbg_mode);
  57. /**
  58. * csi_efuse_set_user_dbg_mode() - Set debug mode in user area
  59. *
  60. * @type: Debug type
  61. *
  62. * @dbg_mode: debug mode
  63. *
  64. * Return: 0 on success or negative code on failure
  65. */
  66. int csi_efuse_set_user_dbg_mode(efuse_dbg_type_t type, efuse_dbg_mode_t dbg_mode);
  67. /**
  68. * csi_efuse_get_boot_offset() - Get BL1's offset in boot media
  69. *
  70. * @offset: pointer to the buffer to store BL1's offset
  71. *
  72. * Return: 0 on success or negative code on failure
  73. */
  74. int csi_efuse_get_boot_offset(unsigned int *offset);
  75. /**
  76. * csi_efuse_set_boot_offset() - Set BL1's offset in boot media
  77. *
  78. * @offset: Offset value to be set
  79. *
  80. * Return: 0 on success or negative code on failure
  81. */
  82. int csi_efuse_set_boot_offset(unsigned int offset);
  83. /**
  84. * csi_efuse_get_boot_index() - Get BL1's index in boot media
  85. *
  86. * @index: pointer to the buffer to store BL1's index
  87. *
  88. * Return: 0 on success or negative code on failure
  89. */
  90. int csi_efuse_get_boot_index(unsigned char *index);
  91. /**
  92. * csi_efuse_set_boot_index() - Set BL1's index in boot media
  93. *
  94. * @index: index value to be set
  95. *
  96. * Return: 0 on success or negative code on failure
  97. */
  98. int csi_efuse_set_boot_index(unsigned char index);
  99. /**
  100. * csi_efuse_get_bak_boot_offset() - Get BL1's offset in boot media
  101. *
  102. * @offset: pointer to the buffer to store BL1's offset
  103. *
  104. * Return: 0 on success or negative code on failure
  105. */
  106. int csi_efuse_get_bak_boot_offset(unsigned int *offset);
  107. /**
  108. * csi_efuse_set_boot_offset() - Set BL1's offset in boot media
  109. *
  110. * @offset: Offset value to be set
  111. *
  112. * Return: 0 on success or negative code on failure
  113. */
  114. int csi_efuse_set_bak_boot_offset(unsigned int offset);
  115. /**
  116. * csi_efuse_get_bak_boot_index() - Get BL1's index in boot media
  117. *
  118. * @index: pointer to the buffer to store BL1's index
  119. *
  120. * Return: 0 on success or negative code on failure
  121. */
  122. int csi_efuse_get_bak_boot_index(unsigned char *index);
  123. /**
  124. * csi_efuse_set_bak_boot_index() - Set BL1's index in boot media
  125. *
  126. * @index: index value to be set
  127. *
  128. * Return: 0 on success or negative code on failure
  129. */
  130. int csi_efuse_set_bak_boot_index(unsigned char index);
  131. /**
  132. * csi_efuse_get_usr_brom_usb_fastboot_st() - Get bootrom USB fastboots tatus in user area
  133. *
  134. * @status: pointer to the buffer to store USB fastboot status
  135. *
  136. * Return: 0 on success or negative code on failure
  137. */
  138. int csi_efuse_get_usr_brom_usb_fastboot_st(brom_usbboot_st_t *status);
  139. /**
  140. * csi_efuse_dis_usr_brom_usb_fastboot() - Disable bootrom USB fastboot status in user area
  141. *
  142. * Return: 0 on success or negative code on failure
  143. */
  144. int csi_efuse_dis_usr_brom_usb_fastboot(void);
  145. /**
  146. * csi_efuse_get_usr_brom_cct_st() - Get bootrom CCT status in user area
  147. *
  148. * @status: pointer to the buffer to store CCT
  149. *
  150. * Return: 0 on success or negative code on failure
  151. */
  152. int csi_efuse_get_usr_brom_cct_st(brom_cct_st_t *status);
  153. /**
  154. * csi_efuse_dis_usr_brom_cct() - Disable bootrom CCT status in user area
  155. *
  156. * Return: 0 on success or negative code on failure
  157. */
  158. int csi_efuse_dis_usr_brom_cct(void);
  159. /**
  160. * csi_efuse_get_bl2_img_encrypt_st() - Get BL2 image encryption flag
  161. *
  162. * @encrypt_flag: pointer to the buffer to store BL2 encryption flag
  163. *
  164. * Return: 0 on success or negative code on failure
  165. */
  166. int csi_efuse_get_bl2_img_encrypt_st( img_encrypt_st_t *encrypt_flag);
  167. /**
  168. * csi_efuse_set_bl2_img_encrypt_st() - Set BL2 image encryption flag
  169. *
  170. * @encrypt_flag: pointer to the buffer to store BL2 encryption flag
  171. *
  172. * Return: 0 on success or negative code on failure
  173. */
  174. int csi_efuse_set_bl2_img_encrypt_st( img_encrypt_st_t encrypt_flag);
  175. /**
  176. * csi_efuse_get_bl3_img_encrypt_st() - Get BL3 image encryption flag
  177. *
  178. * @encrypt_flag: pointer to the buffer to store BL2 encryption flag
  179. *
  180. * Return: 0 on success or negative code on failure
  181. */
  182. int csi_efuse_get_bl3_img_encrypt_st( img_encrypt_st_t *encrypt_flag);
  183. /**
  184. * csi_efuse_set_bl3_img_encrypt_st() - Set BL3 image encryption flag
  185. *
  186. * @encrypt_flag: pointer to the buffer to store BL3 encryption flag
  187. *
  188. * Return: 0 on success or negative code on failure
  189. */
  190. int csi_efuse_set_bl3_img_encrypt_st( img_encrypt_st_t encrypt_flag);
  191. /**
  192. * csi_efuse_get_bl4_img_encrypt_st() - Get BL4 image encryption flag
  193. *
  194. * @encrypt_flag: pointer to the buffer to store BL4 encryption flag
  195. *
  196. * Return: 0 on success or negative code on failure
  197. */
  198. int csi_efuse_get_bl4_img_encrypt_st( img_encrypt_st_t *encrypt_flag);
  199. /**
  200. * csi_efuse_set_bl4_img_encrypt_st() - Set BL4 image encryption flag
  201. *
  202. * @encrypt_flag: pointer to the buffer to store BL4 encryption flag
  203. *
  204. * Return: 0 on success or negative code on failure
  205. */
  206. int csi_efuse_set_bl4_img_encrypt_st( img_encrypt_st_t encrypt_flag);
  207. /**
  208. * csi_efuse_get_bl1_version() - Get BL1 version
  209. *
  210. * @version: pointer to the buffer to store BL1's version in eFuse
  211. *
  212. * Return: 0 on success or negative code on failure
  213. */
  214. int csi_efuse_get_bl1_version(unsigned long long *version);
  215. /**
  216. * csi_efuse_set_bl1_version() - Set BL1 version
  217. *
  218. * @version: pointer to the buffer to store BL1's version in eFuse
  219. *
  220. * Return: 0 on success or negative code on failure
  221. */
  222. int csi_efuse_set_bl1_version(unsigned long long version);
  223. /**
  224. * csi_efuse_get_bl2_version() - Get BL2 version
  225. *
  226. * @version: pointer to the buffer to store BL2's version in eFuse
  227. *
  228. * Return: 0 on success or negative code on failure
  229. */
  230. int csi_efuse_get_bl2_version(unsigned long long *version);
  231. /**
  232. * csi_efuse_set_bl2_version() - Set BL2 version
  233. *
  234. * @version: pointer to the buffer to store BL2's version in eFuse
  235. *
  236. * Return: 0 on success or negative code on failure
  237. */
  238. int csi_efuse_set_bl2_version(unsigned long long version);
  239. /**
  240. * csi_efuse_get_secure_boot_st() - Get seucre boot flag
  241. *
  242. * @sboot_flag: A pointer to the buffer to store secure boot flag
  243. *
  244. * Return: 0 on success or negative code on failure
  245. */
  246. int csi_efuse_get_secure_boot_st(sboot_st_t *sboot_flag);
  247. /**
  248. * csi_efuse_get_hash_challenge() - Get hash challenge in eFuse
  249. *
  250. * @hash_resp: pointer to the buffer to store hash response
  251. *
  252. * Return: 0 on success or negative code on failure
  253. */
  254. int csi_efuse_get_hash_challenge(void * hash_resp);
  255. /**
  256. * csi_efuse_get_userdata_group() - Get user data in corresponding eFuse block
  257. *
  258. * @key: pointer to the buffer to store user data
  259. * @block_num: the block number in eFuse
  260. *
  261. * Return: 0 on success or negative code on failure
  262. */
  263. int csi_efuse_get_userdata_group(unsigned char *key, unsigned char block_num);
  264. /**
  265. * csi_efuse_set_userdata_group() - Set user data corresponding eFuse block
  266. *
  267. * @key: pointer to the buffer to store user data
  268. * @block_num: the block number in eFuse
  269. *
  270. * Return: 0 on success or negative code on failure
  271. */
  272. int csi_efuse_set_userdata_group(unsigned char *key, unsigned char block_num);
  273. /**
  274. * csi_efuse_read() - Read data from eFuse
  275. *
  276. * @offset: offset address
  277. * @data: Pointer to a buffer storing the data read from eFuse
  278. * @cnt: Number of bytes need to be read
  279. *
  280. * Return: number of data items read or error code
  281. */
  282. int csi_efuse_read(unsigned int offset, void *data, unsigned int cnt);
  283. /**
  284. * csi_efuse_write() - Write data to eFuse
  285. *
  286. * @offset: offset address
  287. * @data: Pointer to a buffer storing the data write to eFuse
  288. * @cnt: Number of bytes need to be write
  289. *
  290. * Return: number of data items write or error code
  291. */
  292. int csi_efuse_write(unsigned int offset, void *data, unsigned int cnt);
  293. /**
  294. * csi_dbg_enable_c910t_jtag() - Enable C910 TEE core jtag
  295. *
  296. * Return: 0 on success or negative code on failure
  297. */
  298. int csi_dbg_enable_c910t_jtag(void);
  299. /**
  300. * csi_dbg_disable_c910t_jtag() - Disable C910 TEE core jtag
  301. *
  302. * Return: 0 on success or negative code on failure
  303. */
  304. int csi_dbg_disable_c910t_jtag(void);
  305. /**
  306. * csi_efuse_get_gmac_macaddr() - Get gmac0/gmac1 mac address in eFuse
  307. * @dev_id: '0' means gmac0, '1' means gmac1
  308. * @mac: the mac address string
  309. *
  310. * Return: 0: Success others: Failed
  311. */
  312. int csi_efuse_get_gmac_macaddr(int dev_id, unsigned char *mac);
  313. /**
  314. * csi_efuse_set_gmac_macaddr() - Set gmac0/gmac1 mac address in eFuse
  315. * @dev_id: '0' means gmac0, '1' means gmac1
  316. * @mac: the mac address string
  317. *
  318. * Return: 0: Success others: Failed
  319. */
  320. int csi_efuse_set_gmac_macaddr(int dev_id, unsigned char *mac);
  321. /**
  322. * csi_efuse_update_lc_rma() - Upate efuse life cycle RMA
  323. *
  324. * Return: 0: Success others: Failed
  325. */
  326. int csi_efuse_update_lc_rma();
  327. /**
  328. * csi_efuse_update_lc_rma() - Upate efuse life cycle RIP
  329. *
  330. * Return: 0: Success others: Failed
  331. */
  332. int csi_efuse_update_lc_rip();
  333. #endif