xref: /rk3399_ARM-atf/drivers/arm/sfcp/sfcp_psa/sfcp_psa_protocol/sfcp_psa_protocol_common.h (revision 2801427972c4b0d4c0165edb509f21186103f21f)
1 /*
2  * Copyright (c) 2024, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 /*
9  * Packing scheme of the control parameter
10  *
11  *  31           30-28   27    26-24  23-20   19     18-16   15-0
12  * +------------+-----+------+-------+-----+-------+-------+------+
13  * |            |     |      | invec |     |       | outvec| type |
14  * | Res        | Res | Res  | number| Res | Res   | number|      |
15  * +------------+-----+------+-------+-----+-------+-------+------+
16  *
17  * Res: Reserved.
18  */
19 
20 #ifndef __SFCP_PSA_PROTOCOL_COMMON_H__
21 #define __SFCP_PSA_PROTOCOL_COMMON_H__
22 
23 #define TYPE_OFFSET (0U)
24 #define TYPE_MASK (0xFFFFUL << TYPE_OFFSET)
25 #define IN_LEN_OFFSET (24U)
26 #define IN_LEN_MASK (0x7UL << IN_LEN_OFFSET)
27 #define OUT_LEN_OFFSET (16U)
28 #define OUT_LEN_MASK (0x7UL << OUT_LEN_OFFSET)
29 
30 #define PARAM_PACK(type, in_len, out_len)                          \
31 	(((((uint32_t)(type)) << TYPE_OFFSET) & TYPE_MASK) |       \
32 	 ((((uint32_t)(in_len)) << IN_LEN_OFFSET) & IN_LEN_MASK) | \
33 	 ((((uint32_t)(out_len)) << OUT_LEN_OFFSET) & OUT_LEN_MASK))
34 
35 #endif /* __SFCP_PSA_PROTOCOL_COMMON_H__ */
36