dpbp.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * Freescale Layerscape MC I/O wrapper
  3. *
  4. * Copyright (C) 2013-2015 Freescale Semiconductor, Inc.
  5. * Author: German Rivera <German.Rivera@freescale.com>
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #include <fsl-mc/fsl_mc_sys.h>
  10. #include <fsl-mc/fsl_mc_cmd.h>
  11. #include <fsl-mc/fsl_dpbp.h>
  12. int dpbp_open(struct fsl_mc_io *mc_io,
  13. uint32_t cmd_flags,
  14. int dpbp_id,
  15. uint16_t *token)
  16. {
  17. struct mc_command cmd = { 0 };
  18. int err;
  19. /* prepare command */
  20. cmd.header = mc_encode_cmd_header(DPBP_CMDID_OPEN,
  21. cmd_flags,
  22. 0);
  23. DPBP_CMD_OPEN(cmd, dpbp_id);
  24. /* send command to mc*/
  25. err = mc_send_command(mc_io, &cmd);
  26. if (err)
  27. return err;
  28. /* retrieve response parameters */
  29. *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
  30. return err;
  31. }
  32. int dpbp_close(struct fsl_mc_io *mc_io,
  33. uint32_t cmd_flags,
  34. uint16_t token)
  35. {
  36. struct mc_command cmd = { 0 };
  37. /* prepare command */
  38. cmd.header = mc_encode_cmd_header(DPBP_CMDID_CLOSE, cmd_flags,
  39. token);
  40. /* send command to mc*/
  41. return mc_send_command(mc_io, &cmd);
  42. }
  43. int dpbp_create(struct fsl_mc_io *mc_io,
  44. uint32_t cmd_flags,
  45. const struct dpbp_cfg *cfg,
  46. uint16_t *token)
  47. {
  48. struct mc_command cmd = { 0 };
  49. int err;
  50. (void)(cfg); /* unused */
  51. /* prepare command */
  52. cmd.header = mc_encode_cmd_header(DPBP_CMDID_CREATE,
  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. *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
  61. return 0;
  62. }
  63. int dpbp_destroy(struct fsl_mc_io *mc_io,
  64. uint32_t cmd_flags,
  65. uint16_t token)
  66. {
  67. struct mc_command cmd = { 0 };
  68. /* prepare command */
  69. cmd.header = mc_encode_cmd_header(DPBP_CMDID_DESTROY,
  70. cmd_flags,
  71. token);
  72. /* send command to mc*/
  73. return mc_send_command(mc_io, &cmd);
  74. }
  75. int dpbp_enable(struct fsl_mc_io *mc_io,
  76. uint32_t cmd_flags,
  77. uint16_t token)
  78. {
  79. struct mc_command cmd = { 0 };
  80. /* prepare command */
  81. cmd.header = mc_encode_cmd_header(DPBP_CMDID_ENABLE, cmd_flags,
  82. token);
  83. /* send command to mc*/
  84. return mc_send_command(mc_io, &cmd);
  85. }
  86. int dpbp_disable(struct fsl_mc_io *mc_io,
  87. uint32_t cmd_flags,
  88. uint16_t token)
  89. {
  90. struct mc_command cmd = { 0 };
  91. /* prepare command */
  92. cmd.header = mc_encode_cmd_header(DPBP_CMDID_DISABLE,
  93. cmd_flags,
  94. token);
  95. /* send command to mc*/
  96. return mc_send_command(mc_io, &cmd);
  97. }
  98. int dpbp_reset(struct fsl_mc_io *mc_io,
  99. uint32_t cmd_flags,
  100. uint16_t token)
  101. {
  102. struct mc_command cmd = { 0 };
  103. /* prepare command */
  104. cmd.header = mc_encode_cmd_header(DPBP_CMDID_RESET,
  105. cmd_flags,
  106. token);
  107. /* send command to mc*/
  108. return mc_send_command(mc_io, &cmd);
  109. }
  110. int dpbp_get_attributes(struct fsl_mc_io *mc_io,
  111. uint32_t cmd_flags,
  112. uint16_t token,
  113. struct dpbp_attr *attr)
  114. {
  115. struct mc_command cmd = { 0 };
  116. int err;
  117. /* prepare command */
  118. cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_ATTR,
  119. cmd_flags,
  120. token);
  121. /* send command to mc*/
  122. err = mc_send_command(mc_io, &cmd);
  123. if (err)
  124. return err;
  125. /* retrieve response parameters */
  126. DPBP_RSP_GET_ATTRIBUTES(cmd, attr);
  127. return 0;
  128. }