dpmng.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* Copyright 2013-2014 Freescale Semiconductor Inc.
  2. *
  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.
  13. *
  14. *
  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
  18. * later version.
  19. *
  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.
  31. */
  32. #include "../include/mc-sys.h"
  33. #include "../include/mc-cmd.h"
  34. #include "../include/dpmng.h"
  35. #include "dpmng-cmd.h"
  36. /**
  37. * mc_get_version() - Retrieves the Management Complex firmware
  38. * version information
  39. * @mc_io: Pointer to opaque I/O object
  40. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  41. * @mc_ver_info: Returned version information structure
  42. *
  43. * Return: '0' on Success; Error code otherwise.
  44. */
  45. int mc_get_version(struct fsl_mc_io *mc_io,
  46. u32 cmd_flags,
  47. struct mc_version *mc_ver_info)
  48. {
  49. struct mc_command cmd = { 0 };
  50. int err;
  51. /* prepare command */
  52. cmd.header = mc_encode_cmd_header(DPMNG_CMDID_GET_VERSION,
  53. cmd_flags,
  54. 0);
  55. /* send command to mc*/
  56. err = mc_send_command(mc_io, &cmd);
  57. if (err)
  58. return err;
  59. /* retrieve response parameters */
  60. mc_ver_info->revision = mc_dec(cmd.params[0], 0, 32);
  61. mc_ver_info->major = mc_dec(cmd.params[0], 32, 32);
  62. mc_ver_info->minor = mc_dec(cmd.params[1], 0, 32);
  63. return 0;
  64. }
  65. /**
  66. * dpmng_get_container_id() - Get container ID associated with a given portal.
  67. * @mc_io: Pointer to MC portal's I/O object
  68. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  69. * @container_id: Requested container ID
  70. *
  71. * Return: '0' on Success; Error code otherwise.
  72. */
  73. int dpmng_get_container_id(struct fsl_mc_io *mc_io,
  74. u32 cmd_flags,
  75. int *container_id)
  76. {
  77. struct mc_command cmd = { 0 };
  78. int err;
  79. /* prepare command */
  80. cmd.header = mc_encode_cmd_header(DPMNG_CMDID_GET_CONT_ID,
  81. cmd_flags,
  82. 0);
  83. /* send command to mc*/
  84. err = mc_send_command(mc_io, &cmd);
  85. if (err)
  86. return err;
  87. /* retrieve response parameters */
  88. *container_id = mc_dec(cmd.params[0], 0, 32);
  89. return 0;
  90. }