fsl_dpio.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Copyright (C) 2013-2015 Freescale Semiconductor
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef _FSL_DPIO_H
  7. #define _FSL_DPIO_H
  8. /* DPIO Version */
  9. #define DPIO_VER_MAJOR 2
  10. #define DPIO_VER_MINOR 1
  11. /* Command IDs */
  12. #define DPIO_CMDID_CLOSE 0x800
  13. #define DPIO_CMDID_OPEN 0x803
  14. #define DPIO_CMDID_ENABLE 0x002
  15. #define DPIO_CMDID_DISABLE 0x003
  16. #define DPIO_CMDID_GET_ATTR 0x004
  17. #define DPIO_CMDID_RESET 0x005
  18. /* cmd, param, offset, width, type, arg_name */
  19. #define DPIO_CMD_OPEN(cmd, dpio_id) \
  20. MC_CMD_OP(cmd, 0, 0, 32, int, dpio_id)
  21. /* cmd, param, offset, width, type, arg_name */
  22. #define DPIO_RSP_GET_ATTR(cmd, attr) \
  23. do { \
  24. MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\
  25. MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->qbman_portal_id);\
  26. MC_RSP_OP(cmd, 0, 48, 8, uint8_t, attr->num_priorities);\
  27. MC_RSP_OP(cmd, 0, 56, 4, enum dpio_channel_mode, attr->channel_mode);\
  28. MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->qbman_portal_ce_paddr);\
  29. MC_RSP_OP(cmd, 2, 0, 64, uint64_t, attr->qbman_portal_ci_paddr);\
  30. MC_RSP_OP(cmd, 3, 0, 16, uint16_t, attr->version.major);\
  31. MC_RSP_OP(cmd, 3, 16, 16, uint16_t, attr->version.minor);\
  32. } while (0)
  33. /* Data Path I/O Portal API
  34. * Contains initialization APIs and runtime control APIs for DPIO
  35. */
  36. struct fsl_mc_io;
  37. /**
  38. * dpio_open() - Open a control session for the specified object
  39. * @mc_io: Pointer to MC portal's I/O object
  40. * @dpio_id: DPIO unique ID
  41. * @token: Returned token; use in subsequent API calls
  42. *
  43. * This function can be used to open a control session for an
  44. * already created object; an object may have been declared in
  45. * the DPL or by calling the dpio_create() function.
  46. * This function returns a unique authentication token,
  47. * associated with the specific object ID and the specific MC
  48. * portal; this token must be used in all subsequent commands for
  49. * this specific object.
  50. *
  51. * Return: '0' on Success; Error code otherwise.
  52. */
  53. int dpio_open(struct fsl_mc_io *mc_io, int dpio_id, uint16_t *token);
  54. /**
  55. * dpio_open() - Open a control session for the specified object
  56. * @mc_io: Pointer to MC portal's I/O object
  57. * @dpio_id: DPIO unique ID
  58. * @token: Returned token; use in subsequent API calls
  59. *
  60. * This function can be used to open a control session for an
  61. * already created object; an object may have been declared in
  62. * the DPL or by calling the dpio_create() function.
  63. * This function returns a unique authentication token,
  64. * associated with the specific object ID and the specific MC
  65. * portal; this token must be used in all subsequent commands for
  66. * this specific object.
  67. *
  68. * Return: '0' on Success; Error code otherwise.
  69. */
  70. int dpio_close(struct fsl_mc_io *mc_io, uint16_t token);
  71. /**
  72. * enum dpio_channel_mode - DPIO notification channel mode
  73. * @DPIO_NO_CHANNEL: No support for notification channel
  74. * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a
  75. * dedicated channel in the DPIO; user should point the queue's
  76. * destination in the relevant interface to this DPIO
  77. */
  78. enum dpio_channel_mode {
  79. DPIO_NO_CHANNEL = 0,
  80. DPIO_LOCAL_CHANNEL = 1,
  81. };
  82. /**
  83. * dpio_enable() - Enable the DPIO, allow I/O portal operations.
  84. * @mc_io: Pointer to MC portal's I/O object
  85. * @token: Token of DPIO object
  86. *
  87. * Return: '0' on Success; Error code otherwise
  88. */
  89. int dpio_enable(struct fsl_mc_io *mc_io, uint16_t token);
  90. /**
  91. * dpio_disable() - Disable the DPIO, stop any I/O portal operation.
  92. * @mc_io: Pointer to MC portal's I/O object
  93. * @token: Token of DPIO object
  94. *
  95. * Return: '0' on Success; Error code otherwise
  96. */
  97. int dpio_disable(struct fsl_mc_io *mc_io, uint16_t token);
  98. /**
  99. * dpio_reset() - Reset the DPIO, returns the object to initial state.
  100. * @mc_io: Pointer to MC portal's I/O object
  101. * @token: Token of DPIO object
  102. *
  103. * Return: '0' on Success; Error code otherwise.
  104. */
  105. int dpio_reset(struct fsl_mc_io *mc_io, uint16_t token);
  106. /**
  107. * struct dpio_attr - Structure representing DPIO attributes
  108. * @id: DPIO object ID
  109. * @version: DPIO version
  110. * @qbman_portal_ce_paddr: Physical address of the software portal
  111. * cache-enabled area
  112. * @qbman_portal_ci_paddr: Physical address of the software portal
  113. * cache-inhibited area
  114. * @qbman_portal_id: Software portal ID
  115. * @channel_mode: Notification channel mode
  116. * @num_priorities: Number of priorities for the notification channel (1-8);
  117. * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
  118. */
  119. struct dpio_attr {
  120. int id;
  121. /**
  122. * struct version - DPIO version
  123. * @major: DPIO major version
  124. * @minor: DPIO minor version
  125. */
  126. struct {
  127. uint16_t major;
  128. uint16_t minor;
  129. } version;
  130. uint64_t qbman_portal_ce_paddr;
  131. uint64_t qbman_portal_ci_paddr;
  132. uint16_t qbman_portal_id;
  133. enum dpio_channel_mode channel_mode;
  134. uint8_t num_priorities;
  135. };
  136. /**
  137. * dpio_get_attributes() - Retrieve DPIO attributes
  138. * @mc_io: Pointer to MC portal's I/O object
  139. * @token: Token of DPIO object
  140. * @attr: Returned object's attributes
  141. *
  142. * Return: '0' on Success; Error code otherwise
  143. */
  144. int dpio_get_attributes(struct fsl_mc_io *mc_io,
  145. uint16_t token,
  146. struct dpio_attr *attr);
  147. #endif /* _FSL_DPIO_H */