amd_hsmp_x86.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef _ASM_X86_AMD_HSMP_H_
  3. #define _ASM_X86_AMD_HSMP_H_
  4. #include <linux/types.h>
  5. #pragma pack(4)
  6. #define HSMP_MAX_MSG_LEN 8
  7. /*
  8. * HSMP Messages supported
  9. */
  10. enum hsmp_message_ids {
  11. HSMP_TEST = 1, /* 01h Increments input value by 1 */
  12. HSMP_GET_SMU_VER, /* 02h SMU FW version */
  13. HSMP_GET_PROTO_VER, /* 03h HSMP interface version */
  14. HSMP_GET_SOCKET_POWER, /* 04h average package power consumption */
  15. HSMP_SET_SOCKET_POWER_LIMIT, /* 05h Set the socket power limit */
  16. HSMP_GET_SOCKET_POWER_LIMIT, /* 06h Get current socket power limit */
  17. HSMP_GET_SOCKET_POWER_LIMIT_MAX,/* 07h Get maximum socket power value */
  18. HSMP_SET_BOOST_LIMIT, /* 08h Set a core maximum frequency limit */
  19. HSMP_SET_BOOST_LIMIT_SOCKET, /* 09h Set socket maximum frequency level */
  20. HSMP_GET_BOOST_LIMIT, /* 0Ah Get current frequency limit */
  21. HSMP_GET_PROC_HOT, /* 0Bh Get PROCHOT status */
  22. HSMP_SET_XGMI_LINK_WIDTH, /* 0Ch Set max and min width of xGMI Link */
  23. HSMP_SET_DF_PSTATE, /* 0Dh Alter APEnable/Disable messages behavior */
  24. HSMP_SET_AUTO_DF_PSTATE, /* 0Eh Enable DF P-State Performance Boost algorithm */
  25. HSMP_GET_FCLK_MCLK, /* 0Fh Get FCLK and MEMCLK for current socket */
  26. HSMP_GET_CCLK_THROTTLE_LIMIT, /* 10h Get CCLK frequency limit in socket */
  27. HSMP_GET_C0_PERCENT, /* 11h Get average C0 residency in socket */
  28. HSMP_SET_NBIO_DPM_LEVEL, /* 12h Set max/min LCLK DPM Level for a given NBIO */
  29. HSMP_GET_NBIO_DPM_LEVEL, /* 13h Get LCLK DPM level min and max for a given NBIO */
  30. HSMP_GET_DDR_BANDWIDTH, /* 14h Get theoretical maximum and current DDR Bandwidth */
  31. HSMP_GET_TEMP_MONITOR, /* 15h Get socket temperature */
  32. HSMP_GET_DIMM_TEMP_RANGE, /* 16h Get per-DIMM temperature range and refresh rate */
  33. HSMP_GET_DIMM_POWER, /* 17h Get per-DIMM power consumption */
  34. HSMP_GET_DIMM_THERMAL, /* 18h Get per-DIMM thermal sensors */
  35. HSMP_GET_SOCKET_FREQ_LIMIT, /* 19h Get current active frequency per socket */
  36. HSMP_GET_CCLK_CORE_LIMIT, /* 1Ah Get CCLK frequency limit per core */
  37. HSMP_GET_RAILS_SVI, /* 1Bh Get SVI-based Telemetry for all rails */
  38. HSMP_GET_SOCKET_FMAX_FMIN, /* 1Ch Get Fmax and Fmin per socket */
  39. HSMP_GET_IOLINK_BANDWITH, /* 1Dh Get current bandwidth on IO Link */
  40. HSMP_GET_XGMI_BANDWITH, /* 1Eh Get current bandwidth on xGMI Link */
  41. HSMP_SET_GMI3_WIDTH, /* 1Fh Set max and min GMI3 Link width */
  42. HSMP_SET_PCI_RATE, /* 20h Control link rate on PCIe devices */
  43. HSMP_SET_POWER_MODE, /* 21h Select power efficiency profile policy */
  44. HSMP_SET_PSTATE_MAX_MIN, /* 22h Set the max and min DF P-State */
  45. HSMP_MSG_ID_MAX,
  46. };
  47. struct hsmp_message {
  48. __u32 msg_id; /* Message ID */
  49. __u16 num_args; /* Number of input argument words in message */
  50. __u16 response_sz; /* Number of expected output/response words */
  51. __u32 args[HSMP_MAX_MSG_LEN]; /* argument/response buffer */
  52. __u16 sock_ind; /* socket number */
  53. };
  54. enum hsmp_msg_type {
  55. HSMP_RSVD = -1,
  56. HSMP_SET = 0,
  57. HSMP_GET = 1,
  58. };
  59. struct hsmp_msg_desc {
  60. int num_args;
  61. int response_sz;
  62. enum hsmp_msg_type type;
  63. };
  64. /*
  65. * User may use these comments as reference, please find the
  66. * supported list of messages and message definition in the
  67. * HSMP chapter of respective family/model PPR.
  68. *
  69. * Not supported messages would return -ENOMSG.
  70. */
  71. static const struct hsmp_msg_desc hsmp_msg_desc_table[] = {
  72. /* RESERVED */
  73. {0, 0, HSMP_RSVD},
  74. /*
  75. * HSMP_TEST, num_args = 1, response_sz = 1
  76. * input: args[0] = xx
  77. * output: args[0] = xx + 1
  78. */
  79. {1, 1, HSMP_GET},
  80. /*
  81. * HSMP_GET_SMU_VER, num_args = 0, response_sz = 1
  82. * output: args[0] = smu fw ver
  83. */
  84. {0, 1, HSMP_GET},
  85. /*
  86. * HSMP_GET_PROTO_VER, num_args = 0, response_sz = 1
  87. * output: args[0] = proto version
  88. */
  89. {0, 1, HSMP_GET},
  90. /*
  91. * HSMP_GET_SOCKET_POWER, num_args = 0, response_sz = 1
  92. * output: args[0] = socket power in mWatts
  93. */
  94. {0, 1, HSMP_GET},
  95. /*
  96. * HSMP_SET_SOCKET_POWER_LIMIT, num_args = 1, response_sz = 0
  97. * input: args[0] = power limit value in mWatts
  98. */
  99. {1, 0, HSMP_SET},
  100. /*
  101. * HSMP_GET_SOCKET_POWER_LIMIT, num_args = 0, response_sz = 1
  102. * output: args[0] = socket power limit value in mWatts
  103. */
  104. {0, 1, HSMP_GET},
  105. /*
  106. * HSMP_GET_SOCKET_POWER_LIMIT_MAX, num_args = 0, response_sz = 1
  107. * output: args[0] = maximuam socket power limit in mWatts
  108. */
  109. {0, 1, HSMP_GET},
  110. /*
  111. * HSMP_SET_BOOST_LIMIT, num_args = 1, response_sz = 0
  112. * input: args[0] = apic id[31:16] + boost limit value in MHz[15:0]
  113. */
  114. {1, 0, HSMP_SET},
  115. /*
  116. * HSMP_SET_BOOST_LIMIT_SOCKET, num_args = 1, response_sz = 0
  117. * input: args[0] = boost limit value in MHz
  118. */
  119. {1, 0, HSMP_SET},
  120. /*
  121. * HSMP_GET_BOOST_LIMIT, num_args = 1, response_sz = 1
  122. * input: args[0] = apic id
  123. * output: args[0] = boost limit value in MHz
  124. */
  125. {1, 1, HSMP_GET},
  126. /*
  127. * HSMP_GET_PROC_HOT, num_args = 0, response_sz = 1
  128. * output: args[0] = proc hot status
  129. */
  130. {0, 1, HSMP_GET},
  131. /*
  132. * HSMP_SET_XGMI_LINK_WIDTH, num_args = 1, response_sz = 0
  133. * input: args[0] = min link width[15:8] + max link width[7:0]
  134. */
  135. {1, 0, HSMP_SET},
  136. /*
  137. * HSMP_SET_DF_PSTATE, num_args = 1, response_sz = 0
  138. * input: args[0] = df pstate[7:0]
  139. */
  140. {1, 0, HSMP_SET},
  141. /* HSMP_SET_AUTO_DF_PSTATE, num_args = 0, response_sz = 0 */
  142. {0, 0, HSMP_SET},
  143. /*
  144. * HSMP_GET_FCLK_MCLK, num_args = 0, response_sz = 2
  145. * output: args[0] = fclk in MHz, args[1] = mclk in MHz
  146. */
  147. {0, 2, HSMP_GET},
  148. /*
  149. * HSMP_GET_CCLK_THROTTLE_LIMIT, num_args = 0, response_sz = 1
  150. * output: args[0] = core clock in MHz
  151. */
  152. {0, 1, HSMP_GET},
  153. /*
  154. * HSMP_GET_C0_PERCENT, num_args = 0, response_sz = 1
  155. * output: args[0] = average c0 residency
  156. */
  157. {0, 1, HSMP_GET},
  158. /*
  159. * HSMP_SET_NBIO_DPM_LEVEL, num_args = 1, response_sz = 0
  160. * input: args[0] = nbioid[23:16] + max dpm level[15:8] + min dpm level[7:0]
  161. */
  162. {1, 0, HSMP_SET},
  163. /*
  164. * HSMP_GET_NBIO_DPM_LEVEL, num_args = 1, response_sz = 1
  165. * input: args[0] = nbioid[23:16]
  166. * output: args[0] = max dpm level[15:8] + min dpm level[7:0]
  167. */
  168. {1, 1, HSMP_GET},
  169. /*
  170. * HSMP_GET_DDR_BANDWIDTH, num_args = 0, response_sz = 1
  171. * output: args[0] = max bw in Gbps[31:20] + utilised bw in Gbps[19:8] +
  172. * bw in percentage[7:0]
  173. */
  174. {0, 1, HSMP_GET},
  175. /*
  176. * HSMP_GET_TEMP_MONITOR, num_args = 0, response_sz = 1
  177. * output: args[0] = temperature in degree celsius. [15:8] integer part +
  178. * [7:5] fractional part
  179. */
  180. {0, 1, HSMP_GET},
  181. /*
  182. * HSMP_GET_DIMM_TEMP_RANGE, num_args = 1, response_sz = 1
  183. * input: args[0] = DIMM address[7:0]
  184. * output: args[0] = refresh rate[3] + temperature range[2:0]
  185. */
  186. {1, 1, HSMP_GET},
  187. /*
  188. * HSMP_GET_DIMM_POWER, num_args = 1, response_sz = 1
  189. * input: args[0] = DIMM address[7:0]
  190. * output: args[0] = DIMM power in mW[31:17] + update rate in ms[16:8] +
  191. * DIMM address[7:0]
  192. */
  193. {1, 1, HSMP_GET},
  194. /*
  195. * HSMP_GET_DIMM_THERMAL, num_args = 1, response_sz = 1
  196. * input: args[0] = DIMM address[7:0]
  197. * output: args[0] = temperature in degree celcius[31:21] + update rate in ms[16:8] +
  198. * DIMM address[7:0]
  199. */
  200. {1, 1, HSMP_GET},
  201. /*
  202. * HSMP_GET_SOCKET_FREQ_LIMIT, num_args = 0, response_sz = 1
  203. * output: args[0] = frequency in MHz[31:16] + frequency source[15:0]
  204. */
  205. {0, 1, HSMP_GET},
  206. /*
  207. * HSMP_GET_CCLK_CORE_LIMIT, num_args = 1, response_sz = 1
  208. * input: args[0] = apic id [31:0]
  209. * output: args[0] = frequency in MHz[31:0]
  210. */
  211. {1, 1, HSMP_GET},
  212. /*
  213. * HSMP_GET_RAILS_SVI, num_args = 0, response_sz = 1
  214. * output: args[0] = power in mW[31:0]
  215. */
  216. {0, 1, HSMP_GET},
  217. /*
  218. * HSMP_GET_SOCKET_FMAX_FMIN, num_args = 0, response_sz = 1
  219. * output: args[0] = fmax in MHz[31:16] + fmin in MHz[15:0]
  220. */
  221. {0, 1, HSMP_GET},
  222. /*
  223. * HSMP_GET_IOLINK_BANDWITH, num_args = 1, response_sz = 1
  224. * input: args[0] = link id[15:8] + bw type[2:0]
  225. * output: args[0] = io bandwidth in Mbps[31:0]
  226. */
  227. {1, 1, HSMP_GET},
  228. /*
  229. * HSMP_GET_XGMI_BANDWITH, num_args = 1, response_sz = 1
  230. * input: args[0] = link id[15:8] + bw type[2:0]
  231. * output: args[0] = xgmi bandwidth in Mbps[31:0]
  232. */
  233. {1, 1, HSMP_GET},
  234. /*
  235. * HSMP_SET_GMI3_WIDTH, num_args = 1, response_sz = 0
  236. * input: args[0] = min link width[15:8] + max link width[7:0]
  237. */
  238. {1, 0, HSMP_SET},
  239. /*
  240. * HSMP_SET_PCI_RATE, num_args = 1, response_sz = 1
  241. * input: args[0] = link rate control value
  242. * output: args[0] = previous link rate control value
  243. */
  244. {1, 1, HSMP_SET},
  245. /*
  246. * HSMP_SET_POWER_MODE, num_args = 1, response_sz = 0
  247. * input: args[0] = power efficiency mode[2:0]
  248. */
  249. {1, 0, HSMP_SET},
  250. /*
  251. * HSMP_SET_PSTATE_MAX_MIN, num_args = 1, response_sz = 0
  252. * input: args[0] = min df pstate[15:8] + max df pstate[7:0]
  253. */
  254. {1, 0, HSMP_SET},
  255. };
  256. /* Reset to default packing */
  257. #pragma pack()
  258. /* Define unique ioctl command for hsmp msgs using generic _IOWR */
  259. #define HSMP_BASE_IOCTL_NR 0xF8
  260. #define HSMP_IOCTL_CMD _IOWR(HSMP_BASE_IOCTL_NR, 0, struct hsmp_message)
  261. #endif /*_ASM_X86_AMD_HSMP_H_*/