1 /* Copyright 2014 Freescale Semiconductor Inc. 2 * 3 * SPDX-License-Identifier: GPL-2.0+ 4 */ 5 #include <fsl-mc/fsl_mc_sys.h> 6 #include <fsl-mc/fsl_mc_cmd.h> 7 #include <fsl-mc/fsl_dpmng.h> 8 #include "fsl_dpmng_cmd.h" 9 10 int mc_get_version(struct fsl_mc_io *mc_io, struct mc_version *mc_ver_info) 11 { 12 struct mc_command cmd = { 0 }; 13 int err; 14 15 /* prepare command */ 16 cmd.header = mc_encode_cmd_header(DPMNG_CMDID_GET_VERSION, 17 MC_CMD_PRI_LOW, 0); 18 19 /* send command to mc*/ 20 err = mc_send_command(mc_io, &cmd); 21 if (err) 22 return err; 23 24 /* retrieve response parameters */ 25 DPMNG_RSP_GET_VERSION(cmd, mc_ver_info); 26 27 return 0; 28 } 29 30 int dpmng_reset_aiop(struct fsl_mc_io *mc_io, int container_id, 31 int aiop_tile_id) 32 { 33 struct mc_command cmd = { 0 }; 34 35 /* prepare command */ 36 cmd.header = mc_encode_cmd_header(DPMNG_CMDID_RESET_AIOP, 37 MC_CMD_PRI_LOW, 0); 38 DPMNG_CMD_RESET_AIOP(cmd, container_id, aiop_tile_id); 39 40 /* send command to mc*/ 41 return mc_send_command(mc_io, &cmd); 42 } 43 44 int dpmng_load_aiop(struct fsl_mc_io *mc_io, 45 int container_id, 46 int aiop_tile_id, 47 uint64_t img_iova, 48 uint32_t img_size) 49 { 50 struct mc_command cmd = { 0 }; 51 52 /* prepare command */ 53 cmd.header = mc_encode_cmd_header(DPMNG_CMDID_LOAD_AIOP, 54 MC_CMD_PRI_LOW, 55 0); 56 DPMNG_CMD_LOAD_AIOP(cmd, container_id, aiop_tile_id, img_size, 57 img_iova); 58 59 /* send command to mc*/ 60 return mc_send_command(mc_io, &cmd); 61 } 62 63 int dpmng_run_aiop(struct fsl_mc_io *mc_io, 64 int container_id, 65 int aiop_tile_id, 66 const struct dpmng_aiop_run_cfg *cfg) 67 { 68 struct mc_command cmd = { 0 }; 69 70 /* prepare command */ 71 cmd.header = mc_encode_cmd_header(DPMNG_CMDID_RUN_AIOP, 72 MC_CMD_PRI_LOW, 73 0); 74 DPMNG_CMD_RUN_AIOP(cmd, container_id, aiop_tile_id, cfg); 75 76 /* send command to mc*/ 77 return mc_send_command(mc_io, &cmd); 78 } 79 80 int dpmng_reset_mc_portal(struct fsl_mc_io *mc_io) 81 { 82 struct mc_command cmd = { 0 }; 83 84 /* prepare command */ 85 cmd.header = mc_encode_cmd_header(DPMNG_CMDID_RESET_MC_PORTAL, 86 MC_CMD_PRI_LOW, 87 0); 88 89 /* send command to mc*/ 90 return mc_send_command(mc_io, &cmd); 91 } 92