1 /* Copyright 2013-2014 Freescale Semiconductor Inc.
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
5 * * Redistributions of source code must retain the above copyright
6 * notice, this list of conditions and the following disclaimer.
7 * * Redistributions in binary form must reproduce the above copyright
8 * notice, this list of conditions and the following disclaimer in the
9 * documentation and/or other materials provided with the distribution.
10 * * Neither the name of the above-listed copyright holders nor the
11 * names of any contributors may be used to endorse or promote products
12 * derived from this software without specific prior written permission.
15 * ALTERNATIVELY, this software may be distributed under the terms of the
16 * GNU General Public License ("GPL") as published by the Free Software
17 * Foundation, either version 2 of that License or (at your option) any
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
32 #include "../include/mc-sys.h"
33 #include "../include/mc-cmd.h"
34 #include "../include/dprc.h"
37 int dprc_open(struct fsl_mc_io
*mc_io
, int container_id
, uint16_t *token
)
39 struct mc_command cmd
= { 0 };
43 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_OPEN
, MC_CMD_PRI_LOW
,
45 cmd
.params
[0] |= mc_enc(0, 32, container_id
);
47 /* send command to mc*/
48 err
= mc_send_command(mc_io
, &cmd
);
52 /* retrieve response parameters */
53 *token
= MC_CMD_HDR_READ_TOKEN(cmd
.header
);
57 EXPORT_SYMBOL(dprc_open
);
59 int dprc_close(struct fsl_mc_io
*mc_io
, uint16_t token
)
61 struct mc_command cmd
= { 0 };
64 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_CLOSE
, MC_CMD_PRI_HIGH
,
67 /* send command to mc*/
68 return mc_send_command(mc_io
, &cmd
);
70 EXPORT_SYMBOL(dprc_close
);
72 int dprc_create_container(struct fsl_mc_io
*mc_io
,
75 int *child_container_id
,
76 uint64_t *child_portal_paddr
)
78 struct mc_command cmd
= { 0 };
82 cmd
.params
[0] |= mc_enc(32, 16, cfg
->icid
);
83 cmd
.params
[0] |= mc_enc(0, 32, cfg
->options
);
84 cmd
.params
[1] |= mc_enc(32, 32, cfg
->portal_id
);
86 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_CREATE_CONT
,
87 MC_CMD_PRI_LOW
, token
);
89 /* send command to mc*/
90 err
= mc_send_command(mc_io
, &cmd
);
94 /* retrieve response parameters */
95 *child_container_id
= mc_dec(cmd
.params
[1], 0, 32);
96 *child_portal_paddr
= mc_dec(cmd
.params
[2], 0, 64);
101 int dprc_destroy_container(struct fsl_mc_io
*mc_io
,
103 int child_container_id
)
105 struct mc_command cmd
= { 0 };
107 /* prepare command */
108 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_DESTROY_CONT
,
109 MC_CMD_PRI_LOW
, token
);
110 cmd
.params
[0] |= mc_enc(0, 32, child_container_id
);
112 /* send command to mc*/
113 return mc_send_command(mc_io
, &cmd
);
116 int dprc_reset_container(struct fsl_mc_io
*mc_io
,
118 int child_container_id
)
120 struct mc_command cmd
= { 0 };
122 /* prepare command */
123 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_RESET_CONT
,
124 MC_CMD_PRI_LOW
, token
);
125 cmd
.params
[0] |= mc_enc(0, 32, child_container_id
);
127 /* send command to mc*/
128 return mc_send_command(mc_io
, &cmd
);
131 int dprc_get_irq(struct fsl_mc_io
*mc_io
,
139 struct mc_command cmd
= { 0 };
142 /* prepare command */
143 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_GET_IRQ
,
146 cmd
.params
[0] |= mc_enc(32, 8, irq_index
);
148 /* send command to mc*/
149 err
= mc_send_command(mc_io
, &cmd
);
153 /* retrieve response parameters */
154 *irq_val
= mc_dec(cmd
.params
[0], 0, 32);
155 *irq_paddr
= mc_dec(cmd
.params
[1], 0, 64);
156 *user_irq_id
= mc_dec(cmd
.params
[2], 0, 32);
157 *type
= mc_dec(cmd
.params
[2], 32, 32);
162 int dprc_set_irq(struct fsl_mc_io
*mc_io
,
169 struct mc_command cmd
= { 0 };
171 /* prepare command */
172 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_SET_IRQ
,
175 cmd
.params
[0] |= mc_enc(32, 8, irq_index
);
176 cmd
.params
[0] |= mc_enc(0, 32, irq_val
);
177 cmd
.params
[1] |= mc_enc(0, 64, irq_paddr
);
178 cmd
.params
[2] |= mc_enc(0, 32, user_irq_id
);
180 /* send command to mc*/
181 return mc_send_command(mc_io
, &cmd
);
184 int dprc_get_irq_enable(struct fsl_mc_io
*mc_io
,
189 struct mc_command cmd
= { 0 };
192 /* prepare command */
193 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_GET_IRQ_ENABLE
,
194 MC_CMD_PRI_LOW
, token
);
195 cmd
.params
[0] |= mc_enc(32, 8, irq_index
);
197 /* send command to mc*/
198 err
= mc_send_command(mc_io
, &cmd
);
202 /* retrieve response parameters */
203 *en
= mc_dec(cmd
.params
[0], 0, 8);
208 int dprc_set_irq_enable(struct fsl_mc_io
*mc_io
,
213 struct mc_command cmd
= { 0 };
215 /* prepare command */
216 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_SET_IRQ_ENABLE
,
217 MC_CMD_PRI_LOW
, token
);
218 cmd
.params
[0] |= mc_enc(0, 8, en
);
219 cmd
.params
[0] |= mc_enc(32, 8, irq_index
);
221 /* send command to mc*/
222 return mc_send_command(mc_io
, &cmd
);
225 int dprc_get_irq_mask(struct fsl_mc_io
*mc_io
,
230 struct mc_command cmd
= { 0 };
233 /* prepare command */
234 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_GET_IRQ_MASK
,
235 MC_CMD_PRI_LOW
, token
);
236 cmd
.params
[0] |= mc_enc(32, 8, irq_index
);
238 /* send command to mc*/
239 err
= mc_send_command(mc_io
, &cmd
);
243 /* retrieve response parameters */
244 *mask
= mc_dec(cmd
.params
[0], 0, 32);
249 int dprc_set_irq_mask(struct fsl_mc_io
*mc_io
,
254 struct mc_command cmd
= { 0 };
256 /* prepare command */
257 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_SET_IRQ_MASK
,
258 MC_CMD_PRI_LOW
, token
);
259 cmd
.params
[0] |= mc_enc(0, 32, mask
);
260 cmd
.params
[0] |= mc_enc(32, 8, irq_index
);
262 /* send command to mc*/
263 return mc_send_command(mc_io
, &cmd
);
266 int dprc_get_irq_status(struct fsl_mc_io
*mc_io
,
271 struct mc_command cmd
= { 0 };
274 /* prepare command */
275 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_GET_IRQ_STATUS
,
276 MC_CMD_PRI_LOW
, token
);
277 cmd
.params
[0] |= mc_enc(32, 8, irq_index
);
279 /* send command to mc*/
280 err
= mc_send_command(mc_io
, &cmd
);
284 /* retrieve response parameters */
285 *status
= mc_dec(cmd
.params
[0], 0, 32);
290 int dprc_clear_irq_status(struct fsl_mc_io
*mc_io
,
295 struct mc_command cmd
= { 0 };
297 /* prepare command */
298 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_CLEAR_IRQ_STATUS
,
299 MC_CMD_PRI_LOW
, token
);
300 cmd
.params
[0] |= mc_enc(0, 32, status
);
301 cmd
.params
[0] |= mc_enc(32, 8, irq_index
);
303 /* send command to mc*/
304 return mc_send_command(mc_io
, &cmd
);
307 int dprc_get_attributes(struct fsl_mc_io
*mc_io
,
309 struct dprc_attributes
*attr
)
311 struct mc_command cmd
= { 0 };
314 /* prepare command */
315 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_GET_ATTR
,
319 /* send command to mc*/
320 err
= mc_send_command(mc_io
, &cmd
);
324 /* retrieve response parameters */
325 attr
->container_id
= mc_dec(cmd
.params
[0], 0, 32);
326 attr
->icid
= mc_dec(cmd
.params
[0], 32, 16);
327 attr
->options
= mc_dec(cmd
.params
[1], 0, 32);
328 attr
->portal_id
= mc_dec(cmd
.params
[1], 32, 32);
329 attr
->version
.major
= mc_dec(cmd
.params
[2], 0, 16);
330 attr
->version
.minor
= mc_dec(cmd
.params
[2], 16, 16);
335 int dprc_set_res_quota(struct fsl_mc_io
*mc_io
,
337 int child_container_id
,
341 struct mc_command cmd
= { 0 };
343 /* prepare command */
344 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_SET_RES_QUOTA
,
345 MC_CMD_PRI_LOW
, token
);
346 cmd
.params
[0] |= mc_enc(0, 32, child_container_id
);
347 cmd
.params
[0] |= mc_enc(32, 16, quota
);
348 cmd
.params
[1] |= mc_enc(0, 8, type
[0]);
349 cmd
.params
[1] |= mc_enc(8, 8, type
[1]);
350 cmd
.params
[1] |= mc_enc(16, 8, type
[2]);
351 cmd
.params
[1] |= mc_enc(24, 8, type
[3]);
352 cmd
.params
[1] |= mc_enc(32, 8, type
[4]);
353 cmd
.params
[1] |= mc_enc(40, 8, type
[5]);
354 cmd
.params
[1] |= mc_enc(48, 8, type
[6]);
355 cmd
.params
[1] |= mc_enc(56, 8, type
[7]);
356 cmd
.params
[2] |= mc_enc(0, 8, type
[8]);
357 cmd
.params
[2] |= mc_enc(8, 8, type
[9]);
358 cmd
.params
[2] |= mc_enc(16, 8, type
[10]);
359 cmd
.params
[2] |= mc_enc(24, 8, type
[11]);
360 cmd
.params
[2] |= mc_enc(32, 8, type
[12]);
361 cmd
.params
[2] |= mc_enc(40, 8, type
[13]);
362 cmd
.params
[2] |= mc_enc(48, 8, type
[14]);
363 cmd
.params
[2] |= mc_enc(56, 8, '\0');
365 /* send command to mc*/
366 return mc_send_command(mc_io
, &cmd
);
369 int dprc_get_res_quota(struct fsl_mc_io
*mc_io
,
371 int child_container_id
,
375 struct mc_command cmd
= { 0 };
378 /* prepare command */
379 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_GET_RES_QUOTA
,
380 MC_CMD_PRI_LOW
, token
);
381 cmd
.params
[0] |= mc_enc(0, 32, child_container_id
);
382 cmd
.params
[1] |= mc_enc(0, 8, type
[0]);
383 cmd
.params
[1] |= mc_enc(8, 8, type
[1]);
384 cmd
.params
[1] |= mc_enc(16, 8, type
[2]);
385 cmd
.params
[1] |= mc_enc(24, 8, type
[3]);
386 cmd
.params
[1] |= mc_enc(32, 8, type
[4]);
387 cmd
.params
[1] |= mc_enc(40, 8, type
[5]);
388 cmd
.params
[1] |= mc_enc(48, 8, type
[6]);
389 cmd
.params
[1] |= mc_enc(56, 8, type
[7]);
390 cmd
.params
[2] |= mc_enc(0, 8, type
[8]);
391 cmd
.params
[2] |= mc_enc(8, 8, type
[9]);
392 cmd
.params
[2] |= mc_enc(16, 8, type
[10]);
393 cmd
.params
[2] |= mc_enc(24, 8, type
[11]);
394 cmd
.params
[2] |= mc_enc(32, 8, type
[12]);
395 cmd
.params
[2] |= mc_enc(40, 8, type
[13]);
396 cmd
.params
[2] |= mc_enc(48, 8, type
[14]);
397 cmd
.params
[2] |= mc_enc(56, 8, '\0');
399 /* send command to mc*/
400 err
= mc_send_command(mc_io
, &cmd
);
404 /* retrieve response parameters */
405 *quota
= mc_dec(cmd
.params
[0], 32, 16);
410 int dprc_assign(struct fsl_mc_io
*mc_io
,
413 struct dprc_res_req
*res_req
)
415 struct mc_command cmd
= { 0 };
417 /* prepare command */
418 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_ASSIGN
,
419 MC_CMD_PRI_LOW
, token
);
420 cmd
.params
[0] |= mc_enc(0, 32, container_id
);
421 cmd
.params
[0] |= mc_enc(32, 32, res_req
->options
);
422 cmd
.params
[1] |= mc_enc(0, 32, res_req
->num
);
423 cmd
.params
[1] |= mc_enc(32, 32, res_req
->id_base_align
);
424 cmd
.params
[2] |= mc_enc(0, 8, res_req
->type
[0]);
425 cmd
.params
[2] |= mc_enc(8, 8, res_req
->type
[1]);
426 cmd
.params
[2] |= mc_enc(16, 8, res_req
->type
[2]);
427 cmd
.params
[2] |= mc_enc(24, 8, res_req
->type
[3]);
428 cmd
.params
[2] |= mc_enc(32, 8, res_req
->type
[4]);
429 cmd
.params
[2] |= mc_enc(40, 8, res_req
->type
[5]);
430 cmd
.params
[2] |= mc_enc(48, 8, res_req
->type
[6]);
431 cmd
.params
[2] |= mc_enc(56, 8, res_req
->type
[7]);
432 cmd
.params
[3] |= mc_enc(0, 8, res_req
->type
[8]);
433 cmd
.params
[3] |= mc_enc(8, 8, res_req
->type
[9]);
434 cmd
.params
[3] |= mc_enc(16, 8, res_req
->type
[10]);
435 cmd
.params
[3] |= mc_enc(24, 8, res_req
->type
[11]);
436 cmd
.params
[3] |= mc_enc(32, 8, res_req
->type
[12]);
437 cmd
.params
[3] |= mc_enc(40, 8, res_req
->type
[13]);
438 cmd
.params
[3] |= mc_enc(48, 8, res_req
->type
[14]);
439 cmd
.params
[3] |= mc_enc(56, 8, res_req
->type
[15]);
441 /* send command to mc*/
442 return mc_send_command(mc_io
, &cmd
);
445 int dprc_unassign(struct fsl_mc_io
*mc_io
,
447 int child_container_id
,
448 struct dprc_res_req
*res_req
)
450 struct mc_command cmd
= { 0 };
452 /* prepare command */
453 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_UNASSIGN
,
456 cmd
.params
[0] |= mc_enc(0, 32, child_container_id
);
457 cmd
.params
[0] |= mc_enc(32, 32, res_req
->options
);
458 cmd
.params
[1] |= mc_enc(0, 32, res_req
->num
);
459 cmd
.params
[1] |= mc_enc(32, 32, res_req
->id_base_align
);
460 cmd
.params
[2] |= mc_enc(0, 8, res_req
->type
[0]);
461 cmd
.params
[2] |= mc_enc(8, 8, res_req
->type
[1]);
462 cmd
.params
[2] |= mc_enc(16, 8, res_req
->type
[2]);
463 cmd
.params
[2] |= mc_enc(24, 8, res_req
->type
[3]);
464 cmd
.params
[2] |= mc_enc(32, 8, res_req
->type
[4]);
465 cmd
.params
[2] |= mc_enc(40, 8, res_req
->type
[5]);
466 cmd
.params
[2] |= mc_enc(48, 8, res_req
->type
[6]);
467 cmd
.params
[2] |= mc_enc(56, 8, res_req
->type
[7]);
468 cmd
.params
[3] |= mc_enc(0, 8, res_req
->type
[8]);
469 cmd
.params
[3] |= mc_enc(8, 8, res_req
->type
[9]);
470 cmd
.params
[3] |= mc_enc(16, 8, res_req
->type
[10]);
471 cmd
.params
[3] |= mc_enc(24, 8, res_req
->type
[11]);
472 cmd
.params
[3] |= mc_enc(32, 8, res_req
->type
[12]);
473 cmd
.params
[3] |= mc_enc(40, 8, res_req
->type
[13]);
474 cmd
.params
[3] |= mc_enc(48, 8, res_req
->type
[14]);
475 cmd
.params
[3] |= mc_enc(56, 8, res_req
->type
[15]);
477 /* send command to mc*/
478 return mc_send_command(mc_io
, &cmd
);
481 int dprc_get_pool_count(struct fsl_mc_io
*mc_io
,
485 struct mc_command cmd
= { 0 };
488 /* prepare command */
489 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_GET_POOL_COUNT
,
490 MC_CMD_PRI_LOW
, token
);
492 /* send command to mc*/
493 err
= mc_send_command(mc_io
, &cmd
);
497 /* retrieve response parameters */
498 *pool_count
= mc_dec(cmd
.params
[0], 0, 32);
503 int dprc_get_pool(struct fsl_mc_io
*mc_io
,
508 struct mc_command cmd
= { 0 };
511 /* prepare command */
512 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_GET_POOL
,
515 cmd
.params
[0] |= mc_enc(0, 32, pool_index
);
517 /* send command to mc*/
518 err
= mc_send_command(mc_io
, &cmd
);
522 /* retrieve response parameters */
523 type
[0] = mc_dec(cmd
.params
[1], 0, 8);
524 type
[1] = mc_dec(cmd
.params
[1], 8, 8);
525 type
[2] = mc_dec(cmd
.params
[1], 16, 8);
526 type
[3] = mc_dec(cmd
.params
[1], 24, 8);
527 type
[4] = mc_dec(cmd
.params
[1], 32, 8);
528 type
[5] = mc_dec(cmd
.params
[1], 40, 8);
529 type
[6] = mc_dec(cmd
.params
[1], 48, 8);
530 type
[7] = mc_dec(cmd
.params
[1], 56, 8);
531 type
[8] = mc_dec(cmd
.params
[2], 0, 8);
532 type
[9] = mc_dec(cmd
.params
[2], 8, 8);
533 type
[10] = mc_dec(cmd
.params
[2], 16, 8);
534 type
[11] = mc_dec(cmd
.params
[2], 24, 8);
535 type
[12] = mc_dec(cmd
.params
[2], 32, 8);
536 type
[13] = mc_dec(cmd
.params
[2], 40, 8);
537 type
[14] = mc_dec(cmd
.params
[2], 48, 8);
543 int dprc_get_obj_count(struct fsl_mc_io
*mc_io
, uint16_t token
, int *obj_count
)
545 struct mc_command cmd
= { 0 };
548 /* prepare command */
549 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_COUNT
,
550 MC_CMD_PRI_LOW
, token
);
552 /* send command to mc*/
553 err
= mc_send_command(mc_io
, &cmd
);
557 /* retrieve response parameters */
558 *obj_count
= mc_dec(cmd
.params
[0], 32, 32);
562 EXPORT_SYMBOL(dprc_get_obj_count
);
564 int dprc_get_obj(struct fsl_mc_io
*mc_io
,
567 struct dprc_obj_desc
*obj_desc
)
569 struct mc_command cmd
= { 0 };
572 /* prepare command */
573 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_GET_OBJ
,
576 cmd
.params
[0] |= mc_enc(0, 32, obj_index
);
578 /* send command to mc*/
579 err
= mc_send_command(mc_io
, &cmd
);
583 /* retrieve response parameters */
584 obj_desc
->id
= mc_dec(cmd
.params
[0], 32, 32);
585 obj_desc
->vendor
= mc_dec(cmd
.params
[1], 0, 16);
586 obj_desc
->irq_count
= mc_dec(cmd
.params
[1], 16, 8);
587 obj_desc
->region_count
= mc_dec(cmd
.params
[1], 24, 8);
588 obj_desc
->state
= mc_dec(cmd
.params
[1], 32, 32);
589 obj_desc
->ver_major
= mc_dec(cmd
.params
[2], 0, 16);
590 obj_desc
->ver_minor
= mc_dec(cmd
.params
[2], 16, 16);
591 obj_desc
->type
[0] = mc_dec(cmd
.params
[3], 0, 8);
592 obj_desc
->type
[1] = mc_dec(cmd
.params
[3], 8, 8);
593 obj_desc
->type
[2] = mc_dec(cmd
.params
[3], 16, 8);
594 obj_desc
->type
[3] = mc_dec(cmd
.params
[3], 24, 8);
595 obj_desc
->type
[4] = mc_dec(cmd
.params
[3], 32, 8);
596 obj_desc
->type
[5] = mc_dec(cmd
.params
[3], 40, 8);
597 obj_desc
->type
[6] = mc_dec(cmd
.params
[3], 48, 8);
598 obj_desc
->type
[7] = mc_dec(cmd
.params
[3], 56, 8);
599 obj_desc
->type
[8] = mc_dec(cmd
.params
[4], 0, 8);
600 obj_desc
->type
[9] = mc_dec(cmd
.params
[4], 8, 8);
601 obj_desc
->type
[10] = mc_dec(cmd
.params
[4], 16, 8);
602 obj_desc
->type
[11] = mc_dec(cmd
.params
[4], 24, 8);
603 obj_desc
->type
[12] = mc_dec(cmd
.params
[4], 32, 8);
604 obj_desc
->type
[13] = mc_dec(cmd
.params
[4], 40, 8);
605 obj_desc
->type
[14] = mc_dec(cmd
.params
[4], 48, 8);
606 obj_desc
->type
[15] = '\0';
610 EXPORT_SYMBOL(dprc_get_obj
);
612 int dprc_get_res_count(struct fsl_mc_io
*mc_io
,
617 struct mc_command cmd
= { 0 };
622 /* prepare command */
623 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_GET_RES_COUNT
,
624 MC_CMD_PRI_LOW
, token
);
625 cmd
.params
[1] |= mc_enc(0, 8, type
[0]);
626 cmd
.params
[1] |= mc_enc(8, 8, type
[1]);
627 cmd
.params
[1] |= mc_enc(16, 8, type
[2]);
628 cmd
.params
[1] |= mc_enc(24, 8, type
[3]);
629 cmd
.params
[1] |= mc_enc(32, 8, type
[4]);
630 cmd
.params
[1] |= mc_enc(40, 8, type
[5]);
631 cmd
.params
[1] |= mc_enc(48, 8, type
[6]);
632 cmd
.params
[1] |= mc_enc(56, 8, type
[7]);
633 cmd
.params
[2] |= mc_enc(0, 8, type
[8]);
634 cmd
.params
[2] |= mc_enc(8, 8, type
[9]);
635 cmd
.params
[2] |= mc_enc(16, 8, type
[10]);
636 cmd
.params
[2] |= mc_enc(24, 8, type
[11]);
637 cmd
.params
[2] |= mc_enc(32, 8, type
[12]);
638 cmd
.params
[2] |= mc_enc(40, 8, type
[13]);
639 cmd
.params
[2] |= mc_enc(48, 8, type
[14]);
640 cmd
.params
[2] |= mc_enc(56, 8, '\0');
642 /* send command to mc*/
643 err
= mc_send_command(mc_io
, &cmd
);
647 /* retrieve response parameters */
648 *res_count
= mc_dec(cmd
.params
[0], 0, 32);
652 EXPORT_SYMBOL(dprc_get_res_count
);
654 int dprc_get_res_ids(struct fsl_mc_io
*mc_io
,
657 struct dprc_res_ids_range_desc
*range_desc
)
659 struct mc_command cmd
= { 0 };
662 /* prepare command */
663 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_GET_RES_IDS
,
664 MC_CMD_PRI_LOW
, token
);
665 cmd
.params
[0] |= mc_enc(42, 7, range_desc
->iter_status
);
666 cmd
.params
[1] |= mc_enc(0, 32, range_desc
->base_id
);
667 cmd
.params
[1] |= mc_enc(32, 32, range_desc
->last_id
);
668 cmd
.params
[2] |= mc_enc(0, 8, type
[0]);
669 cmd
.params
[2] |= mc_enc(8, 8, type
[1]);
670 cmd
.params
[2] |= mc_enc(16, 8, type
[2]);
671 cmd
.params
[2] |= mc_enc(24, 8, type
[3]);
672 cmd
.params
[2] |= mc_enc(32, 8, type
[4]);
673 cmd
.params
[2] |= mc_enc(40, 8, type
[5]);
674 cmd
.params
[2] |= mc_enc(48, 8, type
[6]);
675 cmd
.params
[2] |= mc_enc(56, 8, type
[7]);
676 cmd
.params
[3] |= mc_enc(0, 8, type
[8]);
677 cmd
.params
[3] |= mc_enc(8, 8, type
[9]);
678 cmd
.params
[3] |= mc_enc(16, 8, type
[10]);
679 cmd
.params
[3] |= mc_enc(24, 8, type
[11]);
680 cmd
.params
[3] |= mc_enc(32, 8, type
[12]);
681 cmd
.params
[3] |= mc_enc(40, 8, type
[13]);
682 cmd
.params
[3] |= mc_enc(48, 8, type
[14]);
683 cmd
.params
[3] |= mc_enc(56, 8, '\0');
685 /* send command to mc*/
686 err
= mc_send_command(mc_io
, &cmd
);
690 /* retrieve response parameters */
691 range_desc
->iter_status
= mc_dec(cmd
.params
[0], 42, 7);
692 range_desc
->base_id
= mc_dec(cmd
.params
[1], 0, 32);
693 range_desc
->last_id
= mc_dec(cmd
.params
[1], 32, 32);
697 EXPORT_SYMBOL(dprc_get_res_ids
);
699 int dprc_get_portal_paddr(struct fsl_mc_io
*mc_io
,
702 uint64_t *portal_addr
)
704 struct mc_command cmd
= { 0 };
707 /* prepare command */
708 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_GET_PORTAL_PADDR
,
709 MC_CMD_PRI_LOW
, token
);
710 cmd
.params
[0] |= mc_enc(0, 32, portal_id
);
712 /* send command to mc*/
713 err
= mc_send_command(mc_io
, &cmd
);
717 /* retrieve response parameters */
718 *portal_addr
= mc_dec(cmd
.params
[1], 0, 64);
722 EXPORT_SYMBOL(dprc_get_portal_paddr
);
724 int dprc_get_obj_region(struct fsl_mc_io
*mc_io
,
728 uint8_t region_index
,
729 struct dprc_region_desc
*region_desc
)
731 struct mc_command cmd
= { 0 };
734 /* prepare command */
735 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_REG
,
736 MC_CMD_PRI_LOW
, token
);
737 cmd
.params
[0] |= mc_enc(0, 32, obj_id
);
738 cmd
.params
[0] |= mc_enc(48, 8, region_index
);
739 cmd
.params
[3] |= mc_enc(0, 8, obj_type
[0]);
740 cmd
.params
[3] |= mc_enc(8, 8, obj_type
[1]);
741 cmd
.params
[3] |= mc_enc(16, 8, obj_type
[2]);
742 cmd
.params
[3] |= mc_enc(24, 8, obj_type
[3]);
743 cmd
.params
[3] |= mc_enc(32, 8, obj_type
[4]);
744 cmd
.params
[3] |= mc_enc(40, 8, obj_type
[5]);
745 cmd
.params
[3] |= mc_enc(48, 8, obj_type
[6]);
746 cmd
.params
[3] |= mc_enc(56, 8, obj_type
[7]);
747 cmd
.params
[4] |= mc_enc(0, 8, obj_type
[8]);
748 cmd
.params
[4] |= mc_enc(8, 8, obj_type
[9]);
749 cmd
.params
[4] |= mc_enc(16, 8, obj_type
[10]);
750 cmd
.params
[4] |= mc_enc(24, 8, obj_type
[11]);
751 cmd
.params
[4] |= mc_enc(32, 8, obj_type
[12]);
752 cmd
.params
[4] |= mc_enc(40, 8, obj_type
[13]);
753 cmd
.params
[4] |= mc_enc(48, 8, obj_type
[14]);
754 cmd
.params
[4] |= mc_enc(56, 8, '\0');
756 /* send command to mc*/
757 err
= mc_send_command(mc_io
, &cmd
);
761 /* retrieve response parameters */
762 region_desc
->base_paddr
= mc_dec(cmd
.params
[1], 0, 64);
763 region_desc
->size
= mc_dec(cmd
.params
[2], 0, 32);
767 EXPORT_SYMBOL(dprc_get_obj_region
);
769 int dprc_connect(struct fsl_mc_io
*mc_io
,
771 const struct dprc_endpoint
*endpoint1
,
772 const struct dprc_endpoint
*endpoint2
)
774 struct mc_command cmd
= { 0 };
776 /* prepare command */
777 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_CONNECT
,
780 cmd
.params
[0] |= mc_enc(0, 32, endpoint1
->id
);
781 cmd
.params
[0] |= mc_enc(32, 32, endpoint1
->interface_id
);
782 cmd
.params
[1] |= mc_enc(0, 32, endpoint2
->id
);
783 cmd
.params
[1] |= mc_enc(32, 32, endpoint2
->interface_id
);
784 cmd
.params
[2] |= mc_enc(0, 8, endpoint1
->type
[0]);
785 cmd
.params
[2] |= mc_enc(8, 8, endpoint1
->type
[1]);
786 cmd
.params
[2] |= mc_enc(16, 8, endpoint1
->type
[2]);
787 cmd
.params
[2] |= mc_enc(24, 8, endpoint1
->type
[3]);
788 cmd
.params
[2] |= mc_enc(32, 8, endpoint1
->type
[4]);
789 cmd
.params
[2] |= mc_enc(40, 8, endpoint1
->type
[5]);
790 cmd
.params
[2] |= mc_enc(48, 8, endpoint1
->type
[6]);
791 cmd
.params
[2] |= mc_enc(56, 8, endpoint1
->type
[7]);
792 cmd
.params
[3] |= mc_enc(0, 8, endpoint1
->type
[8]);
793 cmd
.params
[3] |= mc_enc(8, 8, endpoint1
->type
[9]);
794 cmd
.params
[3] |= mc_enc(16, 8, endpoint1
->type
[10]);
795 cmd
.params
[3] |= mc_enc(24, 8, endpoint1
->type
[11]);
796 cmd
.params
[3] |= mc_enc(32, 8, endpoint1
->type
[12]);
797 cmd
.params
[3] |= mc_enc(40, 8, endpoint1
->type
[13]);
798 cmd
.params
[3] |= mc_enc(48, 8, endpoint1
->type
[14]);
799 cmd
.params
[3] |= mc_enc(56, 8, endpoint1
->type
[15]);
800 cmd
.params
[5] |= mc_enc(0, 8, endpoint2
->type
[0]);
801 cmd
.params
[5] |= mc_enc(8, 8, endpoint2
->type
[1]);
802 cmd
.params
[5] |= mc_enc(16, 8, endpoint2
->type
[2]);
803 cmd
.params
[5] |= mc_enc(24, 8, endpoint2
->type
[3]);
804 cmd
.params
[5] |= mc_enc(32, 8, endpoint2
->type
[4]);
805 cmd
.params
[5] |= mc_enc(40, 8, endpoint2
->type
[5]);
806 cmd
.params
[5] |= mc_enc(48, 8, endpoint2
->type
[6]);
807 cmd
.params
[5] |= mc_enc(56, 8, endpoint2
->type
[7]);
808 cmd
.params
[6] |= mc_enc(0, 8, endpoint2
->type
[8]);
809 cmd
.params
[6] |= mc_enc(8, 8, endpoint2
->type
[9]);
810 cmd
.params
[6] |= mc_enc(16, 8, endpoint2
->type
[10]);
811 cmd
.params
[6] |= mc_enc(24, 8, endpoint2
->type
[11]);
812 cmd
.params
[6] |= mc_enc(32, 8, endpoint2
->type
[12]);
813 cmd
.params
[6] |= mc_enc(40, 8, endpoint2
->type
[13]);
814 cmd
.params
[6] |= mc_enc(48, 8, endpoint2
->type
[14]);
815 cmd
.params
[6] |= mc_enc(56, 8, endpoint2
->type
[15]);
817 /* send command to mc*/
818 return mc_send_command(mc_io
, &cmd
);
821 int dprc_disconnect(struct fsl_mc_io
*mc_io
,
823 const struct dprc_endpoint
*endpoint
)
825 struct mc_command cmd
= { 0 };
827 /* prepare command */
828 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_DISCONNECT
,
831 cmd
.params
[0] |= mc_enc(0, 32, endpoint
->id
);
832 cmd
.params
[0] |= mc_enc(32, 32, endpoint
->interface_id
);
833 cmd
.params
[1] |= mc_enc(0, 8, endpoint
->type
[0]);
834 cmd
.params
[1] |= mc_enc(8, 8, endpoint
->type
[1]);
835 cmd
.params
[1] |= mc_enc(16, 8, endpoint
->type
[2]);
836 cmd
.params
[1] |= mc_enc(24, 8, endpoint
->type
[3]);
837 cmd
.params
[1] |= mc_enc(32, 8, endpoint
->type
[4]);
838 cmd
.params
[1] |= mc_enc(40, 8, endpoint
->type
[5]);
839 cmd
.params
[1] |= mc_enc(48, 8, endpoint
->type
[6]);
840 cmd
.params
[1] |= mc_enc(56, 8, endpoint
->type
[7]);
841 cmd
.params
[2] |= mc_enc(0, 8, endpoint
->type
[8]);
842 cmd
.params
[2] |= mc_enc(8, 8, endpoint
->type
[9]);
843 cmd
.params
[2] |= mc_enc(16, 8, endpoint
->type
[10]);
844 cmd
.params
[2] |= mc_enc(24, 8, endpoint
->type
[11]);
845 cmd
.params
[2] |= mc_enc(32, 8, endpoint
->type
[12]);
846 cmd
.params
[2] |= mc_enc(40, 8, endpoint
->type
[13]);
847 cmd
.params
[2] |= mc_enc(48, 8, endpoint
->type
[14]);
848 cmd
.params
[2] |= mc_enc(56, 8, endpoint
->type
[15]);
850 /* send command to mc*/
851 return mc_send_command(mc_io
, &cmd
);
854 int dprc_get_connection(struct fsl_mc_io
*mc_io
,
856 const struct dprc_endpoint
*endpoint1
,
857 struct dprc_endpoint
*endpoint2
,
860 struct mc_command cmd
= { 0 };
863 /* prepare command */
864 cmd
.header
= mc_encode_cmd_header(DPRC_CMDID_GET_CONNECTION
,
867 cmd
.params
[0] |= mc_enc(0, 32, endpoint1
->id
);
868 cmd
.params
[0] |= mc_enc(32, 32, endpoint1
->interface_id
);
869 cmd
.params
[1] |= mc_enc(0, 8, endpoint1
->type
[0]);
870 cmd
.params
[1] |= mc_enc(8, 8, endpoint1
->type
[1]);
871 cmd
.params
[1] |= mc_enc(16, 8, endpoint1
->type
[2]);
872 cmd
.params
[1] |= mc_enc(24, 8, endpoint1
->type
[3]);
873 cmd
.params
[1] |= mc_enc(32, 8, endpoint1
->type
[4]);
874 cmd
.params
[1] |= mc_enc(40, 8, endpoint1
->type
[5]);
875 cmd
.params
[1] |= mc_enc(48, 8, endpoint1
->type
[6]);
876 cmd
.params
[1] |= mc_enc(56, 8, endpoint1
->type
[7]);
877 cmd
.params
[2] |= mc_enc(0, 8, endpoint1
->type
[8]);
878 cmd
.params
[2] |= mc_enc(8, 8, endpoint1
->type
[9]);
879 cmd
.params
[2] |= mc_enc(16, 8, endpoint1
->type
[10]);
880 cmd
.params
[2] |= mc_enc(24, 8, endpoint1
->type
[11]);
881 cmd
.params
[2] |= mc_enc(32, 8, endpoint1
->type
[12]);
882 cmd
.params
[2] |= mc_enc(40, 8, endpoint1
->type
[13]);
883 cmd
.params
[2] |= mc_enc(48, 8, endpoint1
->type
[14]);
884 cmd
.params
[2] |= mc_enc(56, 8, endpoint1
->type
[15]);
886 /* send command to mc*/
887 err
= mc_send_command(mc_io
, &cmd
);
891 /* retrieve response parameters */
892 endpoint2
->id
= mc_dec(cmd
.params
[3], 0, 32);
893 endpoint2
->interface_id
= mc_dec(cmd
.params
[3], 32, 32);
894 endpoint2
->type
[0] = mc_dec(cmd
.params
[4], 0, 8);
895 endpoint2
->type
[1] = mc_dec(cmd
.params
[4], 8, 8);
896 endpoint2
->type
[2] = mc_dec(cmd
.params
[4], 16, 8);
897 endpoint2
->type
[3] = mc_dec(cmd
.params
[4], 24, 8);
898 endpoint2
->type
[4] = mc_dec(cmd
.params
[4], 32, 8);
899 endpoint2
->type
[5] = mc_dec(cmd
.params
[4], 40, 8);
900 endpoint2
->type
[6] = mc_dec(cmd
.params
[4], 48, 8);
901 endpoint2
->type
[7] = mc_dec(cmd
.params
[4], 56, 8);
902 endpoint2
->type
[8] = mc_dec(cmd
.params
[5], 0, 8);
903 endpoint2
->type
[9] = mc_dec(cmd
.params
[5], 8, 8);
904 endpoint2
->type
[10] = mc_dec(cmd
.params
[5], 16, 8);
905 endpoint2
->type
[11] = mc_dec(cmd
.params
[5], 24, 8);
906 endpoint2
->type
[12] = mc_dec(cmd
.params
[5], 32, 8);
907 endpoint2
->type
[13] = mc_dec(cmd
.params
[5], 40, 8);
908 endpoint2
->type
[14] = mc_dec(cmd
.params
[5], 48, 8);
909 endpoint2
->type
[15] = mc_dec(cmd
.params
[5], 56, 8);
910 *state
= mc_dec(cmd
.params
[6], 0, 32);