fsl_dpio.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright 2013-2016 Freescale Semiconductor, Inc.
  4. * Copyright 2017 NXP
  5. */
  6. #ifndef _FSL_DPIO_H
  7. #define _FSL_DPIO_H
  8. /* DPIO Version */
  9. #define DPIO_VER_MAJOR 4
  10. #define DPIO_VER_MINOR 2
  11. /* Command IDs */
  12. #define DPIO_CMDID_CLOSE 0x8001
  13. #define DPIO_CMDID_OPEN 0x8031
  14. #define DPIO_CMDID_CREATE 0x9031
  15. #define DPIO_CMDID_DESTROY 0x9831
  16. #define DPIO_CMDID_GET_API_VERSION 0xa031
  17. #define DPIO_CMDID_ENABLE 0x0021
  18. #define DPIO_CMDID_DISABLE 0x0031
  19. #define DPIO_CMDID_GET_ATTR 0x0041
  20. #define DPIO_CMDID_RESET 0x0051
  21. /* cmd, param, offset, width, type, arg_name */
  22. #define DPIO_CMD_OPEN(cmd, dpio_id) \
  23. MC_CMD_OP(cmd, 0, 0, 32, int, dpio_id)
  24. /* cmd, param, offset, width, type, arg_name */
  25. #define DPIO_CMD_CREATE(cmd, cfg) \
  26. do { \
  27. MC_CMD_OP(cmd, 0, 16, 2, enum dpio_channel_mode, \
  28. cfg->channel_mode);\
  29. MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->num_priorities);\
  30. } while (0)
  31. /* cmd, param, offset, width, type, arg_name */
  32. #define DPIO_RSP_GET_ATTR(cmd, attr) \
  33. do { \
  34. MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\
  35. MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->qbman_portal_id);\
  36. MC_RSP_OP(cmd, 0, 48, 8, uint8_t, attr->num_priorities);\
  37. MC_RSP_OP(cmd, 0, 56, 4, enum dpio_channel_mode, attr->channel_mode);\
  38. MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->qbman_portal_ce_offset);\
  39. MC_RSP_OP(cmd, 2, 0, 64, uint64_t, attr->qbman_portal_ci_offset);\
  40. MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->qbman_version);\
  41. } while (0)
  42. /* Data Path I/O Portal API
  43. * Contains initialization APIs and runtime control APIs for DPIO
  44. */
  45. struct fsl_mc_io;
  46. /**
  47. * dpio_open() - Open a control session for the specified object
  48. * @mc_io: Pointer to MC portal's I/O object
  49. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  50. * @dpio_id: DPIO unique ID
  51. * @token: Returned token; use in subsequent API calls
  52. *
  53. * This function can be used to open a control session for an
  54. * already created object; an object may have been declared in
  55. * the DPL or by calling the dpio_create() function.
  56. * This function returns a unique authentication token,
  57. * associated with the specific object ID and the specific MC
  58. * portal; this token must be used in all subsequent commands for
  59. * this specific object.
  60. *
  61. * Return: '0' on Success; Error code otherwise.
  62. */
  63. int dpio_open(struct fsl_mc_io *mc_io,
  64. uint32_t cmd_flags,
  65. uint32_t dpio_id,
  66. uint16_t *token);
  67. /**
  68. * dpio_close() - Close the control session of the object
  69. * @mc_io: Pointer to MC portal's I/O object
  70. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  71. * @token: Token of DPIO object
  72. *
  73. * Return: '0' on Success; Error code otherwise.
  74. */
  75. int dpio_close(struct fsl_mc_io *mc_io,
  76. uint32_t cmd_flags,
  77. uint16_t token);
  78. /**
  79. * enum dpio_channel_mode - DPIO notification channel mode
  80. * @DPIO_NO_CHANNEL: No support for notification channel
  81. * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a
  82. * dedicated channel in the DPIO; user should point the queue's
  83. * destination in the relevant interface to this DPIO
  84. */
  85. enum dpio_channel_mode {
  86. DPIO_NO_CHANNEL = 0,
  87. DPIO_LOCAL_CHANNEL = 1,
  88. };
  89. /**
  90. * struct dpio_cfg - Structure representing DPIO configuration
  91. * @channel_mode: Notification channel mode
  92. * @num_priorities: Number of priorities for the notification channel (1-8);
  93. * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
  94. */
  95. struct dpio_cfg {
  96. enum dpio_channel_mode channel_mode;
  97. uint8_t num_priorities;
  98. };
  99. /**
  100. * dpio_create() - Create the DPIO object.
  101. * @mc_io: Pointer to MC portal's I/O object
  102. * @token: Authentication token.
  103. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  104. * @cfg: Configuration structure
  105. * @obj_id: Returned obj_id; use in subsequent API calls
  106. *
  107. * Create the DPIO object, allocate required resources and
  108. * perform required initialization.
  109. *
  110. * The object can be created either by declaring it in the
  111. * DPL file, or by calling this function.
  112. *
  113. * This function returns a unique authentication token,
  114. * associated with the specific object ID and the specific MC
  115. * portal; this token must be used in all subsequent calls to
  116. * this specific object. For objects that are created using the
  117. * DPL file, call dpio_open() function to get an authentication
  118. * token first.
  119. *
  120. * Return: '0' on Success; Error code otherwise.
  121. */
  122. int dpio_create(struct fsl_mc_io *mc_io,
  123. uint16_t token,
  124. uint32_t cmd_flags,
  125. const struct dpio_cfg *cfg,
  126. uint32_t *obj_id);
  127. /**
  128. * dpio_destroy() - Destroy the DPIO object and release all its resources.
  129. * @mc_io: Pointer to MC portal's I/O object
  130. * @token: Authentication token.
  131. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  132. * @obj_id: Object ID of DPIO
  133. *
  134. * Return: '0' on Success; Error code otherwise
  135. */
  136. int dpio_destroy(struct fsl_mc_io *mc_io,
  137. uint16_t token,
  138. uint32_t cmd_flags,
  139. uint32_t obj_id);
  140. /**
  141. * dpio_enable() - Enable the DPIO, allow I/O portal operations.
  142. * @mc_io: Pointer to MC portal's I/O object
  143. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  144. * @token: Token of DPIO object
  145. *
  146. * Return: '0' on Success; Error code otherwise
  147. */
  148. int dpio_enable(struct fsl_mc_io *mc_io,
  149. uint32_t cmd_flags,
  150. uint16_t token);
  151. /**
  152. * dpio_disable() - Disable the DPIO, stop any I/O portal operation.
  153. * @mc_io: Pointer to MC portal's I/O object
  154. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  155. * @token: Token of DPIO object
  156. *
  157. * Return: '0' on Success; Error code otherwise
  158. */
  159. int dpio_disable(struct fsl_mc_io *mc_io,
  160. uint32_t cmd_flags,
  161. uint16_t token);
  162. /**
  163. * dpio_reset() - Reset the DPIO, returns the object to initial state.
  164. * @mc_io: Pointer to MC portal's I/O object
  165. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  166. * @token: Token of DPIO object
  167. *
  168. * Return: '0' on Success; Error code otherwise.
  169. */
  170. int dpio_reset(struct fsl_mc_io *mc_io,
  171. uint32_t cmd_flags,
  172. uint16_t token);
  173. /**
  174. * struct dpio_attr - Structure representing DPIO attributes
  175. * @id: DPIO object ID
  176. * @version: DPIO version
  177. * @qbman_portal_ce_offset: offset of the software portal cache-enabled area
  178. * @qbman_portal_ci_offset: offset of the software portal cache-inhibited area
  179. * @qbman_portal_id: Software portal ID
  180. * @channel_mode: Notification channel mode
  181. * @num_priorities: Number of priorities for the notification channel (1-8);
  182. * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
  183. * @qbman_version: QBMAN version
  184. */
  185. struct dpio_attr {
  186. uint32_t id;
  187. uint64_t qbman_portal_ce_offset;
  188. uint64_t qbman_portal_ci_offset;
  189. uint16_t qbman_portal_id;
  190. enum dpio_channel_mode channel_mode;
  191. uint8_t num_priorities;
  192. uint32_t qbman_version;
  193. };
  194. /**
  195. * dpio_get_attributes() - Retrieve DPIO attributes
  196. * @mc_io: Pointer to MC portal's I/O object
  197. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  198. * @token: Token of DPIO object
  199. * @attr: Returned object's attributes
  200. *
  201. * Return: '0' on Success; Error code otherwise
  202. */
  203. int dpio_get_attributes(struct fsl_mc_io *mc_io,
  204. uint32_t cmd_flags,
  205. uint16_t token,
  206. struct dpio_attr *attr);
  207. /**
  208. * dpio_get_api_version - Retrieve DPIO Major and Minor version info.
  209. *
  210. * @mc_io: Pointer to MC portal's I/O object
  211. * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  212. * @major_ver: DPIO major version
  213. * @minor_ver: DPIO minor version
  214. *
  215. * Return: '0' on Success; Error code otherwise.
  216. */
  217. int dpio_get_api_version(struct fsl_mc_io *mc_io,
  218. u32 cmd_flags,
  219. u16 *major_ver,
  220. u16 *minor_ver);
  221. #endif /* _FSL_DPIO_H */