scmi_protocols.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
  2. /*
  3. * Copyright (c) 2015-2019, Arm Limited and Contributors. All rights reserved.
  4. * Copyright (C) 2019-2020, Linaro Limited
  5. */
  6. #ifndef _SCMI_PROTOCOLS_H
  7. #define _SCMI_PROTOCOLS_H
  8. #include <linux/bitops.h>
  9. #include <asm/types.h>
  10. /*
  11. * Subset the SCMI protocols definition
  12. * based on SCMI specification v2.0 (DEN0056B)
  13. * https://developer.arm.com/docs/den0056/b
  14. */
  15. enum scmi_std_protocol {
  16. SCMI_PROTOCOL_ID_BASE = 0x10,
  17. SCMI_PROTOCOL_ID_POWER_DOMAIN = 0x11,
  18. SCMI_PROTOCOL_ID_SYSTEM = 0x12,
  19. SCMI_PROTOCOL_ID_PERF = 0x13,
  20. SCMI_PROTOCOL_ID_CLOCK = 0x14,
  21. SCMI_PROTOCOL_ID_SENSOR = 0x15,
  22. SCMI_PROTOCOL_ID_RESET_DOMAIN = 0x16,
  23. SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN = 0x17,
  24. };
  25. enum scmi_status_code {
  26. SCMI_SUCCESS = 0,
  27. SCMI_NOT_SUPPORTED = -1,
  28. SCMI_INVALID_PARAMETERS = -2,
  29. SCMI_DENIED = -3,
  30. SCMI_NOT_FOUND = -4,
  31. SCMI_OUT_OF_RANGE = -5,
  32. SCMI_BUSY = -6,
  33. SCMI_COMMS_ERROR = -7,
  34. SCMI_GENERIC_ERROR = -8,
  35. SCMI_HARDWARE_ERROR = -9,
  36. SCMI_PROTOCOL_ERROR = -10,
  37. };
  38. /*
  39. * SCMI Clock Protocol
  40. */
  41. enum scmi_clock_message_id {
  42. SCMI_CLOCK_RATE_SET = 0x5,
  43. SCMI_CLOCK_RATE_GET = 0x6,
  44. SCMI_CLOCK_CONFIG_SET = 0x7,
  45. };
  46. #define SCMI_CLK_RATE_ASYNC_NOTIFY BIT(0)
  47. #define SCMI_CLK_RATE_ASYNC_NORESP (BIT(0) | BIT(1))
  48. #define SCMI_CLK_RATE_ROUND_DOWN 0
  49. #define SCMI_CLK_RATE_ROUND_UP BIT(2)
  50. #define SCMI_CLK_RATE_ROUND_CLOSEST BIT(3)
  51. /**
  52. * struct scmi_clk_state_in - Message payload for CLOCK_CONFIG_SET command
  53. * @clock_id: SCMI clock ID
  54. * @attributes: Attributes of the targets clock state
  55. */
  56. struct scmi_clk_state_in {
  57. u32 clock_id;
  58. u32 attributes;
  59. };
  60. /**
  61. * struct scmi_clk_state_out - Response payload for CLOCK_CONFIG_SET command
  62. * @status: SCMI command status
  63. */
  64. struct scmi_clk_state_out {
  65. s32 status;
  66. };
  67. /**
  68. * struct scmi_clk_state_in - Message payload for CLOCK_RATE_GET command
  69. * @clock_id: SCMI clock ID
  70. * @attributes: Attributes of the targets clock state
  71. */
  72. struct scmi_clk_rate_get_in {
  73. u32 clock_id;
  74. };
  75. /**
  76. * struct scmi_clk_rate_get_out - Response payload for CLOCK_RATE_GET command
  77. * @status: SCMI command status
  78. * @rate_lsb: 32bit LSB of the clock rate in Hertz
  79. * @rate_msb: 32bit MSB of the clock rate in Hertz
  80. */
  81. struct scmi_clk_rate_get_out {
  82. s32 status;
  83. u32 rate_lsb;
  84. u32 rate_msb;
  85. };
  86. /**
  87. * struct scmi_clk_state_in - Message payload for CLOCK_RATE_SET command
  88. * @flags: Flags for the clock rate set request
  89. * @clock_id: SCMI clock ID
  90. * @rate_lsb: 32bit LSB of the clock rate in Hertz
  91. * @rate_msb: 32bit MSB of the clock rate in Hertz
  92. */
  93. struct scmi_clk_rate_set_in {
  94. u32 flags;
  95. u32 clock_id;
  96. u32 rate_lsb;
  97. u32 rate_msb;
  98. };
  99. /**
  100. * struct scmi_clk_rate_set_out - Response payload for CLOCK_RATE_SET command
  101. * @status: SCMI command status
  102. */
  103. struct scmi_clk_rate_set_out {
  104. s32 status;
  105. };
  106. /*
  107. * SCMI Reset Domain Protocol
  108. */
  109. enum scmi_reset_domain_message_id {
  110. SCMI_RESET_DOMAIN_ATTRIBUTES = 0x3,
  111. SCMI_RESET_DOMAIN_RESET = 0x4,
  112. };
  113. #define SCMI_RD_NAME_LEN 16
  114. #define SCMI_RD_ATTRIBUTES_FLAG_ASYNC BIT(31)
  115. #define SCMI_RD_ATTRIBUTES_FLAG_NOTIF BIT(30)
  116. #define SCMI_RD_RESET_FLAG_ASYNC BIT(2)
  117. #define SCMI_RD_RESET_FLAG_ASSERT BIT(1)
  118. #define SCMI_RD_RESET_FLAG_CYCLE BIT(0)
  119. /**
  120. * struct scmi_rd_attr_in - Payload for RESET_DOMAIN_ATTRIBUTES message
  121. * @domain_id: SCMI reset domain ID
  122. */
  123. struct scmi_rd_attr_in {
  124. u32 domain_id;
  125. };
  126. /**
  127. * struct scmi_rd_attr_out - Payload for RESET_DOMAIN_ATTRIBUTES response
  128. * @status: SCMI command status
  129. * @attributes: Retrieved attributes of the reset domain
  130. * @latency: Reset cycle max lantency
  131. * @name: Reset domain name
  132. */
  133. struct scmi_rd_attr_out {
  134. s32 status;
  135. u32 attributes;
  136. u32 latency;
  137. char name[SCMI_RD_NAME_LEN];
  138. };
  139. /**
  140. * struct scmi_rd_reset_in - Message payload for RESET command
  141. * @domain_id: SCMI reset domain ID
  142. * @flags: Flags for the reset request
  143. * @reset_state: Reset target state
  144. */
  145. struct scmi_rd_reset_in {
  146. u32 domain_id;
  147. u32 flags;
  148. u32 reset_state;
  149. };
  150. /**
  151. * struct scmi_rd_reset_out - Response payload for RESET command
  152. * @status: SCMI command status
  153. */
  154. struct scmi_rd_reset_out {
  155. s32 status;
  156. };
  157. /*
  158. * SCMI Voltage Domain Protocol
  159. */
  160. enum scmi_voltage_domain_message_id {
  161. SCMI_VOLTAGE_DOMAIN_ATTRIBUTES = 0x3,
  162. SCMI_VOLTAGE_DOMAIN_CONFIG_SET = 0x5,
  163. SCMI_VOLTAGE_DOMAIN_CONFIG_GET = 0x6,
  164. SCMI_VOLTAGE_DOMAIN_LEVEL_SET = 0x7,
  165. SCMI_VOLTAGE_DOMAIN_LEVEL_GET = 0x8,
  166. };
  167. #define SCMI_VOLTD_NAME_LEN 16
  168. #define SCMI_VOLTD_CONFIG_MASK GENMASK(3, 0)
  169. #define SCMI_VOLTD_CONFIG_OFF 0
  170. #define SCMI_VOLTD_CONFIG_ON 0x7
  171. /**
  172. * struct scmi_voltd_attr_in - Payload for VOLTAGE_DOMAIN_ATTRIBUTES message
  173. * @domain_id: SCMI voltage domain ID
  174. */
  175. struct scmi_voltd_attr_in {
  176. u32 domain_id;
  177. };
  178. /**
  179. * struct scmi_voltd_attr_out - Payload for VOLTAGE_DOMAIN_ATTRIBUTES response
  180. * @status: SCMI command status
  181. * @attributes: Retrieved attributes of the voltage domain
  182. * @name: Voltage domain name
  183. */
  184. struct scmi_voltd_attr_out {
  185. s32 status;
  186. u32 attributes;
  187. char name[SCMI_VOLTD_NAME_LEN];
  188. };
  189. /**
  190. * struct scmi_voltd_config_set_in - Message payload for VOLTAGE_CONFIG_SET cmd
  191. * @domain_id: SCMI voltage domain ID
  192. * @config: Configuration data of the voltage domain
  193. */
  194. struct scmi_voltd_config_set_in {
  195. u32 domain_id;
  196. u32 config;
  197. };
  198. /**
  199. * struct scmi_voltd_config_set_out - Response for VOLTAGE_CONFIG_SET command
  200. * @status: SCMI command status
  201. */
  202. struct scmi_voltd_config_set_out {
  203. s32 status;
  204. };
  205. /**
  206. * struct scmi_voltd_config_get_in - Message payload for VOLTAGE_CONFIG_GET cmd
  207. * @domain_id: SCMI voltage domain ID
  208. */
  209. struct scmi_voltd_config_get_in {
  210. u32 domain_id;
  211. };
  212. /**
  213. * struct scmi_voltd_config_get_out - Response for VOLTAGE_CONFIG_GET command
  214. * @status: SCMI command status
  215. * @config: Configuration data of the voltage domain
  216. */
  217. struct scmi_voltd_config_get_out {
  218. s32 status;
  219. u32 config;
  220. };
  221. /**
  222. * struct scmi_voltd_level_set_in - Message payload for VOLTAGE_LEVEL_SET cmd
  223. * @domain_id: SCMI voltage domain ID
  224. * @flags: Parameter flags for configuring target level
  225. * @voltage_level: Target voltage level in microvolts (uV)
  226. */
  227. struct scmi_voltd_level_set_in {
  228. u32 domain_id;
  229. u32 flags;
  230. s32 voltage_level;
  231. };
  232. /**
  233. * struct scmi_voltd_level_set_out - Response for VOLTAGE_LEVEL_SET command
  234. * @status: SCMI command status
  235. */
  236. struct scmi_voltd_level_set_out {
  237. s32 status;
  238. };
  239. /**
  240. * struct scmi_voltd_level_get_in - Message payload for VOLTAGE_LEVEL_GET cmd
  241. * @domain_id: SCMI voltage domain ID
  242. */
  243. struct scmi_voltd_level_get_in {
  244. u32 domain_id;
  245. };
  246. /**
  247. * struct scmi_voltd_level_get_out - Response for VOLTAGE_LEVEL_GET command
  248. * @status: SCMI command status
  249. * @voltage_level: Voltage level in microvolts (uV)
  250. */
  251. struct scmi_voltd_level_get_out {
  252. s32 status;
  253. s32 voltage_level;
  254. };
  255. #endif /* _SCMI_PROTOCOLS_H */