scmi-msg.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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, false 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. * @start_idx: Start index of rates array
  99. * Return an SCMI compliant error code
  100. */
  101. int32_t plat_scmi_clock_rates_array(unsigned int agent_id, unsigned int scmi_id,
  102. unsigned long *rates, size_t *nb_elts,
  103. uint32_t start_idx);
  104. /*
  105. * Get clock possible rate as range with regular steps in Hertz
  106. *
  107. * @agent_id: SCMI agent ID
  108. * @scmi_id: SCMI clock ID
  109. * @min_max_step: 3 cell array for min, max and step rate data
  110. * Return an SCMI compliant error code
  111. */
  112. int32_t plat_scmi_clock_rates_by_step(unsigned int agent_id,
  113. unsigned int scmi_id,
  114. unsigned long *min_max_step);
  115. /*
  116. * Get clock rate in Hertz
  117. * @agent_id: SCMI agent ID
  118. * @scmi_id: SCMI clock ID
  119. * Return clock rate or 0 if not supported
  120. */
  121. unsigned long plat_scmi_clock_get_rate(unsigned int agent_id,
  122. unsigned int scmi_id);
  123. /*
  124. * Set clock rate in Hertz
  125. * @agent_id: SCMI agent ID
  126. * @scmi_id: SCMI clock ID
  127. * @rate: Target clock frequency in Hertz
  128. * Return a compliant SCMI error code
  129. */
  130. int32_t plat_scmi_clock_set_rate(unsigned int agent_id, unsigned int scmi_id,
  131. unsigned long rate);
  132. /*
  133. * Get clock state (enabled or disabled)
  134. * @agent_id: SCMI agent ID
  135. * @scmi_id: SCMI clock ID
  136. * Return 1 if clock is enabled, 0 if disables, or a negative SCMI error code
  137. */
  138. int32_t plat_scmi_clock_get_state(unsigned int agent_id, unsigned int scmi_id);
  139. /*
  140. * Get clock state (enabled or disabled)
  141. * @agent_id: SCMI agent ID
  142. * @scmi_id: SCMI clock ID
  143. * @enable_not_disable: Enable clock if true, disable clock otherwise
  144. * Return a compliant SCMI error code
  145. */
  146. int32_t plat_scmi_clock_set_state(unsigned int agent_id, unsigned int scmi_id,
  147. bool enable_not_disable);
  148. /* Handlers for SCMI Reset Domain protocol services */
  149. /*
  150. * Return number of reset domains for the agent
  151. * @agent_id: SCMI agent ID
  152. * Return number of reset domains
  153. */
  154. size_t plat_scmi_rstd_count(unsigned int agent_id);
  155. /*
  156. * Get reset domain string ID (aka name)
  157. * @agent_id: SCMI agent ID
  158. * @scmi_id: SCMI reset domain ID
  159. * Return pointer to name or NULL
  160. */
  161. const char *plat_scmi_rstd_get_name(unsigned int agent_id, unsigned int scmi_id);
  162. /*
  163. * Perform a reset cycle on a target reset domain
  164. * @agent_id: SCMI agent ID
  165. * @scmi_id: SCMI reset domain ID
  166. * @state: Target reset state (see SCMI specification, 0 means context loss)
  167. * Return a compliant SCMI error code
  168. */
  169. int32_t plat_scmi_rstd_autonomous(unsigned int agent_id, unsigned int scmi_id,
  170. unsigned int state);
  171. /*
  172. * Assert or deassert target reset domain
  173. * @agent_id: SCMI agent ID
  174. * @scmi_id: SCMI reset domain ID
  175. * @assert_not_deassert: Assert domain if true, otherwise deassert domain
  176. * Return a compliant SCMI error code
  177. */
  178. int32_t plat_scmi_rstd_set_state(unsigned int agent_id, unsigned int scmi_id,
  179. bool assert_not_deassert);
  180. #endif /* SCMI_MSG_H */