New upstream version 18.02
[deb_dpdk.git] / drivers / crypto / dpaa2_sec / hw / rta / signature_cmd.h
1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2  *
3  * Copyright 2008-2016 Freescale Semiconductor Inc.
4  * Copyright 2016 NXP
5  *
6  */
7
8 #ifndef __RTA_SIGNATURE_CMD_H__
9 #define __RTA_SIGNATURE_CMD_H__
10
11 static inline int
12 rta_signature(struct program *program, uint32_t sign_type)
13 {
14         uint32_t opcode = CMD_SIGNATURE;
15         unsigned int start_pc = program->current_pc;
16
17         switch (sign_type) {
18         case (SIGN_TYPE_FINAL):
19         case (SIGN_TYPE_FINAL_RESTORE):
20         case (SIGN_TYPE_FINAL_NONZERO):
21         case (SIGN_TYPE_IMM_2):
22         case (SIGN_TYPE_IMM_3):
23         case (SIGN_TYPE_IMM_4):
24                 opcode |= sign_type;
25                 break;
26         default:
27                 pr_err("SIGNATURE Command: Invalid type selection\n");
28                 goto err;
29         }
30
31         __rta_out32(program, opcode);
32         program->current_instruction++;
33
34         return (int)start_pc;
35
36  err:
37         program->first_error_pc = start_pc;
38         program->current_instruction++;
39         return -EINVAL;
40 }
41
42 #endif /* __RTA_SIGNATURE_CMD_H__ */