1 /* SPDX-License-Identifier:     GPL-2.0+ */
2 /*
3  * Copyright 2017-2018 NXP
4  *
5  */
6 
7 #ifndef SC_RPC_H
8 #define SC_RPC_H
9 
10 /* Note: Check SCFW API Released DOC before you want to modify something */
11 #define SC_RPC_VERSION          1U
12 
13 #define SC_RPC_MAX_MSG          8U
14 
15 #define RPC_VER(MSG)            ((MSG)->version)
16 #define RPC_SIZE(MSG)           ((MSG)->size)
17 #define RPC_SVC(MSG)            ((MSG)->svc)
18 #define RPC_FUNC(MSG)           ((MSG)->func)
19 #define RPC_R8(MSG)             ((MSG)->func)
20 #define RPC_I32(MSG, IDX)       ((MSG)->DATA.i32[(IDX) / 4U])
21 #define RPC_I16(MSG, IDX)       ((MSG)->DATA.i16[(IDX) / 2U])
22 #define RPC_I8(MSG, IDX)        ((MSG)->DATA.i8[(IDX)])
23 #define RPC_U32(MSG, IDX)       ((MSG)->DATA.u32[(IDX) / 4U])
24 #define RPC_U16(MSG, IDX)       ((MSG)->DATA.u16[(IDX) / 2U])
25 #define RPC_U8(MSG, IDX)        ((MSG)->DATA.u8[(IDX)])
26 
27 #define SC_RPC_SVC_UNKNOWN      0U
28 #define SC_RPC_SVC_RETURN       1U
29 #define SC_RPC_SVC_PM           2U
30 #define SC_RPC_SVC_RM           3U
31 #define SC_RPC_SVC_TIMER        5U
32 #define SC_RPC_SVC_PAD          6U
33 #define SC_RPC_SVC_MISC         7U
34 #define SC_RPC_SVC_IRQ          8U
35 #define SC_RPC_SVC_ABORT        9U
36 
37 /* Types */
38 
39 struct sc_rpc_msg_s {
40 	u8 version;
41 	u8 size;
42 	u8 svc;
43 	u8 func;
44 	union {
45 		s32 i32[(SC_RPC_MAX_MSG - 1U)];
46 		s16 i16[(SC_RPC_MAX_MSG - 1U) * 2U];
47 		s8 i8[(SC_RPC_MAX_MSG - 1U) * 4U];
48 		u32 u32[(SC_RPC_MAX_MSG - 1U)];
49 		u16 u16[(SC_RPC_MAX_MSG - 1U) * 2U];
50 		u8 u8[(SC_RPC_MAX_MSG - 1U) * 4U];
51 	} DATA;
52 };
53 
54 /* PM RPC */
55 #define PM_FUNC_UNKNOWN				0
56 #define PM_FUNC_SET_SYS_POWER_MODE		19U
57 #define PM_FUNC_SET_PARTITION_POWER_MODE	1U
58 #define PM_FUNC_GET_SYS_POWER_MODE		2U
59 #define PM_FUNC_SET_RESOURCE_POWER_MODE		3U
60 #define PM_FUNC_GET_RESOURCE_POWER_MODE		4U
61 #define PM_FUNC_REQ_LOW_POWER_MODE		16U
62 #define PM_FUNC_REQ_CPU_LOW_POWER_MODE		20U
63 #define PM_FUNC_SET_CPU_RESUME_ADDR		17U
64 #define PM_FUNC_SET_CPU_RESUME			21U
65 #define PM_FUNC_REQ_SYS_IF_POWER_MODE		18U
66 #define PM_FUNC_SET_CLOCK_RATE			5U
67 #define PM_FUNC_GET_CLOCK_RATE			6U
68 #define PM_FUNC_CLOCK_ENABLE			7U
69 #define PM_FUNC_SET_CLOCK_PARENT		14U
70 #define PM_FUNC_GET_CLOCK_PARENT		15U
71 #define PM_FUNC_RESET				13U
72 #define PM_FUNC_RESET_REASON			10U
73 #define PM_FUNC_BOOT				8U
74 #define PM_FUNC_REBOOT				9U
75 #define PM_FUNC_REBOOT_PARTITION		12U
76 #define PM_FUNC_CPU_START			11U
77 
78 /* MISC RPC */
79 #define MISC_FUNC_UNKNOWN			0
80 #define MISC_FUNC_SET_CONTROL			1U
81 #define MISC_FUNC_GET_CONTROL			2U
82 #define MISC_FUNC_SET_MAX_DMA_GROUP		4U
83 #define MISC_FUNC_SET_DMA_GROUP			5U
84 #define MISC_FUNC_SECO_IMAGE_LOAD		8U
85 #define MISC_FUNC_SECO_AUTHENTICATE		9U
86 #define MISC_FUNC_SECO_FUSE_WRITE		20U
87 #define MISC_FUNC_SECO_ENABLE_DEBUG		21U
88 #define MISC_FUNC_SECO_FORWARD_LIFECYCLE	22U
89 #define MISC_FUNC_SECO_RETURN_LIFECYCLE		23U
90 #define MISC_FUNC_SECO_BUILD_INFO		24U
91 #define MISC_FUNC_DEBUG_OUT			10U
92 #define MISC_FUNC_WAVEFORM_CAPTURE		6U
93 #define MISC_FUNC_BUILD_INFO			15U
94 #define MISC_FUNC_UNIQUE_ID			19U
95 #define MISC_FUNC_SET_ARI			3U
96 #define MISC_FUNC_BOOT_STATUS			7U
97 #define MISC_FUNC_BOOT_DONE			14U
98 #define MISC_FUNC_OTP_FUSE_READ			11U
99 #define MISC_FUNC_OTP_FUSE_WRITE		17U
100 #define MISC_FUNC_SET_TEMP			12U
101 #define MISC_FUNC_GET_TEMP			13U
102 #define MISC_FUNC_GET_BOOT_DEV			16U
103 #define MISC_FUNC_GET_BUTTON_STATUS		18U
104 
105 /* PAD RPC */
106 #define PAD_FUNC_UNKNOWN			0
107 #define PAD_FUNC_SET_MUX			1U
108 #define PAD_FUNC_GET_MUX			6U
109 #define PAD_FUNC_SET_GP				2U
110 #define PAD_FUNC_GET_GP				7U
111 #define PAD_FUNC_SET_WAKEUP			4U
112 #define PAD_FUNC_GET_WAKEUP			9U
113 #define PAD_FUNC_SET_ALL			5U
114 #define PAD_FUNC_GET_ALL			10U
115 #define PAD_FUNC_SET				15U
116 #define PAD_FUNC_GET				16U
117 #define PAD_FUNC_SET_GP_28FDSOI			11U
118 #define PAD_FUNC_GET_GP_28FDSOI			12U
119 #define PAD_FUNC_SET_GP_28FDSOI_HSIC		3U
120 #define PAD_FUNC_GET_GP_28FDSOI_HSIC		8U
121 #define PAD_FUNC_SET_GP_28FDSOI_COMP		13U
122 #define PAD_FUNC_GET_GP_28FDSOI_COMP		14U
123 
124 /* RM RPC */
125 #define RM_FUNC_UNKNOWN				0
126 #define RM_FUNC_PARTITION_ALLOC			1U
127 #define RM_FUNC_SET_CONFIDENTIAL		31U
128 #define RM_FUNC_PARTITION_FREE			2U
129 #define RM_FUNC_GET_DID				26U
130 #define RM_FUNC_PARTITION_STATIC		3U
131 #define RM_FUNC_PARTITION_LOCK			4U
132 #define RM_FUNC_GET_PARTITION			5U
133 #define RM_FUNC_SET_PARENT			6U
134 #define RM_FUNC_MOVE_ALL			7U
135 #define RM_FUNC_ASSIGN_RESOURCE			8U
136 #define RM_FUNC_SET_RESOURCE_MOVABLE		9U
137 #define RM_FUNC_SET_SUBSYS_RSRC_MOVABLE		28U
138 #define RM_FUNC_SET_MASTER_ATTRIBUTES		10U
139 #define RM_FUNC_SET_MASTER_SID			11U
140 #define RM_FUNC_SET_PERIPHERAL_PERMISSIONS	12U
141 #define RM_FUNC_IS_RESOURCE_OWNED		13U
142 #define RM_FUNC_IS_RESOURCE_MASTER		14U
143 #define RM_FUNC_IS_RESOURCE_PERIPHERAL		15U
144 #define RM_FUNC_GET_RESOURCE_INFO		16U
145 #define RM_FUNC_MEMREG_ALLOC			17U
146 #define RM_FUNC_MEMREG_SPLIT			29U
147 #define RM_FUNC_MEMREG_FREE			18U
148 #define RM_FUNC_FIND_MEMREG			30U
149 #define RM_FUNC_ASSIGN_MEMREG			19U
150 #define RM_FUNC_SET_MEMREG_PERMISSIONS		20U
151 #define RM_FUNC_IS_MEMREG_OWNED			21U
152 #define RM_FUNC_GET_MEMREG_INFO			22U
153 #define RM_FUNC_ASSIGN_PAD			23U
154 #define RM_FUNC_SET_PAD_MOVABLE			24U
155 #define RM_FUNC_IS_PAD_OWNED			25U
156 #define RM_FUNC_DUMP				27U
157 
158 #endif /* SC_RPC_H */
159