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.
8 * Copyright (c) 2016 NXP.
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_SEQ_IN_OUT_PTR_CMD_H__
42 #define __RTA_SEQ_IN_OUT_PTR_CMD_H__
44 extern enum rta_sec_era rta_sec_era;
46 /* Allowed SEQ IN PTR flags for each SEC Era. */
47 static const uint32_t seq_in_ptr_flags[] = {
48 RBS | INL | SGF | PRE | EXT | RTO,
49 RBS | INL | SGF | PRE | EXT | RTO | RJD,
50 RBS | INL | SGF | PRE | EXT | RTO | RJD,
51 RBS | INL | SGF | PRE | EXT | RTO | RJD,
52 RBS | INL | SGF | PRE | EXT | RTO | RJD | SOP,
53 RBS | INL | SGF | PRE | EXT | RTO | RJD | SOP,
54 RBS | INL | SGF | PRE | EXT | RTO | RJD | SOP,
55 RBS | INL | SGF | PRE | EXT | RTO | RJD | SOP
58 /* Allowed SEQ OUT PTR flags for each SEC Era. */
59 static const uint32_t seq_out_ptr_flags[] = {
61 SGF | PRE | EXT | RTO,
62 SGF | PRE | EXT | RTO,
63 SGF | PRE | EXT | RTO,
64 SGF | PRE | EXT | RTO | RST | EWS,
65 SGF | PRE | EXT | RTO | RST | EWS,
66 SGF | PRE | EXT | RTO | RST | EWS,
67 SGF | PRE | EXT | RTO | RST | EWS
71 rta_seq_in_ptr(struct program *program, uint64_t src,
72 uint32_t length, uint32_t flags)
74 uint32_t opcode = CMD_SEQ_IN_PTR;
75 unsigned int start_pc = program->current_pc;
78 /* Parameters checking */
79 if ((flags & RTO) && (flags & PRE)) {
80 pr_err("SEQ IN PTR: Invalid usage of RTO and PRE flags\n");
83 if (flags & ~seq_in_ptr_flags[rta_sec_era]) {
84 pr_err("SEQ IN PTR: Flag(s) not supported by SEC Era %d\n",
85 USER_SEC_ERA(rta_sec_era));
88 if ((flags & INL) && (flags & RJD)) {
89 pr_err("SEQ IN PTR: Invalid usage of INL and RJD flags\n");
92 if ((src) && (flags & (SOP | RTO | PRE))) {
93 pr_err("SEQ IN PTR: Invalid usage of RTO or PRE flag\n");
96 if ((flags & SOP) && (flags & (RBS | PRE | RTO | EXT))) {
97 pr_err("SEQ IN PTR: Invalid usage of SOP and (RBS or PRE or RTO or EXT) flags\n");
101 /* write flag fields */
116 if ((length >> 16) || (flags & EXT)) {
118 pr_err("SEQ IN PTR: Invalid usage of SOP and EXT flags\n");
124 opcode |= length & SQIN_LEN_MASK;
127 __rta_out32(program, opcode);
128 program->current_instruction++;
130 /* write pointer or immediate data field */
131 if (!(opcode & (SQIN_PRE | SQIN_RTO | SQIN_SOP)))
132 __rta_out64(program, program->ps, src);
134 /* write extended length field */
135 if (opcode & SQIN_EXT)
136 __rta_out32(program, length);
138 return (int)start_pc;
141 program->first_error_pc = start_pc;
142 program->current_instruction++;
147 rta_seq_out_ptr(struct program *program, uint64_t dst,
148 uint32_t length, uint32_t flags)
150 uint32_t opcode = CMD_SEQ_OUT_PTR;
151 unsigned int start_pc = program->current_pc;
154 /* Parameters checking */
155 if (flags & ~seq_out_ptr_flags[rta_sec_era]) {
156 pr_err("SEQ OUT PTR: Flag(s) not supported by SEC Era %d\n",
157 USER_SEC_ERA(rta_sec_era));
160 if ((flags & RTO) && (flags & PRE)) {
161 pr_err("SEQ OUT PTR: Invalid usage of RTO and PRE flags\n");
164 if ((dst) && (flags & (RTO | PRE))) {
165 pr_err("SEQ OUT PTR: Invalid usage of RTO or PRE flag\n");
168 if ((flags & RST) && !(flags & RTO)) {
169 pr_err("SEQ OUT PTR: RST flag must be used with RTO flag\n");
173 /* write flag fields */
184 if ((length >> 16) || (flags & EXT))
187 opcode |= length & SQOUT_LEN_MASK;
189 __rta_out32(program, opcode);
190 program->current_instruction++;
192 /* write pointer or immediate data field */
193 if (!(opcode & (SQOUT_PRE | SQOUT_RTO)))
194 __rta_out64(program, program->ps, dst);
196 /* write extended length field */
197 if (opcode & SQOUT_EXT)
198 __rta_out32(program, length);
200 return (int)start_pc;
203 program->first_error_pc = start_pc;
204 program->current_instruction++;
208 #endif /* __RTA_SEQ_IN_OUT_PTR_CMD_H__ */