scmi_protocols.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. };
  24. enum scmi_status_code {
  25. SCMI_SUCCESS = 0,
  26. SCMI_NOT_SUPPORTED = -1,
  27. SCMI_INVALID_PARAMETERS = -2,
  28. SCMI_DENIED = -3,
  29. SCMI_NOT_FOUND = -4,
  30. SCMI_OUT_OF_RANGE = -5,
  31. SCMI_BUSY = -6,
  32. SCMI_COMMS_ERROR = -7,
  33. SCMI_GENERIC_ERROR = -8,
  34. SCMI_HARDWARE_ERROR = -9,
  35. SCMI_PROTOCOL_ERROR = -10,
  36. };
  37. /*
  38. * SCMI Clock Protocol
  39. */
  40. enum scmi_clock_message_id {
  41. SCMI_CLOCK_RATE_SET = 0x5,
  42. SCMI_CLOCK_RATE_GET = 0x6,
  43. SCMI_CLOCK_CONFIG_SET = 0x7,
  44. };
  45. #define SCMI_CLK_RATE_ASYNC_NOTIFY BIT(0)
  46. #define SCMI_CLK_RATE_ASYNC_NORESP (BIT(0) | BIT(1))
  47. #define SCMI_CLK_RATE_ROUND_DOWN 0
  48. #define SCMI_CLK_RATE_ROUND_UP BIT(2)
  49. #define SCMI_CLK_RATE_ROUND_CLOSEST BIT(3)
  50. /**
  51. * struct scmi_clk_state_in - Message payload for CLOCK_CONFIG_SET command
  52. * @clock_id: SCMI clock ID
  53. * @attributes: Attributes of the targets clock state
  54. */
  55. struct scmi_clk_state_in {
  56. u32 clock_id;
  57. u32 attributes;
  58. };
  59. /**
  60. * struct scmi_clk_state_out - Response payload for CLOCK_CONFIG_SET command
  61. * @status: SCMI command status
  62. */
  63. struct scmi_clk_state_out {
  64. s32 status;
  65. };
  66. /**
  67. * struct scmi_clk_state_in - Message payload for CLOCK_RATE_GET command
  68. * @clock_id: SCMI clock ID
  69. * @attributes: Attributes of the targets clock state
  70. */
  71. struct scmi_clk_rate_get_in {
  72. u32 clock_id;
  73. };
  74. /**
  75. * struct scmi_clk_rate_get_out - Response payload for CLOCK_RATE_GET command
  76. * @status: SCMI command status
  77. * @rate_lsb: 32bit LSB of the clock rate in Hertz
  78. * @rate_msb: 32bit MSB of the clock rate in Hertz
  79. */
  80. struct scmi_clk_rate_get_out {
  81. s32 status;
  82. u32 rate_lsb;
  83. u32 rate_msb;
  84. };
  85. /**
  86. * struct scmi_clk_state_in - Message payload for CLOCK_RATE_SET command
  87. * @clock_id: SCMI clock ID
  88. * @flags: Flags for the clock rate set request
  89. * @rate_lsb: 32bit LSB of the clock rate in Hertz
  90. * @rate_msb: 32bit MSB of the clock rate in Hertz
  91. */
  92. struct scmi_clk_rate_set_in {
  93. u32 clock_id;
  94. u32 flags;
  95. u32 rate_lsb;
  96. u32 rate_msb;
  97. };
  98. /**
  99. * struct scmi_clk_rate_set_out - Response payload for CLOCK_RATE_SET command
  100. * @status: SCMI command status
  101. */
  102. struct scmi_clk_rate_set_out {
  103. s32 status;
  104. };
  105. /*
  106. * SCMI Reset Domain Protocol
  107. */
  108. enum scmi_reset_domain_message_id {
  109. SCMI_RESET_DOMAIN_ATTRIBUTES = 0x3,
  110. SCMI_RESET_DOMAIN_RESET = 0x4,
  111. };
  112. #define SCMI_RD_NAME_LEN 16
  113. #define SCMI_RD_ATTRIBUTES_FLAG_ASYNC BIT(31)
  114. #define SCMI_RD_ATTRIBUTES_FLAG_NOTIF BIT(30)
  115. #define SCMI_RD_RESET_FLAG_ASYNC BIT(2)
  116. #define SCMI_RD_RESET_FLAG_ASSERT BIT(1)
  117. #define SCMI_RD_RESET_FLAG_CYCLE BIT(0)
  118. /**
  119. * struct scmi_rd_attr_in - Payload for RESET_DOMAIN_ATTRIBUTES message
  120. * @domain_id: SCMI reset domain ID
  121. */
  122. struct scmi_rd_attr_in {
  123. u32 domain_id;
  124. };
  125. /**
  126. * struct scmi_rd_attr_out - Payload for RESET_DOMAIN_ATTRIBUTES response
  127. * @status: SCMI command status
  128. * @attributes: Retrieved attributes of the reset domain
  129. * @latency: Reset cycle max lantency
  130. * @name: Reset domain name
  131. */
  132. struct scmi_rd_attr_out {
  133. s32 status;
  134. u32 attributes;
  135. u32 latency;
  136. char name[SCMI_RD_NAME_LEN];
  137. };
  138. /**
  139. * struct scmi_rd_reset_in - Message payload for RESET command
  140. * @domain_id: SCMI reset domain ID
  141. * @flags: Flags for the reset request
  142. * @reset_state: Reset target state
  143. */
  144. struct scmi_rd_reset_in {
  145. u32 domain_id;
  146. u32 flags;
  147. u32 reset_state;
  148. };
  149. /**
  150. * struct scmi_rd_reset_out - Response payload for RESET command
  151. * @status: SCMI command status
  152. */
  153. struct scmi_rd_reset_out {
  154. s32 status;
  155. };
  156. #endif /* _SCMI_PROTOCOLS_H */