2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
7 * Copyright 2008-2016 Freescale Semiconductor Inc.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * * Neither the name of the above-listed copyright holders nor the
18 * names of any contributors may be used to endorse or promote products
19 * derived from this software without specific prior written permission.
23 * ALTERNATIVELY, this software may be distributed under the terms of the
24 * GNU General Public License ("GPL") as published by the Free Software
25 * Foundation, either version 2 of that License or (at your option) any
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
32 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
41 #ifndef __RTA_HEADER_CMD_H__
42 #define __RTA_HEADER_CMD_H__
44 extern enum rta_sec_era rta_sec_era;
46 /* Allowed job header flags for each SEC Era. */
47 static const uint32_t job_header_flags[] = {
48 DNR | TD | MTD | SHR | REO,
49 DNR | TD | MTD | SHR | REO | RSMS,
50 DNR | TD | MTD | SHR | REO | RSMS,
51 DNR | TD | MTD | SHR | REO | RSMS,
52 DNR | TD | MTD | SHR | REO | RSMS | EXT,
53 DNR | TD | MTD | SHR | REO | RSMS | EXT,
54 DNR | TD | MTD | SHR | REO | RSMS | EXT,
55 DNR | TD | MTD | SHR | REO | EXT
58 /* Allowed shared header flags for each SEC Era. */
59 static const uint32_t shr_header_flags[] = {
63 DNR | SC | PD | CIF | RIF,
64 DNR | SC | PD | CIF | RIF,
65 DNR | SC | PD | CIF | RIF,
66 DNR | SC | PD | CIF | RIF,
67 DNR | SC | PD | CIF | RIF
71 rta_shr_header(struct program *program,
72 enum rta_share_type share,
73 unsigned int start_idx,
76 uint32_t opcode = CMD_SHARED_DESC_HDR;
77 unsigned int start_pc = program->current_pc;
79 if (flags & ~shr_header_flags[rta_sec_era]) {
80 pr_err("SHR_DESC: Flag(s) not supported by SEC Era %d\n",
81 USER_SEC_ERA(rta_sec_era));
87 opcode |= HDR_SHARE_ALWAYS;
90 opcode |= HDR_SHARE_SERIAL;
94 * opcode |= HDR_SHARE_NEVER;
95 * HDR_SHARE_NEVER is 0
99 opcode |= HDR_SHARE_WAIT;
102 pr_err("SHR_DESC: SHARE VALUE is not supported. SEC Program Line: %d\n",
103 program->current_pc);
108 opcode |= (start_idx << HDR_START_IDX_SHIFT) & HDR_START_IDX_MASK;
113 opcode |= HDR_CLEAR_IFIFO;
115 opcode |= HDR_SAVECTX;
117 opcode |= HDR_PROP_DNR;
121 __rta_out32(program, opcode);
122 program->current_instruction++;
124 if (program->current_instruction == 1)
125 program->shrhdr = program->buffer;
127 return (int)start_pc;
130 program->first_error_pc = start_pc;
131 program->current_instruction++;
136 rta_job_header(struct program *program,
137 enum rta_share_type share,
138 unsigned int start_idx,
139 uint64_t shr_desc, uint32_t flags,
142 uint32_t opcode = CMD_DESC_HDR;
143 uint32_t hdr_ext = 0;
144 unsigned int start_pc = program->current_pc;
146 if (flags & ~job_header_flags[rta_sec_era]) {
147 pr_err("JOB_DESC: Flag(s) not supported by SEC Era %d\n",
148 USER_SEC_ERA(rta_sec_era));
154 opcode |= HDR_SHARE_ALWAYS;
157 opcode |= HDR_SHARE_SERIAL;
161 * opcode |= HDR_SHARE_NEVER;
162 * HDR_SHARE_NEVER is 0
166 opcode |= HDR_SHARE_WAIT;
169 opcode |= HDR_SHARE_DEFER;
172 pr_err("JOB_DESC: SHARE VALUE is not supported. SEC Program Line: %d\n",
173 program->current_pc);
177 if ((flags & TD) && (flags & REO)) {
178 pr_err("JOB_DESC: REO flag not supported for trusted descriptors. SEC Program Line: %d\n",
179 program->current_pc);
183 if ((rta_sec_era < RTA_SEC_ERA_7) && (flags & MTD) && !(flags & TD)) {
184 pr_err("JOB_DESC: Trying to MTD a descriptor that is not a TD. SEC Program Line: %d\n",
185 program->current_pc);
189 if ((flags & EXT) && !(flags & SHR) && (start_idx < 2)) {
190 pr_err("JOB_DESC: Start index must be >= 2 in case of no SHR and EXT. SEC Program Line: %d\n",
191 program->current_pc);
196 opcode |= ((start_idx << HDR_START_IDX_SHIFT) & HDR_START_IDX_MASK);
201 if (ext_flags & DSV) {
202 hdr_ext |= HDR_EXT_DSEL_VALID;
203 hdr_ext |= ext_flags & DSEL_MASK;
206 if (ext_flags & FTD) {
207 if (rta_sec_era <= RTA_SEC_ERA_5) {
208 pr_err("JOB_DESC: Fake trusted descriptor not supported by SEC Era %d\n",
209 USER_SEC_ERA(rta_sec_era));
213 hdr_ext |= HDR_EXT_FTD;
221 opcode |= HDR_TRUSTED;
223 opcode |= HDR_MAKE_TRUSTED;
225 opcode |= HDR_REVERSE;
227 opcode |= HDR_SHARED;
229 __rta_out32(program, opcode);
230 program->current_instruction++;
232 if (program->current_instruction == 1) {
233 program->jobhdr = program->buffer;
235 if (opcode & HDR_SHARED)
236 __rta_out64(program, program->ps, shr_desc);
240 __rta_out32(program, hdr_ext);
242 /* Note: descriptor length is set in program_finalize routine */
243 return (int)start_pc;
246 program->first_error_pc = start_pc;
247 program->current_instruction++;
251 #endif /* __RTA_HEADER_CMD_H__ */