1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
3 * Copyright 2008-2016 Freescale Semiconductor Inc.
8 #ifndef __RTA_HEADER_CMD_H__
9 #define __RTA_HEADER_CMD_H__
11 extern enum rta_sec_era rta_sec_era;
13 /* Allowed job header flags for each SEC Era. */
14 static const uint32_t job_header_flags[] = {
15 DNR | TD | MTD | SHR | REO,
16 DNR | TD | MTD | SHR | REO | RSMS,
17 DNR | TD | MTD | SHR | REO | RSMS,
18 DNR | TD | MTD | SHR | REO | RSMS,
19 DNR | TD | MTD | SHR | REO | RSMS | EXT,
20 DNR | TD | MTD | SHR | REO | RSMS | EXT,
21 DNR | TD | MTD | SHR | REO | RSMS | EXT,
22 DNR | TD | MTD | SHR | REO | EXT
25 /* Allowed shared header flags for each SEC Era. */
26 static const uint32_t shr_header_flags[] = {
30 DNR | SC | PD | CIF | RIF,
31 DNR | SC | PD | CIF | RIF,
32 DNR | SC | PD | CIF | RIF,
33 DNR | SC | PD | CIF | RIF,
34 DNR | SC | PD | CIF | RIF
38 rta_shr_header(struct program *program,
39 enum rta_share_type share,
40 unsigned int start_idx,
43 uint32_t opcode = CMD_SHARED_DESC_HDR;
44 unsigned int start_pc = program->current_pc;
46 if (flags & ~shr_header_flags[rta_sec_era]) {
47 pr_err("SHR_DESC: Flag(s) not supported by SEC Era %d\n",
48 USER_SEC_ERA(rta_sec_era));
54 opcode |= HDR_SHARE_ALWAYS;
57 opcode |= HDR_SHARE_SERIAL;
61 * opcode |= HDR_SHARE_NEVER;
62 * HDR_SHARE_NEVER is 0
66 opcode |= HDR_SHARE_WAIT;
69 pr_err("SHR_DESC: SHARE VALUE is not supported. SEC Program Line: %d\n",
75 opcode |= (start_idx << HDR_START_IDX_SHIFT) & HDR_START_IDX_MASK;
80 opcode |= HDR_CLEAR_IFIFO;
82 opcode |= HDR_SAVECTX;
84 opcode |= HDR_PROP_DNR;
88 __rta_out32(program, opcode);
89 program->current_instruction++;
91 if (program->current_instruction == 1)
92 program->shrhdr = program->buffer;
97 program->first_error_pc = start_pc;
98 program->current_instruction++;
103 rta_job_header(struct program *program,
104 enum rta_share_type share,
105 unsigned int start_idx,
106 uint64_t shr_desc, uint32_t flags,
109 uint32_t opcode = CMD_DESC_HDR;
110 uint32_t hdr_ext = 0;
111 unsigned int start_pc = program->current_pc;
113 if (flags & ~job_header_flags[rta_sec_era]) {
114 pr_err("JOB_DESC: Flag(s) not supported by SEC Era %d\n",
115 USER_SEC_ERA(rta_sec_era));
121 opcode |= HDR_SHARE_ALWAYS;
124 opcode |= HDR_SHARE_SERIAL;
128 * opcode |= HDR_SHARE_NEVER;
129 * HDR_SHARE_NEVER is 0
133 opcode |= HDR_SHARE_WAIT;
136 opcode |= HDR_SHARE_DEFER;
139 pr_err("JOB_DESC: SHARE VALUE is not supported. SEC Program Line: %d\n",
140 program->current_pc);
144 if ((flags & TD) && (flags & REO)) {
145 pr_err("JOB_DESC: REO flag not supported for trusted descriptors. SEC Program Line: %d\n",
146 program->current_pc);
150 if ((rta_sec_era < RTA_SEC_ERA_7) && (flags & MTD) && !(flags & TD)) {
151 pr_err("JOB_DESC: Trying to MTD a descriptor that is not a TD. SEC Program Line: %d\n",
152 program->current_pc);
156 if ((flags & EXT) && !(flags & SHR) && (start_idx < 2)) {
157 pr_err("JOB_DESC: Start index must be >= 2 in case of no SHR and EXT. SEC Program Line: %d\n",
158 program->current_pc);
163 opcode |= ((start_idx << HDR_START_IDX_SHIFT) & HDR_START_IDX_MASK);
168 if (ext_flags & DSV) {
169 hdr_ext |= HDR_EXT_DSEL_VALID;
170 hdr_ext |= ext_flags & DSEL_MASK;
173 if (ext_flags & FTD) {
174 if (rta_sec_era <= RTA_SEC_ERA_5) {
175 pr_err("JOB_DESC: Fake trusted descriptor not supported by SEC Era %d\n",
176 USER_SEC_ERA(rta_sec_era));
180 hdr_ext |= HDR_EXT_FTD;
188 opcode |= HDR_TRUSTED;
190 opcode |= HDR_MAKE_TRUSTED;
192 opcode |= HDR_REVERSE;
194 opcode |= HDR_SHARED;
196 __rta_out32(program, opcode);
197 program->current_instruction++;
199 if (program->current_instruction == 1) {
200 program->jobhdr = program->buffer;
202 if (opcode & HDR_SHARED)
203 __rta_out64(program, program->ps, shr_desc);
207 __rta_out32(program, hdr_ext);
209 /* Note: descriptor length is set in program_finalize routine */
210 return (int)start_pc;
213 program->first_error_pc = start_pc;
214 program->current_instruction++;
218 #endif /* __RTA_HEADER_CMD_H__ */