2 * Copyright 2008-2016 Freescale Semiconductor, Inc.
4 * SPDX-License-Identifier: BSD-3-Clause or GPL-2.0+
7 #ifndef __RTA_HEADER_CMD_H__
8 #define __RTA_HEADER_CMD_H__
10 extern enum rta_sec_era rta_sec_era;
12 /* Allowed job header flags for each SEC Era. */
13 static const uint32_t job_header_flags[] = {
14 DNR | TD | MTD | SHR | REO,
15 DNR | TD | MTD | SHR | REO | RSMS,
16 DNR | TD | MTD | SHR | REO | RSMS,
17 DNR | TD | MTD | SHR | REO | RSMS,
18 DNR | TD | MTD | SHR | REO | RSMS | EXT,
19 DNR | TD | MTD | SHR | REO | RSMS | EXT,
20 DNR | TD | MTD | SHR | REO | RSMS | EXT,
21 DNR | TD | MTD | SHR | REO | EXT
24 /* Allowed shared header flags for each SEC Era. */
25 static const uint32_t shr_header_flags[] = {
29 DNR | SC | PD | CIF | RIF,
30 DNR | SC | PD | CIF | RIF,
31 DNR | SC | PD | CIF | RIF,
32 DNR | SC | PD | CIF | RIF,
33 DNR | SC | PD | CIF | RIF
37 rta_shr_header(struct program *program,
38 enum rta_share_type share,
39 unsigned int start_idx,
42 uint32_t opcode = CMD_SHARED_DESC_HDR;
43 unsigned int start_pc = program->current_pc;
45 if (flags & ~shr_header_flags[rta_sec_era]) {
46 pr_err("SHR_DESC: Flag(s) not supported by SEC Era %d\n",
47 USER_SEC_ERA(rta_sec_era));
53 opcode |= HDR_SHARE_ALWAYS;
56 opcode |= HDR_SHARE_SERIAL;
60 * opcode |= HDR_SHARE_NEVER;
61 * HDR_SHARE_NEVER is 0
65 opcode |= HDR_SHARE_WAIT;
68 pr_err("SHR_DESC: SHARE VALUE is not supported. SEC Program Line: %d\n",
74 opcode |= (start_idx << HDR_START_IDX_SHIFT) & HDR_START_IDX_MASK;
79 opcode |= HDR_CLEAR_IFIFO;
81 opcode |= HDR_SAVECTX;
83 opcode |= HDR_PROP_DNR;
87 __rta_out32(program, opcode);
88 program->current_instruction++;
90 if (program->current_instruction == 1)
91 program->shrhdr = program->buffer;
96 program->first_error_pc = start_pc;
97 program->current_instruction++;
102 rta_job_header(struct program *program,
103 enum rta_share_type share,
104 unsigned int start_idx,
105 uint64_t shr_desc, uint32_t flags,
108 uint32_t opcode = CMD_DESC_HDR;
109 uint32_t hdr_ext = 0;
110 unsigned int start_pc = program->current_pc;
112 if (flags & ~job_header_flags[rta_sec_era]) {
113 pr_err("JOB_DESC: Flag(s) not supported by SEC Era %d\n",
114 USER_SEC_ERA(rta_sec_era));
120 opcode |= HDR_SHARE_ALWAYS;
123 opcode |= HDR_SHARE_SERIAL;
127 * opcode |= HDR_SHARE_NEVER;
128 * HDR_SHARE_NEVER is 0
132 opcode |= HDR_SHARE_WAIT;
135 opcode |= HDR_SHARE_DEFER;
138 pr_err("JOB_DESC: SHARE VALUE is not supported. SEC Program Line: %d\n",
139 program->current_pc);
143 if ((flags & TD) && (flags & REO)) {
144 pr_err("JOB_DESC: REO flag not supported for trusted descriptors. SEC Program Line: %d\n",
145 program->current_pc);
149 if ((rta_sec_era < RTA_SEC_ERA_7) && (flags & MTD) && !(flags & TD)) {
150 pr_err("JOB_DESC: Trying to MTD a descriptor that is not a TD. SEC Program Line: %d\n",
151 program->current_pc);
155 if ((flags & EXT) && !(flags & SHR) && (start_idx < 2)) {
156 pr_err("JOB_DESC: Start index must be >= 2 in case of no SHR and EXT. SEC Program Line: %d\n",
157 program->current_pc);
162 opcode |= ((start_idx << HDR_START_IDX_SHIFT) & HDR_START_IDX_MASK);
167 if (ext_flags & DSV) {
168 hdr_ext |= HDR_EXT_DSEL_VALID;
169 hdr_ext |= ext_flags & DSEL_MASK;
172 if (ext_flags & FTD) {
173 if (rta_sec_era <= RTA_SEC_ERA_5) {
174 pr_err("JOB_DESC: Fake trusted descriptor not supported by SEC Era %d\n",
175 USER_SEC_ERA(rta_sec_era));
179 hdr_ext |= HDR_EXT_FTD;
187 opcode |= HDR_TRUSTED;
189 opcode |= HDR_MAKE_TRUSTED;
191 opcode |= HDR_REVERSE;
193 opcode |= HDR_SHARED;
195 __rta_out32(program, opcode);
196 program->current_instruction++;
198 if (program->current_instruction == 1) {
199 program->jobhdr = program->buffer;
201 if (opcode & HDR_SHARED)
202 __rta_out64(program, program->ps, shr_desc);
206 __rta_out32(program, hdr_ext);
208 /* Note: descriptor length is set in program_finalize routine */
209 return (int)start_pc;
212 program->first_error_pc = start_pc;
213 program->current_instruction++;
217 #endif /* __RTA_HEADER_CMD_H__ */