dpmng.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. int mc_get_version(struct fsl_mc_io *mc_io, struct mc_version *mc_ver_info)
  10. {
  11. struct mc_command cmd = { 0 };
  12. int err;
  13. /* prepare command */
  14. cmd.header = mc_encode_cmd_header(DPMNG_CMDID_GET_VERSION,
  15. MC_CMD_PRI_LOW, 0);
  16. /* send command to mc*/
  17. err = mc_send_command(mc_io, &cmd);
  18. if (err)
  19. return err;
  20. /* retrieve response parameters */
  21. DPMNG_RSP_GET_VERSION(cmd, mc_ver_info);
  22. return 0;
  23. }
  24. int dpmng_reset_aiop(struct fsl_mc_io *mc_io, int container_id,
  25. int aiop_tile_id)
  26. {
  27. struct mc_command cmd = { 0 };
  28. /* prepare command */
  29. cmd.header = mc_encode_cmd_header(DPMNG_CMDID_RESET_AIOP,
  30. MC_CMD_PRI_LOW, 0);
  31. DPMNG_CMD_RESET_AIOP(cmd, container_id, aiop_tile_id);
  32. /* send command to mc*/
  33. return mc_send_command(mc_io, &cmd);
  34. }
  35. int dpmng_load_aiop(struct fsl_mc_io *mc_io,
  36. int container_id,
  37. int aiop_tile_id,
  38. uint64_t img_iova,
  39. uint32_t img_size)
  40. {
  41. struct mc_command cmd = { 0 };
  42. /* prepare command */
  43. cmd.header = mc_encode_cmd_header(DPMNG_CMDID_LOAD_AIOP,
  44. MC_CMD_PRI_LOW,
  45. 0);
  46. DPMNG_CMD_LOAD_AIOP(cmd, container_id, aiop_tile_id, img_size,
  47. img_iova);
  48. /* send command to mc*/
  49. return mc_send_command(mc_io, &cmd);
  50. }
  51. int dpmng_run_aiop(struct fsl_mc_io *mc_io,
  52. int container_id,
  53. int aiop_tile_id,
  54. const struct dpmng_aiop_run_cfg *cfg)
  55. {
  56. struct mc_command cmd = { 0 };
  57. /* prepare command */
  58. cmd.header = mc_encode_cmd_header(DPMNG_CMDID_RUN_AIOP,
  59. MC_CMD_PRI_LOW,
  60. 0);
  61. DPMNG_CMD_RUN_AIOP(cmd, container_id, aiop_tile_id, cfg);
  62. /* send command to mc*/
  63. return mc_send_command(mc_io, &cmd);
  64. }
  65. int dpmng_reset_mc_portal(struct fsl_mc_io *mc_io)
  66. {
  67. struct mc_command cmd = { 0 };
  68. /* prepare command */
  69. cmd.header = mc_encode_cmd_header(DPMNG_CMDID_RESET_MC_PORTAL,
  70. MC_CMD_PRI_LOW,
  71. 0);
  72. /* send command to mc*/
  73. return mc_send_command(mc_io, &cmd);
  74. }