xref: /openbmc/u-boot/include/fsl-mc/fsl_dprc.h (revision cc4f1558)
1 /*
2  * Freescale Layerscape MC I/O wrapper
3  *
4  * Copyright (C) 2013-2015 Freescale Semiconductor, Inc.
5  * Author: German Rivera <German.Rivera@freescale.com>
6  *
7  * SPDX-License-Identifier:	GPL-2.0+
8  */
9 #ifndef _FSL_DPRC_H
10 #define _FSL_DPRC_H
11 
12 /* DPRC Version */
13 #define DPRC_VER_MAJOR				5
14 #define DPRC_VER_MINOR				0
15 
16 /* Command IDs */
17 #define DPRC_CMDID_CLOSE			0x800
18 #define DPRC_CMDID_OPEN				0x805
19 
20 #define DPRC_CMDID_GET_ATTR			0x004
21 #define DPRC_CMDID_RESET_CONT			0x005
22 
23 #define DPRC_CMDID_GET_CONT_ID			0x830
24 #define DPRC_CMDID_GET_OBJ_COUNT		0x159
25 #define DPRC_CMDID_GET_OBJ			0x15A
26 #define DPRC_CMDID_GET_RES_COUNT		0x15B
27 #define DPRC_CMDID_GET_RES_IDS			0x15C
28 #define DPRC_CMDID_GET_OBJ_REG			0x15E
29 
30 #define DPRC_CMDID_CONNECT			0x167
31 #define DPRC_CMDID_DISCONNECT			0x168
32 #define DPRC_CMDID_GET_CONNECTION		0x16C
33 
34 /*                cmd, param, offset, width, type, arg_name */
35 #define DPRC_RSP_GET_CONTAINER_ID(cmd, container_id) \
36 	MC_RSP_OP(cmd, 0, 0,  32,  int,	    container_id)
37 
38 /*                cmd, param, offset, width, type, arg_name */
39 #define DPRC_CMD_OPEN(cmd, container_id) \
40 	MC_CMD_OP(cmd, 0, 0,  32, int,	    container_id)
41 
42 /*                cmd, param, offset, width, type, arg_name */
43 #define DPRC_CMD_RESET_CONTAINER(cmd, child_container_id) \
44 	MC_CMD_OP(cmd, 0, 0,  32, int,	    child_container_id)
45 
46 /*                cmd, param, offset, width, type, arg_name */
47 #define DPRC_RSP_GET_ATTRIBUTES(cmd, attr) \
48 do { \
49 	MC_RSP_OP(cmd, 0, 0,  32, int,	    attr->container_id); \
50 	MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->icid); \
51 	MC_RSP_OP(cmd, 1, 0,  32, uint32_t, attr->options);\
52 	MC_RSP_OP(cmd, 1, 32, 32, int,      attr->portal_id); \
53 	MC_RSP_OP(cmd, 2, 0,  16, uint16_t, attr->version.major);\
54 	MC_RSP_OP(cmd, 2, 16, 16, uint16_t, attr->version.minor);\
55 } while (0)
56 
57 /*                cmd, param, offset, width, type, arg_name */
58 #define DPRC_RSP_GET_OBJ_COUNT(cmd, obj_count) \
59 	MC_RSP_OP(cmd, 0, 32, 32, int,      obj_count)
60 
61 /*                cmd, param, offset, width, type, arg_name */
62 #define DPRC_CMD_GET_OBJ(cmd, obj_index) \
63 	MC_CMD_OP(cmd, 0, 0,  32, int,	    obj_index)
64 
65 /*                cmd, param, offset, width, type, arg_name */
66 #define DPRC_RSP_GET_OBJ(cmd, obj_desc) \
67 do { \
68 	MC_RSP_OP(cmd, 0, 32, 32, int,	    obj_desc->id); \
69 	MC_RSP_OP(cmd, 1, 0,  16, uint16_t, obj_desc->vendor); \
70 	MC_RSP_OP(cmd, 1, 16, 8,  uint8_t,  obj_desc->irq_count); \
71 	MC_RSP_OP(cmd, 1, 24, 8,  uint8_t,  obj_desc->region_count); \
72 	MC_RSP_OP(cmd, 1, 32, 32, uint32_t, obj_desc->state);\
73 	MC_RSP_OP(cmd, 2, 0,  16, uint16_t, obj_desc->ver_major);\
74 	MC_RSP_OP(cmd, 2, 16, 16, uint16_t, obj_desc->ver_minor);\
75 	MC_RSP_OP(cmd, 3, 0,  8,  char,	    obj_desc->type[0]);\
76 	MC_RSP_OP(cmd, 3, 8,  8,  char,	    obj_desc->type[1]);\
77 	MC_RSP_OP(cmd, 3, 16, 8,  char,	    obj_desc->type[2]);\
78 	MC_RSP_OP(cmd, 3, 24, 8,  char,	    obj_desc->type[3]);\
79 	MC_RSP_OP(cmd, 3, 32, 8,  char,	    obj_desc->type[4]);\
80 	MC_RSP_OP(cmd, 3, 40, 8,  char,	    obj_desc->type[5]);\
81 	MC_RSP_OP(cmd, 3, 48, 8,  char,	    obj_desc->type[6]);\
82 	MC_RSP_OP(cmd, 3, 56, 8,  char,	    obj_desc->type[7]);\
83 	MC_RSP_OP(cmd, 4, 0,  8,  char,	    obj_desc->type[8]);\
84 	MC_RSP_OP(cmd, 4, 8,  8,  char,	    obj_desc->type[9]);\
85 	MC_RSP_OP(cmd, 4, 16, 8,  char,	    obj_desc->type[10]);\
86 	MC_RSP_OP(cmd, 4, 24, 8,  char,	    obj_desc->type[11]);\
87 	MC_RSP_OP(cmd, 4, 32, 8,  char,	    obj_desc->type[12]);\
88 	MC_RSP_OP(cmd, 4, 40, 8,  char,	    obj_desc->type[13]);\
89 	MC_RSP_OP(cmd, 4, 48, 8,  char,	    obj_desc->type[14]);\
90 	MC_RSP_OP(cmd, 4, 56, 8,  char,	    obj_desc->type[15]);\
91 	MC_RSP_OP(cmd, 5, 0,  8,  char,	    obj_desc->label[0]);\
92 	MC_RSP_OP(cmd, 5, 8,  8,  char,	    obj_desc->label[1]);\
93 	MC_RSP_OP(cmd, 5, 16, 8,  char,	    obj_desc->label[2]);\
94 	MC_RSP_OP(cmd, 5, 24, 8,  char,	    obj_desc->label[3]);\
95 	MC_RSP_OP(cmd, 5, 32, 8,  char,	    obj_desc->label[4]);\
96 	MC_RSP_OP(cmd, 5, 40, 8,  char,	    obj_desc->label[5]);\
97 	MC_RSP_OP(cmd, 5, 48, 8,  char,	    obj_desc->label[6]);\
98 	MC_RSP_OP(cmd, 5, 56, 8,  char,	    obj_desc->label[7]);\
99 	MC_RSP_OP(cmd, 6, 0,  8,  char,	    obj_desc->label[8]);\
100 	MC_RSP_OP(cmd, 6, 8,  8,  char,	    obj_desc->label[9]);\
101 	MC_RSP_OP(cmd, 6, 16, 8,  char,	    obj_desc->label[10]);\
102 	MC_RSP_OP(cmd, 6, 24, 8,  char,	    obj_desc->label[11]);\
103 	MC_RSP_OP(cmd, 6, 32, 8,  char,	    obj_desc->label[12]);\
104 	MC_RSP_OP(cmd, 6, 40, 8,  char,	    obj_desc->label[13]);\
105 	MC_RSP_OP(cmd, 6, 48, 8,  char,	    obj_desc->label[14]);\
106 	MC_RSP_OP(cmd, 6, 56, 8,  char,	    obj_desc->label[15]);\
107 } while (0)
108 
109 /*                cmd, param, offset, width, type, arg_name */
110 #define DPRC_CMD_GET_RES_COUNT(cmd, type) \
111 do { \
112 	MC_CMD_OP(cmd, 1, 0,  8,  char,	    type[0]);\
113 	MC_CMD_OP(cmd, 1, 8,  8,  char,	    type[1]);\
114 	MC_CMD_OP(cmd, 1, 16, 8,  char,	    type[2]);\
115 	MC_CMD_OP(cmd, 1, 24, 8,  char,	    type[3]);\
116 	MC_CMD_OP(cmd, 1, 32, 8,  char,	    type[4]);\
117 	MC_CMD_OP(cmd, 1, 40, 8,  char,	    type[5]);\
118 	MC_CMD_OP(cmd, 1, 48, 8,  char,	    type[6]);\
119 	MC_CMD_OP(cmd, 1, 56, 8,  char,	    type[7]);\
120 	MC_CMD_OP(cmd, 2, 0,  8,  char,	    type[8]);\
121 	MC_CMD_OP(cmd, 2, 8,  8,  char,	    type[9]);\
122 	MC_CMD_OP(cmd, 2, 16, 8,  char,	    type[10]);\
123 	MC_CMD_OP(cmd, 2, 24, 8,  char,	    type[11]);\
124 	MC_CMD_OP(cmd, 2, 32, 8,  char,	    type[12]);\
125 	MC_CMD_OP(cmd, 2, 40, 8,  char,	    type[13]);\
126 	MC_CMD_OP(cmd, 2, 48, 8,  char,	    type[14]);\
127 	MC_CMD_OP(cmd, 2, 56, 8,  char,	    type[15]);\
128 } while (0)
129 
130 /*                cmd, param, offset, width, type, arg_name */
131 #define DPRC_RSP_GET_RES_COUNT(cmd, res_count) \
132 	MC_RSP_OP(cmd, 0, 0,  32, int,	    res_count)
133 
134 /*                cmd, param, offset, width, type, arg_name */
135 #define DPRC_CMD_GET_RES_IDS(cmd, range_desc, type) \
136 do { \
137 	MC_CMD_OP(cmd, 0, 42, 7,  enum dprc_iter_status, \
138 					    range_desc->iter_status); \
139 	MC_CMD_OP(cmd, 1, 0,  32, int,	    range_desc->base_id); \
140 	MC_CMD_OP(cmd, 1, 32, 32, int,	    range_desc->last_id);\
141 	MC_CMD_OP(cmd, 2, 0,  8,  char,	    type[0]);\
142 	MC_CMD_OP(cmd, 2, 8,  8,  char,	    type[1]);\
143 	MC_CMD_OP(cmd, 2, 16, 8,  char,	    type[2]);\
144 	MC_CMD_OP(cmd, 2, 24, 8,  char,	    type[3]);\
145 	MC_CMD_OP(cmd, 2, 32, 8,  char,	    type[4]);\
146 	MC_CMD_OP(cmd, 2, 40, 8,  char,     type[5]);\
147 	MC_CMD_OP(cmd, 2, 48, 8,  char,	    type[6]);\
148 	MC_CMD_OP(cmd, 2, 56, 8,  char,	    type[7]);\
149 	MC_CMD_OP(cmd, 3, 0,  8,  char,	    type[8]);\
150 	MC_CMD_OP(cmd, 3, 8,  8,  char,	    type[9]);\
151 	MC_CMD_OP(cmd, 3, 16, 8,  char,	    type[10]);\
152 	MC_CMD_OP(cmd, 3, 24, 8,  char,	    type[11]);\
153 	MC_CMD_OP(cmd, 3, 32, 8,  char,	    type[12]);\
154 	MC_CMD_OP(cmd, 3, 40, 8,  char,	    type[13]);\
155 	MC_CMD_OP(cmd, 3, 48, 8,  char,	    type[14]);\
156 	MC_CMD_OP(cmd, 3, 56, 8,  char,	    type[15]);\
157 } while (0)
158 
159 /*                cmd, param, offset, width, type, arg_name */
160 #define DPRC_RSP_GET_RES_IDS(cmd, range_desc) \
161 do { \
162 	MC_RSP_OP(cmd, 0, 42, 7,  enum dprc_iter_status, \
163 					    range_desc->iter_status);\
164 	MC_RSP_OP(cmd, 1, 0,  32, int,	    range_desc->base_id); \
165 	MC_RSP_OP(cmd, 1, 32, 32, int,	    range_desc->last_id);\
166 } while (0)
167 
168 /*                cmd, param, offset, width, type, arg_name */
169 #define DPRC_CMD_GET_OBJ_REGION(cmd, obj_type, obj_id, region_index) \
170 do { \
171 	MC_CMD_OP(cmd, 0, 0,  32, int,	    obj_id); \
172 	MC_CMD_OP(cmd, 0, 48, 8,  uint8_t,  region_index);\
173 	MC_CMD_OP(cmd, 3, 0,  8,  char,	    obj_type[0]);\
174 	MC_CMD_OP(cmd, 3, 8,  8,  char,	    obj_type[1]);\
175 	MC_CMD_OP(cmd, 3, 16, 8,  char,	    obj_type[2]);\
176 	MC_CMD_OP(cmd, 3, 24, 8,  char,	    obj_type[3]);\
177 	MC_CMD_OP(cmd, 3, 32, 8,  char,	    obj_type[4]);\
178 	MC_CMD_OP(cmd, 3, 40, 8,  char,	    obj_type[5]);\
179 	MC_CMD_OP(cmd, 3, 48, 8,  char,	    obj_type[6]);\
180 	MC_CMD_OP(cmd, 3, 56, 8,  char,	    obj_type[7]);\
181 	MC_CMD_OP(cmd, 4, 0,  8,  char,	    obj_type[8]);\
182 	MC_CMD_OP(cmd, 4, 8,  8,  char,	    obj_type[9]);\
183 	MC_CMD_OP(cmd, 4, 16, 8,  char,	    obj_type[10]);\
184 	MC_CMD_OP(cmd, 4, 24, 8,  char,	    obj_type[11]);\
185 	MC_CMD_OP(cmd, 4, 32, 8,  char,	    obj_type[12]);\
186 	MC_CMD_OP(cmd, 4, 40, 8,  char,	    obj_type[13]);\
187 	MC_CMD_OP(cmd, 4, 48, 8,  char,	    obj_type[14]);\
188 	MC_CMD_OP(cmd, 4, 56, 8,  char,	    obj_type[15]);\
189 } while (0)
190 
191 /*	param, offset, width,	type,		arg_name */
192 #define DPRC_RSP_GET_OBJ_REGION(cmd, region_desc) \
193 do { \
194 	MC_RSP_OP(cmd, 1, 0,  32, uint32_t, region_desc->base_offset);\
195 	MC_RSP_OP(cmd, 2, 0,  32, uint32_t, region_desc->size); \
196 	MC_RSP_OP(cmd, 2, 32, 4,  enum dprc_region_type, region_desc->type);\
197 	MC_RSP_OP(cmd, 3, 0,  32, uint32_t, region_desc->flags);\
198 } while (0)
199 
200 /*                cmd, param, offset, width, type, arg_name */
201 #define DPRC_CMD_SET_OBJ_LABEL(cmd, obj_type, obj_id, label) \
202 do { \
203 	MC_CMD_OP(cmd, 0, 0,  32, int,      obj_id); \
204 	MC_CMD_OP(cmd, 1, 0,  8,  char,	    label[0]);\
205 	MC_CMD_OP(cmd, 1, 8,  8,  char,	    label[1]);\
206 	MC_CMD_OP(cmd, 1, 16, 8,  char,	    label[2]);\
207 	MC_CMD_OP(cmd, 1, 24, 8,  char,	    label[3]);\
208 	MC_CMD_OP(cmd, 1, 32, 8,  char,	    label[4]);\
209 	MC_CMD_OP(cmd, 1, 40, 8,  char,	    label[5]);\
210 	MC_CMD_OP(cmd, 1, 48, 8,  char,	    label[6]);\
211 	MC_CMD_OP(cmd, 1, 56, 8,  char,	    label[7]);\
212 	MC_CMD_OP(cmd, 2, 0,  8,  char,	    label[8]);\
213 	MC_CMD_OP(cmd, 2, 8,  8,  char,	    label[9]);\
214 	MC_CMD_OP(cmd, 2, 16, 8,  char,	    label[10]);\
215 	MC_CMD_OP(cmd, 2, 24, 8,  char,	    label[11]);\
216 	MC_CMD_OP(cmd, 2, 32, 8,  char,	    label[12]);\
217 	MC_CMD_OP(cmd, 2, 40, 8,  char,	    label[13]);\
218 	MC_CMD_OP(cmd, 2, 48, 8,  char,	    label[14]);\
219 	MC_CMD_OP(cmd, 2, 56, 8,  char,	    label[15]);\
220 	MC_CMD_OP(cmd, 3, 0,  8,  char,	    obj_type[0]);\
221 	MC_CMD_OP(cmd, 3, 8,  8,  char,	    obj_type[1]);\
222 	MC_CMD_OP(cmd, 3, 16, 8,  char,	    obj_type[2]);\
223 	MC_CMD_OP(cmd, 3, 24, 8,  char,	    obj_type[3]);\
224 	MC_CMD_OP(cmd, 3, 32, 8,  char,	    obj_type[4]);\
225 	MC_CMD_OP(cmd, 3, 40, 8,  char,	    obj_type[5]);\
226 	MC_CMD_OP(cmd, 3, 48, 8,  char,	    obj_type[6]);\
227 	MC_CMD_OP(cmd, 3, 56, 8,  char,	    obj_type[7]);\
228 	MC_CMD_OP(cmd, 4, 0,  8,  char,	    obj_type[8]);\
229 	MC_CMD_OP(cmd, 4, 8,  8,  char,	    obj_type[9]);\
230 	MC_CMD_OP(cmd, 4, 16, 8,  char,	    obj_type[10]);\
231 	MC_CMD_OP(cmd, 4, 24, 8,  char,	    obj_type[11]);\
232 	MC_CMD_OP(cmd, 4, 32, 8,  char,	    obj_type[12]);\
233 	MC_CMD_OP(cmd, 4, 40, 8,  char,	    obj_type[13]);\
234 	MC_CMD_OP(cmd, 4, 48, 8,  char,	    obj_type[14]);\
235 	MC_CMD_OP(cmd, 4, 56, 8,  char,	    obj_type[15]);\
236 } while (0)
237 
238 /*                cmd, param, offset, width, type, arg_name */
239 #define DPRC_CMD_CONNECT(cmd, endpoint1, endpoint2, cfg) \
240 do { \
241 	MC_CMD_OP(cmd, 0, 0,  32, int,      endpoint1->id); \
242 	MC_CMD_OP(cmd, 0, 32, 16, uint16_t, endpoint1->if_id); \
243 	MC_CMD_OP(cmd, 1, 0,  32, int,	    endpoint2->id); \
244 	MC_CMD_OP(cmd, 1, 32, 16, uint16_t, endpoint2->if_id); \
245 	MC_CMD_OP(cmd, 2, 0,  8,  char,     endpoint1->type[0]); \
246 	MC_CMD_OP(cmd, 2, 8,  8,  char,	    endpoint1->type[1]); \
247 	MC_CMD_OP(cmd, 2, 16, 8,  char,	    endpoint1->type[2]); \
248 	MC_CMD_OP(cmd, 2, 24, 8,  char,	    endpoint1->type[3]); \
249 	MC_CMD_OP(cmd, 2, 32, 8,  char,	    endpoint1->type[4]); \
250 	MC_CMD_OP(cmd, 2, 40, 8,  char,	    endpoint1->type[5]); \
251 	MC_CMD_OP(cmd, 2, 48, 8,  char,	    endpoint1->type[6]); \
252 	MC_CMD_OP(cmd, 2, 56, 8,  char,	    endpoint1->type[7]); \
253 	MC_CMD_OP(cmd, 3, 0,  8,  char,	    endpoint1->type[8]); \
254 	MC_CMD_OP(cmd, 3, 8,  8,  char,	    endpoint1->type[9]); \
255 	MC_CMD_OP(cmd, 3, 16, 8,  char,	    endpoint1->type[10]); \
256 	MC_CMD_OP(cmd, 3, 24, 8,  char,	    endpoint1->type[11]); \
257 	MC_CMD_OP(cmd, 3, 32, 8,  char,     endpoint1->type[12]); \
258 	MC_CMD_OP(cmd, 3, 40, 8,  char,	    endpoint1->type[13]); \
259 	MC_CMD_OP(cmd, 3, 48, 8,  char,	    endpoint1->type[14]); \
260 	MC_CMD_OP(cmd, 3, 56, 8,  char,	    endpoint1->type[15]); \
261 	MC_CMD_OP(cmd, 4, 0,  32, uint32_t, cfg->max_rate); \
262 	MC_CMD_OP(cmd, 4, 32, 32, uint32_t, cfg->committed_rate); \
263 	MC_CMD_OP(cmd, 5, 0,  8,  char,	    endpoint2->type[0]); \
264 	MC_CMD_OP(cmd, 5, 8,  8,  char,	    endpoint2->type[1]); \
265 	MC_CMD_OP(cmd, 5, 16, 8,  char,	    endpoint2->type[2]); \
266 	MC_CMD_OP(cmd, 5, 24, 8,  char,	    endpoint2->type[3]); \
267 	MC_CMD_OP(cmd, 5, 32, 8,  char,	    endpoint2->type[4]); \
268 	MC_CMD_OP(cmd, 5, 40, 8,  char,	    endpoint2->type[5]); \
269 	MC_CMD_OP(cmd, 5, 48, 8,  char,	    endpoint2->type[6]); \
270 	MC_CMD_OP(cmd, 5, 56, 8,  char,	    endpoint2->type[7]); \
271 	MC_CMD_OP(cmd, 6, 0,  8,  char,	    endpoint2->type[8]); \
272 	MC_CMD_OP(cmd, 6, 8,  8,  char,	    endpoint2->type[9]); \
273 	MC_CMD_OP(cmd, 6, 16, 8,  char,	    endpoint2->type[10]); \
274 	MC_CMD_OP(cmd, 6, 24, 8,  char,	    endpoint2->type[11]); \
275 	MC_CMD_OP(cmd, 6, 32, 8,  char,	    endpoint2->type[12]); \
276 	MC_CMD_OP(cmd, 6, 40, 8,  char,	    endpoint2->type[13]); \
277 	MC_CMD_OP(cmd, 6, 48, 8,  char,	    endpoint2->type[14]); \
278 	MC_CMD_OP(cmd, 6, 56, 8,  char,	    endpoint2->type[15]); \
279 } while (0)
280 
281 /*                cmd, param, offset, width, type, arg_name */
282 #define DPRC_CMD_DISCONNECT(cmd, endpoint) \
283 do { \
284 	MC_CMD_OP(cmd, 0, 0,  32, int,	    endpoint->id); \
285 	MC_CMD_OP(cmd, 0, 32, 16, uint16_t, endpoint->if_id); \
286 	MC_CMD_OP(cmd, 1, 0,  8,  char,	    endpoint->type[0]); \
287 	MC_CMD_OP(cmd, 1, 8,  8,  char,	    endpoint->type[1]); \
288 	MC_CMD_OP(cmd, 1, 16, 8,  char,	    endpoint->type[2]); \
289 	MC_CMD_OP(cmd, 1, 24, 8,  char,	    endpoint->type[3]); \
290 	MC_CMD_OP(cmd, 1, 32, 8,  char,	    endpoint->type[4]); \
291 	MC_CMD_OP(cmd, 1, 40, 8,  char,	    endpoint->type[5]); \
292 	MC_CMD_OP(cmd, 1, 48, 8,  char,	    endpoint->type[6]); \
293 	MC_CMD_OP(cmd, 1, 56, 8,  char,	    endpoint->type[7]); \
294 	MC_CMD_OP(cmd, 2, 0,  8,  char,	    endpoint->type[8]); \
295 	MC_CMD_OP(cmd, 2, 8,  8,  char,	    endpoint->type[9]); \
296 	MC_CMD_OP(cmd, 2, 16, 8,  char,	    endpoint->type[10]); \
297 	MC_CMD_OP(cmd, 2, 24, 8,  char,	    endpoint->type[11]); \
298 	MC_CMD_OP(cmd, 2, 32, 8,  char,	    endpoint->type[12]); \
299 	MC_CMD_OP(cmd, 2, 40, 8,  char,	    endpoint->type[13]); \
300 	MC_CMD_OP(cmd, 2, 48, 8,  char,	    endpoint->type[14]); \
301 	MC_CMD_OP(cmd, 2, 56, 8,  char,	    endpoint->type[15]); \
302 } while (0)
303 
304 /*                cmd, param, offset, width, type, arg_name */
305 #define DPRC_CMD_GET_CONNECTION(cmd, endpoint1) \
306 do { \
307 	MC_CMD_OP(cmd, 0, 0,  32, int,      endpoint1->id); \
308 	MC_CMD_OP(cmd, 0, 32, 16, uint16_t, endpoint1->if_id); \
309 	MC_CMD_OP(cmd, 1, 0,  8,  char,     endpoint1->type[0]); \
310 	MC_CMD_OP(cmd, 1, 8,  8,  char,	    endpoint1->type[1]); \
311 	MC_CMD_OP(cmd, 1, 16, 8,  char,	    endpoint1->type[2]); \
312 	MC_CMD_OP(cmd, 1, 24, 8,  char,	    endpoint1->type[3]); \
313 	MC_CMD_OP(cmd, 1, 32, 8,  char,	    endpoint1->type[4]); \
314 	MC_CMD_OP(cmd, 1, 40, 8,  char,	    endpoint1->type[5]); \
315 	MC_CMD_OP(cmd, 1, 48, 8,  char,	    endpoint1->type[6]); \
316 	MC_CMD_OP(cmd, 1, 56, 8,  char,	    endpoint1->type[7]); \
317 	MC_CMD_OP(cmd, 2, 0,  8,  char,	    endpoint1->type[8]); \
318 	MC_CMD_OP(cmd, 2, 8,  8,  char,	    endpoint1->type[9]); \
319 	MC_CMD_OP(cmd, 2, 16, 8,  char,	    endpoint1->type[10]); \
320 	MC_CMD_OP(cmd, 2, 24, 8,  char,	    endpoint1->type[11]); \
321 	MC_CMD_OP(cmd, 2, 32, 8,  char,     endpoint1->type[12]); \
322 	MC_CMD_OP(cmd, 2, 40, 8,  char,	    endpoint1->type[13]); \
323 	MC_CMD_OP(cmd, 2, 48, 8,  char,	    endpoint1->type[14]); \
324 	MC_CMD_OP(cmd, 2, 56, 8,  char,	    endpoint1->type[15]); \
325 } while (0)
326 
327 /*                cmd, param, offset, width, type, arg_name */
328 #define DPRC_RSP_GET_CONNECTION(cmd, endpoint2, state) \
329 do { \
330 	MC_RSP_OP(cmd, 3, 0,  32, int,	    endpoint2->id); \
331 	MC_RSP_OP(cmd, 3, 32, 16, uint16_t, endpoint2->if_id); \
332 	MC_RSP_OP(cmd, 4, 0,  8,  char,	    endpoint2->type[0]); \
333 	MC_RSP_OP(cmd, 4, 8,  8,  char,	    endpoint2->type[1]); \
334 	MC_RSP_OP(cmd, 4, 16, 8,  char,	    endpoint2->type[2]); \
335 	MC_RSP_OP(cmd, 4, 24, 8,  char,	    endpoint2->type[3]); \
336 	MC_RSP_OP(cmd, 4, 32, 8,  char,	    endpoint2->type[4]); \
337 	MC_RSP_OP(cmd, 4, 40, 8,  char,	    endpoint2->type[5]); \
338 	MC_RSP_OP(cmd, 4, 48, 8,  char,	    endpoint2->type[6]); \
339 	MC_RSP_OP(cmd, 4, 56, 8,  char,	    endpoint2->type[7]); \
340 	MC_RSP_OP(cmd, 5, 0,  8,  char,	    endpoint2->type[8]); \
341 	MC_RSP_OP(cmd, 5, 8,  8,  char,	    endpoint2->type[9]); \
342 	MC_RSP_OP(cmd, 5, 16, 8,  char,	    endpoint2->type[10]); \
343 	MC_RSP_OP(cmd, 5, 24, 8,  char,	    endpoint2->type[11]); \
344 	MC_RSP_OP(cmd, 5, 32, 8,  char,	    endpoint2->type[12]); \
345 	MC_RSP_OP(cmd, 5, 40, 8,  char,	    endpoint2->type[13]); \
346 	MC_RSP_OP(cmd, 5, 48, 8,  char,	    endpoint2->type[14]); \
347 	MC_RSP_OP(cmd, 5, 56, 8,  char,	    endpoint2->type[15]); \
348 	MC_RSP_OP(cmd, 6, 0,  32, int,	    state); \
349 } while (0)
350 
351 /* Data Path Resource Container API
352  * Contains DPRC API for managing and querying DPAA resources
353  */
354 
355 struct fsl_mc_io;
356 
357 /**
358  * Set this value as the icid value in dprc_cfg structure when creating a
359  * container, in case the ICID is not selected by the user and should be
360  * allocated by the DPRC from the pool of ICIDs.
361  */
362 #define DPRC_GET_ICID_FROM_POOL			(uint16_t)(~(0))
363 
364 /**
365  * Set this value as the portal_id value in dprc_cfg structure when creating a
366  * container, in case the portal ID is not specifically selected by the
367  * user and should be allocated by the DPRC from the pool of portal ids.
368  */
369 #define DPRC_GET_PORTAL_ID_FROM_POOL	(int)(~(0))
370 
371 /**
372  * dprc_get_container_id() - Get container ID associated with a given portal.
373  * @mc_io:	Pointer to MC portal's I/O object
374  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
375  * @container_id:	Requested container ID
376  *
377  * Return:	'0' on Success; Error code otherwise.
378  */
379 int dprc_get_container_id(struct fsl_mc_io	*mc_io,
380 			  uint32_t		cmd_flags,
381 			  int			*container_id);
382 
383 /**
384  * dprc_open() - Open DPRC object for use
385  * @mc_io:	Pointer to MC portal's I/O object
386  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
387  * @container_id: Container ID to open
388  * @token:	Returned token of DPRC object
389  *
390  * Return:	'0' on Success; Error code otherwise.
391  *
392  * @warning	Required before any operation on the object.
393  */
394 int dprc_open(struct fsl_mc_io	*mc_io,
395 	      uint32_t		cmd_flags,
396 	      int		container_id,
397 	      uint16_t		*token);
398 
399 /**
400  * dprc_close() - Close the control session of the object
401  * @mc_io:	Pointer to MC portal's I/O object
402  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
403  * @token:	Token of DPRC object
404  *
405  * After this function is called, no further operations are
406  * allowed on the object without opening a new control session.
407  *
408  * Return:	'0' on Success; Error code otherwise.
409  */
410 int dprc_close(struct fsl_mc_io	*mc_io,
411 	       uint32_t		cmd_flags,
412 	       uint16_t		token);
413 
414 /**
415  * Container general options
416  *
417  * These options may be selected at container creation by the container creator
418  * and can be retrieved using dprc_get_attributes()
419  */
420 
421 /* Spawn Policy Option allowed - Indicates that the new container is allowed
422  * to spawn and have its own child containers.
423  */
424 #define DPRC_CFG_OPT_SPAWN_ALLOWED		0x00000001
425 
426 /* General Container allocation policy - Indicates that the new container is
427  * allowed to allocate requested resources from its parent container; if not
428  * set, the container is only allowed to use resources in its own pools; Note
429  * that this is a container's global policy, but the parent container may
430  * override it and set specific quota per resource type.
431  */
432 #define DPRC_CFG_OPT_ALLOC_ALLOWED		0x00000002
433 
434 /* Object initialization allowed - software context associated with this
435  * container is allowed to invoke object initialization operations.
436  */
437 #define DPRC_CFG_OPT_OBJ_CREATE_ALLOWED		0x00000004
438 
439 /* Topology change allowed - software context associated with this
440  * container is allowed to invoke topology operations, such as attach/detach
441  * of network objects.
442  */
443 #define DPRC_CFG_OPT_TOPOLOGY_CHANGES_ALLOWED	0x00000008
444 
445 /* IOMMU bypass - indicates whether objects of this container are permitted
446  * to bypass the IOMMU.
447  */
448 #define DPRC_CFG_OPT_IOMMU_BYPASS		0x00000010
449 
450 /* AIOP - Indicates that container belongs to AIOP.  */
451 #define DPRC_CFG_OPT_AIOP			0x00000020
452 
453 /**
454  * struct dprc_cfg - Container configuration options
455  * @icid: Container's ICID; if set to 'DPRC_GET_ICID_FROM_POOL', a free
456  *		ICID value is allocated by the DPRC
457  * @portal_id: Portal ID; if set to 'DPRC_GET_PORTAL_ID_FROM_POOL', a free
458  *		portal ID is allocated by the DPRC
459  * @options: Combination of 'DPRC_CFG_OPT_<X>' options
460  * @label: Object's label
461  */
462 struct dprc_cfg {
463 	uint16_t icid;
464 	int portal_id;
465 	uint64_t options;
466 	char label[16];
467 };
468 
469 /**
470  * dprc_reset_container - Reset child container.
471  * @mc_io:	Pointer to MC portal's I/O object
472  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
473  * @token:	Token of DPRC object
474  * @child_container_id:	ID of the container to reset
475  *
476  * In case a software context crashes or becomes non-responsive, the parent
477  * may wish to reset its resources container before the software context is
478  * restarted.
479  *
480  * This routine informs all objects assigned to the child container that the
481  * container is being reset, so they may perform any cleanup operations that are
482  * needed. All objects handles that were owned by the child container shall be
483  * closed.
484  *
485  * Note that such request may be submitted even if the child software context
486  * has not crashed, but the resulting object cleanup operations will not be
487  * aware of that.
488  *
489  * Return:	'0' on Success; Error code otherwise.
490  */
491 int dprc_reset_container(struct fsl_mc_io	*mc_io,
492 			 uint32_t		cmd_flags,
493 			 uint16_t		token,
494 			 int			child_container_id);
495 
496 /**
497  * struct dprc_attributes - Container attributes
498  * @container_id: Container's ID
499  * @icid: Container's ICID
500  * @portal_id: Container's portal ID
501  * @options: Container's options as set at container's creation
502  * @version: DPRC version
503  */
504 struct dprc_attributes {
505 	int container_id;
506 	uint16_t icid;
507 	int portal_id;
508 	uint64_t options;
509 	/**
510 	 * struct version - DPRC version
511 	 * @major: DPRC major version
512 	 * @minor: DPRC minor version
513 	 */
514 	struct {
515 		uint16_t major;
516 		uint16_t minor;
517 	} version;
518 };
519 
520 /**
521  * dprc_get_attributes() - Obtains container attributes
522  * @mc_io:	Pointer to MC portal's I/O object
523  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
524  * @token:	Token of DPRC object
525  * @attributes:	Returned container attributes
526  *
527  * Return:     '0' on Success; Error code otherwise.
528  */
529 int dprc_get_attributes(struct fsl_mc_io	*mc_io,
530 			uint32_t		cmd_flags,
531 			uint16_t		token,
532 			struct dprc_attributes	*attributes);
533 
534 /**
535  * dprc_get_obj_count() - Obtains the number of objects in the DPRC
536  * @mc_io:	Pointer to MC portal's I/O object
537  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
538  * @token:	Token of DPRC object
539  * @obj_count:	Number of objects assigned to the DPRC
540  *
541  * Return:	'0' on Success; Error code otherwise.
542  */
543 int dprc_get_obj_count(struct fsl_mc_io	*mc_io,
544 		       uint32_t		cmd_flags,
545 		       uint16_t		token,
546 		       int			*obj_count);
547 
548 /* Objects Attributes Flags */
549 
550 /* Opened state - Indicates that an object is open by at least one owner */
551 #define DPRC_OBJ_STATE_OPEN		0x00000001
552 /* Plugged state - Indicates that the object is plugged */
553 #define DPRC_OBJ_STATE_PLUGGED		0x00000002
554 
555 /**
556  * struct dprc_obj_desc - Object descriptor, returned from dprc_get_obj()
557  * @type: Type of object: NULL terminated string
558  * @id: ID of logical object resource
559  * @vendor: Object vendor identifier
560  * @ver_major: Major version number
561  * @ver_minor:  Minor version number
562  * @irq_count: Number of interrupts supported by the object
563  * @region_count: Number of mappable regions supported by the object
564  * @state: Object state: combination of DPRC_OBJ_STATE_ states
565  * @label: Object label
566  */
567 struct dprc_obj_desc {
568 	char type[16];
569 	int id;
570 	uint16_t vendor;
571 	uint16_t ver_major;
572 	uint16_t ver_minor;
573 	uint8_t irq_count;
574 	uint8_t region_count;
575 	uint32_t state;
576 	char label[16];
577 };
578 
579 /**
580  * dprc_get_obj() - Get general information on an object
581  * @mc_io:	Pointer to MC portal's I/O object
582  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
583  * @token:	Token of DPRC object
584  * @obj_index:	Index of the object to be queried (< obj_count)
585  * @obj_desc:	Returns the requested object descriptor
586  *
587  * The object descriptors are retrieved one by one by incrementing
588  * obj_index up to (not including) the value of obj_count returned
589  * from dprc_get_obj_count(). dprc_get_obj_count() must
590  * be called prior to dprc_get_obj().
591  *
592  * Return:	'0' on Success; Error code otherwise.
593  */
594 int dprc_get_obj(struct fsl_mc_io	*mc_io,
595 		 uint32_t		cmd_flags,
596 		 uint16_t		token,
597 		 int			obj_index,
598 		 struct dprc_obj_desc	*obj_desc);
599 
600 /**
601  * dprc_get_res_count() - Obtains the number of free resources that are
602  *		assigned to this container, by pool type
603  * @mc_io:	Pointer to MC portal's I/O object
604  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
605  * @token:	Token of DPRC object
606  * @type:	pool type
607  * @res_count:	Returned number of free resources of the given
608  *			resource type that are assigned to this DPRC
609  *
610  * Return:	'0' on Success; Error code otherwise.
611  */
612 int dprc_get_res_count(struct fsl_mc_io *mc_io,
613 		       uint32_t	cmd_flags,
614 		       uint16_t		token,
615 		       char		*type,
616 		       int		*res_count);
617 
618 /**
619  * enum dprc_iter_status - Iteration status
620  * @DPRC_ITER_STATUS_FIRST: Perform first iteration
621  * @DPRC_ITER_STATUS_MORE: Indicates more/next iteration is needed
622  * @DPRC_ITER_STATUS_LAST: Indicates last iteration
623  */
624 enum dprc_iter_status {
625 	DPRC_ITER_STATUS_FIRST = 0,
626 	DPRC_ITER_STATUS_MORE = 1,
627 	DPRC_ITER_STATUS_LAST = 2
628 };
629 
630 /**
631  * struct dprc_res_ids_range_desc - Resource ID range descriptor
632  * @base_id: Base resource ID of this range
633  * @last_id: Last resource ID of this range
634  * @iter_status: Iteration status - should be set to DPRC_ITER_STATUS_FIRST at
635  *	first iteration; while the returned marker is DPRC_ITER_STATUS_MORE,
636  *	additional iterations are needed, until the returned marker is
637  *	DPRC_ITER_STATUS_LAST
638  */
639 struct dprc_res_ids_range_desc {
640 	int base_id;
641 	int last_id;
642 	enum dprc_iter_status iter_status;
643 };
644 
645 /**
646  * dprc_get_res_ids() - Obtains IDs of free resources in the container
647  * @mc_io:	Pointer to MC portal's I/O object
648  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
649  * @token:	Token of DPRC object
650  * @type:	pool type
651  * @range_desc:	range descriptor
652  *
653  * Return:	'0' on Success; Error code otherwise.
654  */
655 int dprc_get_res_ids(struct fsl_mc_io			*mc_io,
656 		     uint32_t				cmd_flags,
657 		     uint16_t				token,
658 		     char				*type,
659 		     struct dprc_res_ids_range_desc	*range_desc);
660 
661 /* Region flags */
662 /* Cacheable - Indicates that region should be mapped as cacheable */
663 #define DPRC_REGION_CACHEABLE	0x00000001
664 
665 /**
666  * enum dprc_region_type - Region type
667  * @DPRC_REGION_TYPE_MC_PORTAL: MC portal region
668  * @DPRC_REGION_TYPE_QBMAN_PORTAL: Qbman portal region
669  */
670 enum dprc_region_type {
671 	DPRC_REGION_TYPE_MC_PORTAL,
672 	DPRC_REGION_TYPE_QBMAN_PORTAL
673 };
674 
675 /**
676  * struct dprc_region_desc - Mappable region descriptor
677  * @base_offset: Region offset from region's base address.
678  *	For DPMCP and DPRC objects, region base is offset from SoC MC portals
679  *	base address; For DPIO, region base is offset from SoC QMan portals
680  *	base address
681  * @size: Region size (in bytes)
682  * @flags: Region attributes
683  * @type: Portal region type
684  */
685 struct dprc_region_desc {
686 	uint32_t base_offset;
687 	uint32_t size;
688 	uint32_t flags;
689 	enum dprc_region_type type;
690 };
691 
692 /**
693  * dprc_get_obj_region() - Get region information for a specified object.
694  * @mc_io:	Pointer to MC portal's I/O object
695  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
696  * @token:	Token of DPRC object
697  * @obj_type:	Object type as returned in dprc_get_obj()
698  * @obj_id:	Unique object instance as returned in dprc_get_obj()
699  * @region_index: The specific region to query
700  * @region_desc:  Returns the requested region descriptor
701  *
702  * Return:	'0' on Success; Error code otherwise.
703  */
704 int dprc_get_obj_region(struct fsl_mc_io	*mc_io,
705 			uint32_t		cmd_flags,
706 			uint16_t		token,
707 			char			*obj_type,
708 			int			obj_id,
709 			uint8_t			region_index,
710 			struct dprc_region_desc	*region_desc);
711 /**
712  * struct dprc_endpoint - Endpoint description for link connect/disconnect
713  *			operations
714  * @type: Endpoint object type: NULL terminated string
715  * @id: Endpoint object ID
716  * @if_id: Interface ID; should be set for endpoints with multiple
717  *		interfaces ("dpsw", "dpdmux"); for others, always set to 0
718  */
719 struct dprc_endpoint {
720 	char		type[16];
721 	int		id;
722 	uint16_t	if_id;
723 };
724 
725 /**
726  * struct dprc_connection_cfg - Connection configuration.
727  *				Used for virtual connections only
728  * @committed_rate: Committed rate (Mbits/s)
729  * @max_rate: Maximum rate (Mbits/s)
730  */
731 struct dprc_connection_cfg {
732 	uint32_t committed_rate;
733 	uint32_t max_rate;
734 };
735 
736 /**
737  * dprc_connect() - Connect two endpoints to create a network link between them
738  * @mc_io:	Pointer to MC portal's I/O object
739  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
740  * @token:	Token of DPRC object
741  * @endpoint1:	Endpoint 1 configuration parameters
742  * @endpoint2:	Endpoint 2 configuration parameters
743  * @cfg: Connection configuration. The connection configuration is ignored for
744  *	connections made to DPMAC objects, where rate is retrieved from the
745  *	MAC configuration.
746  *
747  * Return:	'0' on Success; Error code otherwise.
748  */
749 int dprc_connect(struct fsl_mc_io			*mc_io,
750 		 uint32_t				cmd_flags,
751 		 uint16_t				token,
752 		 const struct dprc_endpoint		*endpoint1,
753 		 const struct dprc_endpoint		*endpoint2,
754 		 const struct dprc_connection_cfg	*cfg);
755 
756 /**
757  * dprc_disconnect() - Disconnect one endpoint to remove its network connection
758  * @mc_io:	Pointer to MC portal's I/O object
759  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
760  * @token:	Token of DPRC object
761  * @endpoint:	Endpoint configuration parameters
762  *
763  * Return:	'0' on Success; Error code otherwise.
764  */
765 int dprc_disconnect(struct fsl_mc_io		*mc_io,
766 		    uint32_t			cmd_flags,
767 		    uint16_t			token,
768 		    const struct dprc_endpoint	*endpoint);
769 
770 /**
771 * dprc_get_connection() - Get connected endpoint and link status if connection
772 *			exists.
773 * @mc_io:	Pointer to MC portal's I/O object
774 * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
775 * @token:	Token of DPRC object
776 * @endpoint1:	Endpoint 1 configuration parameters
777 * @endpoint2:	Returned endpoint 2 configuration parameters
778 * @state:	Returned link state: 1 - link is up, 0 - link is down
779 *
780 * Return:     '0' on Success; -ENAVAIL if connection does not exist.
781 */
782 int dprc_get_connection(struct fsl_mc_io		*mc_io,
783 			uint32_t			cmd_flags,
784 			uint16_t			token,
785 			const struct dprc_endpoint	*endpoint1,
786 			struct dprc_endpoint		*endpoint2,
787 			int				*state);
788 
789 #endif /* _FSL_DPRC_H */
790