scmi-msg.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /* SPDX-License-Identifier: BSD-3-Clause */
  2. /*
  3. * Copyright (c) 2015-2019, Arm Limited and Contributors. All rights reserved.
  4. * Copyright (c) 2019, Linaro Limited
  5. */
  6. #ifndef SCMI_MSG_H
  7. #define SCMI_MSG_H
  8. #include <stdbool.h>
  9. #include <stddef.h>
  10. #include <stdint.h>
  11. /* Minimum size expected for SMT based shared memory message buffers */
  12. #define SMT_BUF_SLOT_SIZE 128U
  13. /* A channel abstract a communication path between agent and server */
  14. struct scmi_msg_channel;
  15. /*
  16. * struct scmi_msg_channel - Shared memory buffer for a agent-to-server channel
  17. *
  18. * @shm_addr: Address of the shared memory for the SCMI channel
  19. * @shm_size: Byte size of the shared memory for the SCMI channel
  20. * @busy: True when channel is busy, flase when channel is free
  21. * @agent_name: Agent name, SCMI protocol exposes 16 bytes max, or NULL
  22. */
  23. struct scmi_msg_channel {
  24. uintptr_t shm_addr;
  25. size_t shm_size;
  26. bool busy;
  27. const char *agent_name;
  28. };
  29. /*
  30. * Initialize SMT memory buffer, called by platform at init for each
  31. * agent channel using the SMT header format.
  32. *
  33. * @chan: Pointer to the channel shared memory to be initialized
  34. */
  35. void scmi_smt_init_agent_channel(struct scmi_msg_channel *chan);
  36. /*
  37. * Process SMT formatted message in a fastcall SMC execution context.
  38. * Called by platform on SMC entry. When returning, output message is
  39. * available in shared memory for agent to read the response.
  40. *
  41. * @agent_id: SCMI agent ID the SMT belongs to
  42. */
  43. void scmi_smt_fastcall_smc_entry(unsigned int agent_id);
  44. /*
  45. * Process SMT formatted message in a secure interrupt execution context.
  46. * Called by platform interrupt handler. When returning, output message is
  47. * available in shared memory for agent to read the response.
  48. *
  49. * @agent_id: SCMI agent ID the SMT belongs to
  50. */
  51. void scmi_smt_interrupt_entry(unsigned int agent_id);
  52. /* Platform callback functions */
  53. /*
  54. * Return the SCMI channel related to an agent
  55. * @agent_id: SCMI agent ID
  56. * Return a pointer to channel on success, NULL otherwise
  57. */
  58. struct scmi_msg_channel *plat_scmi_get_channel(unsigned int agent_id);
  59. /*
  60. * Return how many SCMI protocols supported by the platform
  61. * According to the SCMI specification, this function does not target
  62. * a specific agent ID and shall return all platform known capabilities.
  63. */
  64. size_t plat_scmi_protocol_count(void);
  65. /*
  66. * Get the count and list of SCMI protocols (but base) supported for an agent
  67. *
  68. * @agent_id: SCMI agent ID
  69. * Return a pointer to a null terminated array supported protocol IDs.
  70. */
  71. const uint8_t *plat_scmi_protocol_list(unsigned int agent_id);
  72. /* Get the name of the SCMI vendor for the platform */
  73. const char *plat_scmi_vendor_name(void);
  74. /* Get the name of the SCMI sub-vendor for the platform */
  75. const char *plat_scmi_sub_vendor_name(void);
  76. /* Handlers for SCMI Clock protocol services */
  77. /*
  78. * Return number of clock controllers for an agent
  79. * @agent_id: SCMI agent ID
  80. * Return number of clock controllers
  81. */
  82. size_t plat_scmi_clock_count(unsigned int agent_id);
  83. /*
  84. * Get clock controller string ID (aka name)
  85. * @agent_id: SCMI agent ID
  86. * @scmi_id: SCMI clock ID
  87. * Return pointer to name or NULL
  88. */
  89. const char *plat_scmi_clock_get_name(unsigned int agent_id,
  90. unsigned int scmi_id);
  91. /*
  92. * Get clock possible rate as an array of frequencies in Hertz.
  93. *
  94. * @agent_id: SCMI agent ID
  95. * @scmi_id: SCMI clock ID
  96. * @rates: If NULL, function returns, else output rates array
  97. * @nb_elts: Array size of @rates.
  98. * Return an SCMI compliant error code
  99. */
  100. int32_t plat_scmi_clock_rates_array(unsigned int agent_id, unsigned int scmi_id,
  101. unsigned long *rates, size_t *nb_elts);
  102. /*
  103. * Get clock possible rate as range with regular steps in Hertz
  104. *
  105. * @agent_id: SCMI agent ID
  106. * @scmi_id: SCMI clock ID
  107. * @min_max_step: 3 cell array for min, max and step rate data
  108. * Return an SCMI compliant error code
  109. */
  110. int32_t plat_scmi_clock_rates_by_step(unsigned int agent_id,
  111. unsigned int scmi_id,
  112. unsigned long *min_max_step);
  113. /*
  114. * Get clock rate in Hertz
  115. * @agent_id: SCMI agent ID
  116. * @scmi_id: SCMI clock ID
  117. * Return clock rate or 0 if not supported
  118. */
  119. unsigned long plat_scmi_clock_get_rate(unsigned int agent_id,
  120. unsigned int scmi_id);
  121. /*
  122. * Set clock rate in Hertz
  123. * @agent_id: SCMI agent ID
  124. * @scmi_id: SCMI clock ID
  125. * @rate: Target clock frequency in Hertz
  126. * Return a compliant SCMI error code
  127. */
  128. int32_t plat_scmi_clock_set_rate(unsigned int agent_id, unsigned int scmi_id,
  129. unsigned long rate);
  130. /*
  131. * Get clock state (enabled or disabled)
  132. * @agent_id: SCMI agent ID
  133. * @scmi_id: SCMI clock ID
  134. * Return 1 if clock is enabled, 0 if disables, or a negative SCMI error code
  135. */
  136. int32_t plat_scmi_clock_get_state(unsigned int agent_id, unsigned int scmi_id);
  137. /*
  138. * Get clock state (enabled or disabled)
  139. * @agent_id: SCMI agent ID
  140. * @scmi_id: SCMI clock ID
  141. * @enable_not_disable: Enable clock if true, disable clock otherwise
  142. * Return a compliant SCMI error code
  143. */
  144. int32_t plat_scmi_clock_set_state(unsigned int agent_id, unsigned int scmi_id,
  145. bool enable_not_disable);
  146. /* Handlers for SCMI Reset Domain protocol services */
  147. /*
  148. * Return number of reset domains for the agent
  149. * @agent_id: SCMI agent ID
  150. * Return number of reset domains
  151. */
  152. size_t plat_scmi_rstd_count(unsigned int agent_id);
  153. /*
  154. * Get reset domain string ID (aka name)
  155. * @agent_id: SCMI agent ID
  156. * @scmi_id: SCMI reset domain ID
  157. * Return pointer to name or NULL
  158. */
  159. const char *plat_scmi_rstd_get_name(unsigned int agent_id, unsigned int scmi_id);
  160. /*
  161. * Perform a reset cycle on a target reset domain
  162. * @agent_id: SCMI agent ID
  163. * @scmi_id: SCMI reset domain ID
  164. * @state: Target reset state (see SCMI specification, 0 means context loss)
  165. * Return a compliant SCMI error code
  166. */
  167. int32_t plat_scmi_rstd_autonomous(unsigned int agent_id, unsigned int scmi_id,
  168. unsigned int state);
  169. /*
  170. * Assert or deassert target reset domain
  171. * @agent_id: SCMI agent ID
  172. * @scmi_id: SCMI reset domain ID
  173. * @assert_not_deassert: Assert domain if true, otherwise deassert domain
  174. * Return a compliant SCMI error code
  175. */
  176. int32_t plat_scmi_rstd_set_state(unsigned int agent_id, unsigned int scmi_id,
  177. bool assert_not_deassert);
  178. #endif /* SCMI_MSG_H */