blob: 120da0854e44d22055a7d53ffd85f1f23e36f711 [file] [log] [blame]
Ye Li0db17f42021-08-07 16:00:41 +08001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Copyright 2021 NXP
4 */
5
Peng Fand5c31832023-06-15 18:09:05 +08006#ifndef __ELE_API_H__
7#define __ELE_API_H__
Ye Li0db17f42021-08-07 16:00:41 +08008
Peng Fand5c31832023-06-15 18:09:05 +08009#define ELE_VERSION 0x6
10#define ELE_CMD_TAG 0x17
11#define ELE_RESP_TAG 0xe1
Ye Li0db17f42021-08-07 16:00:41 +080012
Ye Lic9e34362023-01-30 18:39:51 +080013/* ELE commands */
14#define ELE_PING_REQ (0x01)
15#define ELE_FW_AUTH_REQ (0x02)
16#define ELE_RESTART_RST_TIMER_REQ (0x04)
17#define ELE_DUMP_DEBUG_BUFFER_REQ (0x21)
18#define ELE_OEM_CNTN_AUTH_REQ (0x87)
19#define ELE_VERIFY_IMAGE_REQ (0x88)
20#define ELE_RELEASE_CONTAINER_REQ (0x89)
21#define ELE_WRITE_SECURE_FUSE_REQ (0x91)
22#define ELE_FWD_LIFECYCLE_UP_REQ (0x95)
23#define ELE_READ_FUSE_REQ (0x97)
24#define ELE_GET_FW_VERSION_REQ (0x9D)
25#define ELE_RET_LIFECYCLE_UP_REQ (0xA0)
26#define ELE_GET_EVENTS_REQ (0xA2)
Peng Fand5c31832023-06-15 18:09:05 +080027#define ELE_START_RNG (0xA3)
28#define ELE_GENERATE_DEK_BLOB (0xAF)
Ye Lic9e34362023-01-30 18:39:51 +080029#define ELE_ENABLE_PATCH_REQ (0xC3)
30#define ELE_RELEASE_RDC_REQ (0xC4)
31#define ELE_GET_FW_STATUS_REQ (0xC5)
32#define ELE_ENABLE_OTFAD_REQ (0xC6)
33#define ELE_RESET_REQ (0xC7)
34#define ELE_UPDATE_OTP_CLKDIV_REQ (0xD0)
35#define ELE_POWER_DOWN_REQ (0xD1)
36#define ELE_ENABLE_APC_REQ (0xD2)
37#define ELE_ENABLE_RTC_REQ (0xD3)
38#define ELE_DEEP_POWER_DOWN_REQ (0xD4)
39#define ELE_STOP_RST_TIMER_REQ (0xD5)
40#define ELE_WRITE_FUSE_REQ (0xD6)
41#define ELE_RELEASE_CAAM_REQ (0xD7)
42#define ELE_RESET_A35_CTX_REQ (0xD8)
43#define ELE_MOVE_TO_UNSECURED_REQ (0xD9)
44#define ELE_GET_INFO_REQ (0xDA)
45#define ELE_ATTEST_REQ (0xDB)
46#define ELE_RELEASE_PATCH_REQ (0xDC)
47#define ELE_OTP_SEQ_SWITH_REQ (0xDD)
48
49/* ELE failure indications */
50#define ELE_ROM_PING_FAILURE_IND (0x0A)
51#define ELE_FW_PING_FAILURE_IND (0x1A)
52#define ELE_BAD_SIGNATURE_FAILURE_IND (0xF0)
53#define ELE_BAD_HASH_FAILURE_IND (0xF1)
54#define ELE_INVALID_LIFECYCLE_IND (0xF2)
55#define ELE_PERMISSION_DENIED_FAILURE_IND (0xF3)
56#define ELE_INVALID_MESSAGE_FAILURE_IND (0xF4)
57#define ELE_BAD_VALUE_FAILURE_IND (0xF5)
58#define ELE_BAD_FUSE_ID_FAILURE_IND (0xF6)
59#define ELE_BAD_CONTAINER_FAILURE_IND (0xF7)
60#define ELE_BAD_VERSION_FAILURE_IND (0xF8)
61#define ELE_INVALID_KEY_FAILURE_IND (0xF9)
62#define ELE_BAD_KEY_HASH_FAILURE_IND (0xFA)
63#define ELE_NO_VALID_CONTAINER_FAILURE_IND (0xFB)
64#define ELE_BAD_CERTIFICATE_FAILURE_IND (0xFC)
65#define ELE_BAD_UID_FAILURE_IND (0xFD)
66#define ELE_BAD_MONOTONIC_COUNTER_FAILURE_IND (0xFE)
67#define ELE_MUST_SIGNED_FAILURE_IND (0xE0)
68#define ELE_NO_AUTHENTICATION_FAILURE_IND (0xEE)
69#define ELE_BAD_SRK_SET_FAILURE_IND (0xEF)
70#define ELE_UNALIGNED_PAYLOAD_FAILURE_IND (0xA6)
71#define ELE_WRONG_SIZE_FAILURE_IND (0xA7)
72#define ELE_ENCRYPTION_FAILURE_IND (0xA8)
73#define ELE_DECRYPTION_FAILURE_IND (0xA9)
74#define ELE_OTP_PROGFAIL_FAILURE_IND (0xAA)
75#define ELE_OTP_LOCKED_FAILURE_IND (0xAB)
76#define ELE_OTP_INVALID_IDX_FAILURE_IND (0xAD)
77#define ELE_TIME_OUT_FAILURE_IND (0xB0)
78#define ELE_BAD_PAYLOAD_FAILURE_IND (0xB1)
79#define ELE_WRONG_ADDRESS_FAILURE_IND (0xB4)
80#define ELE_DMA_FAILURE_IND (0xB5)
81#define ELE_DISABLED_FEATURE_FAILURE_IND (0xB6)
82#define ELE_MUST_ATTEST_FAILURE_IND (0xB7)
83#define ELE_RNG_NOT_STARTED_FAILURE_IND (0xB8)
84#define ELE_CRC_ERROR_IND (0xB9)
85#define ELE_AUTH_SKIPPED_OR_FAILED_FAILURE_IND (0xBB)
86#define ELE_INCONSISTENT_PAR_FAILURE_IND (0xBC)
87#define ELE_RNG_INST_FAILURE_FAILURE_IND (0xBD)
88#define ELE_LOCKED_REG_FAILURE_IND (0xBE)
89#define ELE_BAD_ID_FAILURE_IND (0xBF)
90#define ELE_INVALID_OPERATION_FAILURE_IND (0xC0)
91#define ELE_NON_SECURE_STATE_FAILURE_IND (0xC1)
92#define ELE_MSG_TRUNCATED_IND (0xC2)
93#define ELE_BAD_IMAGE_NUM_FAILURE_IND (0xC3)
94#define ELE_BAD_IMAGE_ADDR_FAILURE_IND (0xC4)
95#define ELE_BAD_IMAGE_PARAM_FAILURE_IND (0xC5)
96#define ELE_BAD_IMAGE_TYPE_FAILURE_IND (0xC6)
97#define ELE_CORRUPTED_SRK_FAILURE_IND (0xD0)
98#define ELE_OUT_OF_MEMORY_IND (0xD1)
99#define ELE_CSTM_FAILURE_IND (0xCF)
100#define ELE_OLD_VERSION_FAILURE_IND (0xCE)
101#define ELE_WRONG_BOOT_MODE_FAILURE_IND (0xCD)
102#define ELE_APC_ALREADY_ENABLED_FAILURE_IND (0xCB)
103#define ELE_RTC_ALREADY_ENABLED_FAILURE_IND (0xCC)
104#define ELE_ABORT_IND (0xFF)
105
106/* ELE IPC identifier */
107#define ELE_IPC_MU_RTD (0x1)
108#define ELE_IPC_MU_APD (0x2)
109
110/* ELE Status*/
111#define ELE_SUCCESS_IND (0xD6)
112#define ELE_FAILURE_IND (0x29)
113
Peng Fand5c31832023-06-15 18:09:05 +0800114#define ELE_MAX_MSG 255U
Ye Li0db17f42021-08-07 16:00:41 +0800115
Peng Fand5c31832023-06-15 18:09:05 +0800116struct ele_msg {
Ye Li0db17f42021-08-07 16:00:41 +0800117 u8 version;
118 u8 size;
119 u8 command;
120 u8 tag;
Peng Fand5c31832023-06-15 18:09:05 +0800121 u32 data[(ELE_MAX_MSG - 1U)];
Ye Li0db17f42021-08-07 16:00:41 +0800122};
123
Peng Fand5c31832023-06-15 18:09:05 +0800124struct ele_get_info_data {
Peng Fancffe2b92022-07-26 16:40:52 +0800125 u32 hdr;
126 u32 soc;
127 u32 lc;
128 u32 uid[4];
129 u32 sha256_rom_patch[8];
130 u32 sha_fw[8];
Ye Lic30260e2023-01-31 16:42:26 +0800131 u32 oem_srkh[16];
132 u32 state;
Peng Fancffe2b92022-07-26 16:40:52 +0800133};
134
Peng Fand5c31832023-06-15 18:09:05 +0800135int ele_release_rdc(u8 core_id, u8 xrdc, u32 *response);
136int ele_auth_oem_ctnr(ulong ctnr_addr, u32 *response);
137int ele_release_container(u32 *response);
138int ele_verify_image(u32 img_id, u32 *response);
139int ele_forward_lifecycle(u16 life_cycle, u32 *response);
140int ele_write_fuse(u16 fuse_id, u32 fuse_val, bool lock, u32 *response);
141int ele_read_common_fuse(u16 fuse_id, u32 *fuse_words, u32 fuse_num, u32 *response);
142int ele_release_caam(u32 core_did, u32 *response);
143int ele_get_fw_version(u32 *fw_version, u32 *sha1, u32 *response);
144int ele_get_events(u32 *events, u32 *events_cnt, u32 *response);
145int ele_dump_buffer(u32 *buffer, u32 buffer_length);
146int ele_get_info(struct ele_get_info_data *info, u32 *response);
147int ele_get_fw_status(u32 *status, u32 *response);
148int ele_release_m33_trout(void);
Ye Lia61f2672021-08-07 16:00:52 +0800149
Ye Li0db17f42021-08-07 16:00:41 +0800150#endif