9 #define IMMEDIATE (1 << 23)
10 #define CAAM_CMD_SZ sizeof(u32)
11 #define CAAM_PTR_SZ sizeof(dma_addr_t)
12 #define CAAM_DESC_BYTES_MAX (CAAM_CMD_SZ * MAX_CAAM_DESCSIZE)
15 #define PRINT_POS do { printk(KERN_DEBUG "%02d: %s\n", desc_len(desc),\
16 &__func__[sizeof("append")]); } while (0)
21 #define SET_OK_NO_PROP_ERRORS (IMMEDIATE | LDST_CLASS_DECO | \
22 LDST_SRCDST_WORD_DECOCTRL | \
23 (LDOFF_CHG_SHARE_OK_NO_PROP << \
25 #define DISABLE_AUTO_INFO_FIFO (IMMEDIATE | LDST_CLASS_DECO | \
26 LDST_SRCDST_WORD_DECOCTRL | \
27 (LDOFF_DISABLE_AUTO_NFIFO << LDST_OFFSET_SHIFT))
28 #define ENABLE_AUTO_INFO_FIFO (IMMEDIATE | LDST_CLASS_DECO | \
29 LDST_SRCDST_WORD_DECOCTRL | \
30 (LDOFF_ENABLE_AUTO_NFIFO << LDST_OFFSET_SHIFT))
32 static inline int desc_len(
u32 *
desc)
37 static inline int desc_bytes(
void *
desc)
44 return desc + desc_len(desc);
47 static inline void *sh_desc_pdb(
u32 *
desc)
54 *desc = (options |
HDR_ONE) + 1;
71 static inline void init_job_desc(
u32 *desc,
u32 options)
85 static inline void init_job_desc_shared(
u32 *desc,
dma_addr_t ptr,
int len,
91 append_ptr(desc, ptr);
94 static inline void append_data(
u32 *desc,
void *
data,
int len)
96 u32 *offset = desc_end(desc);
106 u32 *
cmd = desc_end(desc);
113 static inline void append_cmd_ptr(
u32 *desc,
dma_addr_t ptr,
int len,
116 append_cmd(desc, command | len);
117 append_ptr(desc, ptr);
121 static inline void append_cmd_ptr_extlen(
u32 *desc,
dma_addr_t ptr,
124 append_cmd(desc, command);
125 append_ptr(desc, ptr);
126 append_cmd(desc, len);
129 static inline void append_cmd_data(
u32 *desc,
void *data,
int len,
132 append_cmd(desc, command |
IMMEDIATE | len);
133 append_data(desc, data, len);
136 static inline u32 *append_jump(
u32 *desc,
u32 options)
138 u32 *
cmd = desc_end(desc);
141 append_cmd(desc,
CMD_JUMP | options);
146 static inline void set_jump_tgt_here(
u32 *desc,
u32 *jump_cmd)
148 *jump_cmd = *jump_cmd | (desc_len(desc) - (jump_cmd - desc));
151 #define APPEND_CMD(cmd, op) \
152 static inline void append_##cmd(u32 *desc, u32 options) \
155 append_cmd(desc, CMD_##op | options); \
160 #define APPEND_CMD_LEN(cmd, op) \
161 static inline void append_##cmd(u32 *desc, unsigned int len, u32 options) \
164 append_cmd(desc, CMD_##op | len | options); \
170 #define APPEND_CMD_PTR(cmd, op) \
171 static inline void append_##cmd(u32 *desc, dma_addr_t ptr, unsigned int len, \
175 append_cmd_ptr(desc, ptr, len, CMD_##op | options); \
183 #define APPEND_SEQ_PTR_INTLEN(cmd, op) \
184 static inline void append_seq_##cmd##_ptr_intlen(u32 *desc, dma_addr_t ptr, \
189 append_cmd_ptr(desc, ptr, len, CMD_SEQ_##op##_PTR | options); \
194 #define APPEND_CMD_PTR_TO_IMM(cmd, op) \
195 static inline void append_##cmd##_as_imm(u32 *desc, void *data, \
196 unsigned int len, u32 options) \
199 append_cmd_data(desc, data, len, CMD_##op | options); \
204 #define APPEND_CMD_PTR_EXTLEN(cmd, op) \
205 static inline void append_##cmd##_extlen(u32 *desc, dma_addr_t ptr, \
206 unsigned int len, u32 options) \
209 append_cmd_ptr_extlen(desc, ptr, len, CMD_##op | SQIN_EXT | options); \
218 #define APPEND_CMD_PTR_LEN(cmd, op, type) \
219 static inline void append_##cmd(u32 *desc, dma_addr_t ptr, \
220 type len, u32 options) \
223 if (sizeof(type) > sizeof(u16)) \
224 append_##cmd##_extlen(desc, ptr, len, options); \
226 append_##cmd##_intlen(desc, ptr, len, options); \
235 #define APPEND_CMD_PTR_TO_IMM2(cmd, op) \
236 static inline void append_##cmd##_as_imm(u32 *desc, void *data, \
237 unsigned int data_len, \
238 unsigned int len, u32 options) \
241 append_cmd(desc, CMD_##op | IMMEDIATE | len | options); \
242 append_data(desc, data, data_len); \
246 #define APPEND_CMD_RAW_IMM(cmd, op, type) \
247 static inline void append_##cmd##_imm_##type(u32 *desc, type immediate, \
251 append_cmd(desc, CMD_##op | IMMEDIATE | options | sizeof(type)); \
252 append_cmd(desc, immediate); \
260 #define APPEND_MATH(op, desc, dest, src_0, src_1, len) \
261 append_cmd(desc, CMD_MATH | MATH_FUN_##op | MATH_DEST_##dest | \
262 MATH_SRC0_##src_0 | MATH_SRC1_##src_1 | (u32) (len & MATH_LEN_MASK));
264 #define append_math_add(desc, dest, src0, src1, len) \
265 APPEND_MATH(ADD, desc, dest, src0, src1, len)
266 #define append_math_sub(desc, dest, src0, src1, len) \
267 APPEND_MATH(SUB, desc, dest, src0, src1, len)
268 #define append_math_add_c(desc, dest, src0, src1, len) \
269 APPEND_MATH(ADDC, desc, dest, src0, src1, len)
270 #define append_math_sub_b(desc, dest, src0, src1, len) \
271 APPEND_MATH(SUBB, desc, dest, src0, src1, len)
272 #define append_math_and(desc, dest, src0, src1, len) \
273 APPEND_MATH(AND, desc, dest, src0, src1, len)
274 #define append_math_or(desc, dest, src0, src1, len) \
275 APPEND_MATH(OR, desc, dest, src0, src1, len)
276 #define append_math_xor(desc, dest, src0, src1, len) \
277 APPEND_MATH(XOR, desc, dest, src0, src1, len)
278 #define append_math_lshift(desc, dest, src0, src1, len) \
279 APPEND_MATH(LSHIFT, desc, dest, src0, src1, len)
280 #define append_math_rshift(desc, dest, src0, src1, len) \
281 APPEND_MATH(RSHIFT, desc, dest, src0, src1, len)
284 #define APPEND_MATH_IMM_u32(op, desc, dest, src_0, src_1, data) \
286 APPEND_MATH(op, desc, dest, src_0, src_1, CAAM_CMD_SZ); \
287 append_cmd(desc, data); \
290 #define append_math_add_imm_u32(desc, dest, src0, src1, data) \
291 APPEND_MATH_IMM_u32(ADD, desc, dest, src0, src1, data)
292 #define append_math_sub_imm_u32(desc, dest, src0, src1, data) \
293 APPEND_MATH_IMM_u32(SUB, desc, dest, src0, src1, data)
294 #define append_math_add_c_imm_u32(desc, dest, src0, src1, data) \
295 APPEND_MATH_IMM_u32(ADDC, desc, dest, src0, src1, data)
296 #define append_math_sub_b_imm_u32(desc, dest, src0, src1, data) \
297 APPEND_MATH_IMM_u32(SUBB, desc, dest, src0, src1, data)
298 #define append_math_and_imm_u32(desc, dest, src0, src1, data) \
299 APPEND_MATH_IMM_u32(AND, desc, dest, src0, src1, data)
300 #define append_math_or_imm_u32(desc, dest, src0, src1, data) \
301 APPEND_MATH_IMM_u32(OR, desc, dest, src0, src1, data)
302 #define append_math_xor_imm_u32(desc, dest, src0, src1, data) \
303 APPEND_MATH_IMM_u32(XOR, desc, dest, src0, src1, data)
304 #define append_math_lshift_imm_u32(desc, dest, src0, src1, data) \
305 APPEND_MATH_IMM_u32(LSHIFT, desc, dest, src0, src1, data)
306 #define append_math_rshift_imm_u32(desc, dest, src0, src1, data) \
307 APPEND_MATH_IMM_u32(RSHIFT, desc, dest, src0, src1, data)