2 * Freescale Layerscape MC I/O wrapper
4 * Copyright (C) 2013-2015 Freescale Semiconductor, Inc.
5 * Author: German Rivera <German.Rivera@freescale.com>
7 * SPDX-License-Identifier: GPL-2.0+
10 #include <fsl-mc/fsl_mc_sys.h>
11 #include <fsl-mc/fsl_mc_cmd.h>
12 #include <fsl-mc/fsl_dprc.h>
14 int dprc_get_container_id(struct fsl_mc_io *mc_io,
18 struct mc_command cmd = { 0 };
22 cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_CONT_ID,
26 /* send command to mc*/
27 err = mc_send_command(mc_io, &cmd);
31 /* retrieve response parameters */
32 DPRC_RSP_GET_CONTAINER_ID(cmd, *container_id);
37 int dprc_open(struct fsl_mc_io *mc_io,
42 struct mc_command cmd = { 0 };
46 cmd.header = mc_encode_cmd_header(DPRC_CMDID_OPEN, cmd_flags,
48 DPRC_CMD_OPEN(cmd, container_id);
50 /* send command to mc*/
51 err = mc_send_command(mc_io, &cmd);
55 /* retrieve response parameters */
56 *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
61 int dprc_close(struct fsl_mc_io *mc_io,
65 struct mc_command cmd = { 0 };
68 cmd.header = mc_encode_cmd_header(DPRC_CMDID_CLOSE, cmd_flags,
71 /* send command to mc*/
72 return mc_send_command(mc_io, &cmd);
75 int dprc_create_container(struct fsl_mc_io *mc_io,
79 int *child_container_id,
80 uint64_t *child_portal_paddr)
82 struct mc_command cmd = { 0 };
86 DPRC_CMD_CREATE_CONTAINER(cmd, cfg);
88 cmd.header = mc_encode_cmd_header(DPRC_CMDID_CREATE_CONT,
92 /* send command to mc*/
93 err = mc_send_command(mc_io, &cmd);
97 /* retrieve response parameters */
98 DPRC_RSP_CREATE_CONTAINER(cmd, *child_container_id,
104 int dprc_destroy_container(struct fsl_mc_io *mc_io,
107 int child_container_id)
109 struct mc_command cmd = { 0 };
111 /* prepare command */
112 cmd.header = mc_encode_cmd_header(DPRC_CMDID_DESTROY_CONT,
115 DPRC_CMD_DESTROY_CONTAINER(cmd, child_container_id);
117 /* send command to mc*/
118 return mc_send_command(mc_io, &cmd);
121 int dprc_reset_container(struct fsl_mc_io *mc_io,
124 int child_container_id)
126 struct mc_command cmd = { 0 };
128 /* prepare command */
129 cmd.header = mc_encode_cmd_header(DPRC_CMDID_RESET_CONT,
132 DPRC_CMD_RESET_CONTAINER(cmd, child_container_id);
134 /* send command to mc*/
135 return mc_send_command(mc_io, &cmd);
138 int dprc_get_attributes(struct fsl_mc_io *mc_io,
141 struct dprc_attributes *attr)
143 struct mc_command cmd = { 0 };
146 /* prepare command */
147 cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_ATTR,
151 /* send command to mc*/
152 err = mc_send_command(mc_io, &cmd);
156 /* retrieve response parameters */
157 DPRC_RSP_GET_ATTRIBUTES(cmd, attr);
162 int dprc_get_obj_count(struct fsl_mc_io *mc_io,
167 struct mc_command cmd = { 0 };
170 /* prepare command */
171 cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_COUNT,
175 /* send command to mc*/
176 err = mc_send_command(mc_io, &cmd);
180 /* retrieve response parameters */
181 DPRC_RSP_GET_OBJ_COUNT(cmd, *obj_count);
186 int dprc_get_obj(struct fsl_mc_io *mc_io,
190 struct dprc_obj_desc *obj_desc)
192 struct mc_command cmd = { 0 };
195 /* prepare command */
196 cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ,
199 DPRC_CMD_GET_OBJ(cmd, obj_index);
201 /* send command to mc*/
202 err = mc_send_command(mc_io, &cmd);
206 /* retrieve response parameters */
207 DPRC_RSP_GET_OBJ(cmd, obj_desc);
212 int dprc_get_res_count(struct fsl_mc_io *mc_io,
218 struct mc_command cmd = { 0 };
223 /* prepare command */
224 cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_RES_COUNT,
227 DPRC_CMD_GET_RES_COUNT(cmd, type);
229 /* send command to mc*/
230 err = mc_send_command(mc_io, &cmd);
234 /* retrieve response parameters */
235 DPRC_RSP_GET_RES_COUNT(cmd, *res_count);
240 int dprc_get_res_ids(struct fsl_mc_io *mc_io,
244 struct dprc_res_ids_range_desc *range_desc)
246 struct mc_command cmd = { 0 };
249 /* prepare command */
250 cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_RES_IDS,
253 DPRC_CMD_GET_RES_IDS(cmd, range_desc, type);
255 /* send command to mc*/
256 err = mc_send_command(mc_io, &cmd);
260 /* retrieve response parameters */
261 DPRC_RSP_GET_RES_IDS(cmd, range_desc);
266 int dprc_get_obj_region(struct fsl_mc_io *mc_io,
271 uint8_t region_index,
272 struct dprc_region_desc *region_desc)
274 struct mc_command cmd = { 0 };
277 /* prepare command */
278 cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_REG,
281 DPRC_CMD_GET_OBJ_REGION(cmd, obj_type, obj_id, region_index);
283 /* send command to mc*/
284 err = mc_send_command(mc_io, &cmd);
288 /* retrieve response parameters */
289 DPRC_RSP_GET_OBJ_REGION(cmd, region_desc);
294 int dprc_connect(struct fsl_mc_io *mc_io,
297 const struct dprc_endpoint *endpoint1,
298 const struct dprc_endpoint *endpoint2,
299 const struct dprc_connection_cfg *cfg)
301 struct mc_command cmd = { 0 };
303 /* prepare command */
304 cmd.header = mc_encode_cmd_header(DPRC_CMDID_CONNECT,
307 DPRC_CMD_CONNECT(cmd, endpoint1, endpoint2, cfg);
309 /* send command to mc*/
310 return mc_send_command(mc_io, &cmd);
313 int dprc_disconnect(struct fsl_mc_io *mc_io,
316 const struct dprc_endpoint *endpoint)
318 struct mc_command cmd = { 0 };
320 /* prepare command */
321 cmd.header = mc_encode_cmd_header(DPRC_CMDID_DISCONNECT,
324 DPRC_CMD_DISCONNECT(cmd, endpoint);
326 /* send command to mc*/
327 return mc_send_command(mc_io, &cmd);
330 int dprc_get_connection(struct fsl_mc_io *mc_io,
333 const struct dprc_endpoint *endpoint1,
334 struct dprc_endpoint *endpoint2,
337 struct mc_command cmd = { 0 };
340 /* prepare command */
341 cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_CONNECTION,
344 DPRC_CMD_GET_CONNECTION(cmd, endpoint1);
346 /* send command to mc*/
347 err = mc_send_command(mc_io, &cmd);
351 /* retrieve response parameters */
352 DPRC_RSP_GET_CONNECTION(cmd, endpoint2, *state);