scmi_protocols.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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. * Generic message IDs
  40. */
  41. enum scmi_discovery_id {
  42. SCMI_PROTOCOL_VERSION = 0x0,
  43. SCMI_PROTOCOL_ATTRIBUTES = 0x1,
  44. SCMI_PROTOCOL_MESSAGE_ATTRIBUTES = 0x2,
  45. };
  46. /*
  47. * SCMI Clock Protocol
  48. */
  49. enum scmi_clock_message_id {
  50. SCMI_CLOCK_ATTRIBUTES = 0x3,
  51. SCMI_CLOCK_RATE_SET = 0x5,
  52. SCMI_CLOCK_RATE_GET = 0x6,
  53. SCMI_CLOCK_CONFIG_SET = 0x7,
  54. };
  55. #define SCMI_CLK_PROTO_ATTR_COUNT_MASK GENMASK(15, 0)
  56. #define SCMI_CLK_RATE_ASYNC_NOTIFY BIT(0)
  57. #define SCMI_CLK_RATE_ASYNC_NORESP (BIT(0) | BIT(1))
  58. #define SCMI_CLK_RATE_ROUND_DOWN 0
  59. #define SCMI_CLK_RATE_ROUND_UP BIT(2)
  60. #define SCMI_CLK_RATE_ROUND_CLOSEST BIT(3)
  61. #define SCMI_CLOCK_NAME_LENGTH_MAX 16
  62. /**
  63. * struct scmi_clk_get_nb_out - Response for SCMI_PROTOCOL_ATTRIBUTES command
  64. * @status: SCMI command status
  65. * @attributes: Attributes of the clock protocol, mainly number of clocks exposed
  66. */
  67. struct scmi_clk_protocol_attr_out {
  68. s32 status;
  69. u32 attributes;
  70. };
  71. /**
  72. * struct scmi_clk_attribute_in - Message payload for SCMI_CLOCK_ATTRIBUTES command
  73. * @clock_id: SCMI clock ID
  74. */
  75. struct scmi_clk_attribute_in {
  76. u32 clock_id;
  77. };
  78. /**
  79. * struct scmi_clk_get_nb_out - Response payload for SCMI_CLOCK_ATTRIBUTES command
  80. * @status: SCMI command status
  81. * @attributes: clock attributes
  82. * @clock_name: name of the clock
  83. */
  84. struct scmi_clk_attribute_out {
  85. s32 status;
  86. u32 attributes;
  87. char clock_name[SCMI_CLOCK_NAME_LENGTH_MAX];
  88. };
  89. /**
  90. * struct scmi_clk_state_in - Message payload for CLOCK_CONFIG_SET command
  91. * @clock_id: SCMI clock ID
  92. * @attributes: Attributes of the targets clock state
  93. */
  94. struct scmi_clk_state_in {
  95. u32 clock_id;
  96. u32 attributes;
  97. };
  98. /**
  99. * struct scmi_clk_state_out - Response payload for CLOCK_CONFIG_SET command
  100. * @status: SCMI command status
  101. */
  102. struct scmi_clk_state_out {
  103. s32 status;
  104. };
  105. /**
  106. * struct scmi_clk_state_in - Message payload for CLOCK_RATE_GET command
  107. * @clock_id: SCMI clock ID
  108. * @attributes: Attributes of the targets clock state
  109. */
  110. struct scmi_clk_rate_get_in {
  111. u32 clock_id;
  112. };
  113. /**
  114. * struct scmi_clk_rate_get_out - Response payload for CLOCK_RATE_GET command
  115. * @status: SCMI command status
  116. * @rate_lsb: 32bit LSB of the clock rate in Hertz
  117. * @rate_msb: 32bit MSB of the clock rate in Hertz
  118. */
  119. struct scmi_clk_rate_get_out {
  120. s32 status;
  121. u32 rate_lsb;
  122. u32 rate_msb;
  123. };
  124. /**
  125. * struct scmi_clk_state_in - Message payload for CLOCK_RATE_SET command
  126. * @flags: Flags for the clock rate set request
  127. * @clock_id: SCMI clock ID
  128. * @rate_lsb: 32bit LSB of the clock rate in Hertz
  129. * @rate_msb: 32bit MSB of the clock rate in Hertz
  130. */
  131. struct scmi_clk_rate_set_in {
  132. u32 flags;
  133. u32 clock_id;
  134. u32 rate_lsb;
  135. u32 rate_msb;
  136. };
  137. /**
  138. * struct scmi_clk_rate_set_out - Response payload for CLOCK_RATE_SET command
  139. * @status: SCMI command status
  140. */
  141. struct scmi_clk_rate_set_out {
  142. s32 status;
  143. };
  144. /*
  145. * SCMI Reset Domain Protocol
  146. */
  147. enum scmi_reset_domain_message_id {
  148. SCMI_RESET_DOMAIN_ATTRIBUTES = 0x3,
  149. SCMI_RESET_DOMAIN_RESET = 0x4,
  150. };
  151. #define SCMI_RD_NAME_LEN 16
  152. #define SCMI_RD_ATTRIBUTES_FLAG_ASYNC BIT(31)
  153. #define SCMI_RD_ATTRIBUTES_FLAG_NOTIF BIT(30)
  154. #define SCMI_RD_RESET_FLAG_ASYNC BIT(2)
  155. #define SCMI_RD_RESET_FLAG_ASSERT BIT(1)
  156. #define SCMI_RD_RESET_FLAG_CYCLE BIT(0)
  157. /**
  158. * struct scmi_rd_attr_in - Payload for RESET_DOMAIN_ATTRIBUTES message
  159. * @domain_id: SCMI reset domain ID
  160. */
  161. struct scmi_rd_attr_in {
  162. u32 domain_id;
  163. };
  164. /**
  165. * struct scmi_rd_attr_out - Payload for RESET_DOMAIN_ATTRIBUTES response
  166. * @status: SCMI command status
  167. * @attributes: Retrieved attributes of the reset domain
  168. * @latency: Reset cycle max lantency
  169. * @name: Reset domain name
  170. */
  171. struct scmi_rd_attr_out {
  172. s32 status;
  173. u32 attributes;
  174. u32 latency;
  175. char name[SCMI_RD_NAME_LEN];
  176. };
  177. /**
  178. * struct scmi_rd_reset_in - Message payload for RESET command
  179. * @domain_id: SCMI reset domain ID
  180. * @flags: Flags for the reset request
  181. * @reset_state: Reset target state
  182. */
  183. struct scmi_rd_reset_in {
  184. u32 domain_id;
  185. u32 flags;
  186. u32 reset_state;
  187. };
  188. /**
  189. * struct scmi_rd_reset_out - Response payload for RESET command
  190. * @status: SCMI command status
  191. */
  192. struct scmi_rd_reset_out {
  193. s32 status;
  194. };
  195. /*
  196. * SCMI Voltage Domain Protocol
  197. */
  198. enum scmi_voltage_domain_message_id {
  199. SCMI_VOLTAGE_DOMAIN_ATTRIBUTES = 0x3,
  200. SCMI_VOLTAGE_DOMAIN_CONFIG_SET = 0x5,
  201. SCMI_VOLTAGE_DOMAIN_CONFIG_GET = 0x6,
  202. SCMI_VOLTAGE_DOMAIN_LEVEL_SET = 0x7,
  203. SCMI_VOLTAGE_DOMAIN_LEVEL_GET = 0x8,
  204. };
  205. #define SCMI_VOLTD_NAME_LEN 16
  206. #define SCMI_VOLTD_CONFIG_MASK GENMASK(3, 0)
  207. #define SCMI_VOLTD_CONFIG_OFF 0
  208. #define SCMI_VOLTD_CONFIG_ON 0x7
  209. /**
  210. * struct scmi_voltd_attr_in - Payload for VOLTAGE_DOMAIN_ATTRIBUTES message
  211. * @domain_id: SCMI voltage domain ID
  212. */
  213. struct scmi_voltd_attr_in {
  214. u32 domain_id;
  215. };
  216. /**
  217. * struct scmi_voltd_attr_out - Payload for VOLTAGE_DOMAIN_ATTRIBUTES response
  218. * @status: SCMI command status
  219. * @attributes: Retrieved attributes of the voltage domain
  220. * @name: Voltage domain name
  221. */
  222. struct scmi_voltd_attr_out {
  223. s32 status;
  224. u32 attributes;
  225. char name[SCMI_VOLTD_NAME_LEN];
  226. };
  227. /**
  228. * struct scmi_voltd_config_set_in - Message payload for VOLTAGE_CONFIG_SET cmd
  229. * @domain_id: SCMI voltage domain ID
  230. * @config: Configuration data of the voltage domain
  231. */
  232. struct scmi_voltd_config_set_in {
  233. u32 domain_id;
  234. u32 config;
  235. };
  236. /**
  237. * struct scmi_voltd_config_set_out - Response for VOLTAGE_CONFIG_SET command
  238. * @status: SCMI command status
  239. */
  240. struct scmi_voltd_config_set_out {
  241. s32 status;
  242. };
  243. /**
  244. * struct scmi_voltd_config_get_in - Message payload for VOLTAGE_CONFIG_GET cmd
  245. * @domain_id: SCMI voltage domain ID
  246. */
  247. struct scmi_voltd_config_get_in {
  248. u32 domain_id;
  249. };
  250. /**
  251. * struct scmi_voltd_config_get_out - Response for VOLTAGE_CONFIG_GET command
  252. * @status: SCMI command status
  253. * @config: Configuration data of the voltage domain
  254. */
  255. struct scmi_voltd_config_get_out {
  256. s32 status;
  257. u32 config;
  258. };
  259. /**
  260. * struct scmi_voltd_level_set_in - Message payload for VOLTAGE_LEVEL_SET cmd
  261. * @domain_id: SCMI voltage domain ID
  262. * @flags: Parameter flags for configuring target level
  263. * @voltage_level: Target voltage level in microvolts (uV)
  264. */
  265. struct scmi_voltd_level_set_in {
  266. u32 domain_id;
  267. u32 flags;
  268. s32 voltage_level;
  269. };
  270. /**
  271. * struct scmi_voltd_level_set_out - Response for VOLTAGE_LEVEL_SET command
  272. * @status: SCMI command status
  273. */
  274. struct scmi_voltd_level_set_out {
  275. s32 status;
  276. };
  277. /**
  278. * struct scmi_voltd_level_get_in - Message payload for VOLTAGE_LEVEL_GET cmd
  279. * @domain_id: SCMI voltage domain ID
  280. */
  281. struct scmi_voltd_level_get_in {
  282. u32 domain_id;
  283. };
  284. /**
  285. * struct scmi_voltd_level_get_out - Response for VOLTAGE_LEVEL_GET command
  286. * @status: SCMI command status
  287. * @voltage_level: Voltage level in microvolts (uV)
  288. */
  289. struct scmi_voltd_level_get_out {
  290. s32 status;
  291. s32 voltage_level;
  292. };
  293. #endif /* _SCMI_PROTOCOLS_H */