1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 3 #ifndef _UAPI_ASM_X86_AMD_HSMP_H_ 4 #define _UAPI_ASM_X86_AMD_HSMP_H_ 5 6 #include <linux/types.h> 7 8 #pragma pack(4) 9 10 #define HSMP_MAX_MSG_LEN 8 11 12 /* 13 * HSMP Messages supported 14 */ 15 enum hsmp_message_ids { 16 HSMP_TEST = 1, /* 01h Increments input value by 1 */ 17 HSMP_GET_SMU_VER, /* 02h SMU FW version */ 18 HSMP_GET_PROTO_VER, /* 03h HSMP interface version */ 19 HSMP_GET_SOCKET_POWER, /* 04h average package power consumption */ 20 HSMP_SET_SOCKET_POWER_LIMIT, /* 05h Set the socket power limit */ 21 HSMP_GET_SOCKET_POWER_LIMIT, /* 06h Get current socket power limit */ 22 HSMP_GET_SOCKET_POWER_LIMIT_MAX,/* 07h Get maximum socket power value */ 23 HSMP_SET_BOOST_LIMIT, /* 08h Set a core maximum frequency limit */ 24 HSMP_SET_BOOST_LIMIT_SOCKET, /* 09h Set socket maximum frequency level */ 25 HSMP_GET_BOOST_LIMIT, /* 0Ah Get current frequency limit */ 26 HSMP_GET_PROC_HOT, /* 0Bh Get PROCHOT status */ 27 HSMP_SET_XGMI_LINK_WIDTH, /* 0Ch Set max and min width of xGMI Link */ 28 HSMP_SET_DF_PSTATE, /* 0Dh Alter APEnable/Disable messages behavior */ 29 HSMP_SET_AUTO_DF_PSTATE, /* 0Eh Enable DF P-State Performance Boost algorithm */ 30 HSMP_GET_FCLK_MCLK, /* 0Fh Get FCLK and MEMCLK for current socket */ 31 HSMP_GET_CCLK_THROTTLE_LIMIT, /* 10h Get CCLK frequency limit in socket */ 32 HSMP_GET_C0_PERCENT, /* 11h Get average C0 residency in socket */ 33 HSMP_SET_NBIO_DPM_LEVEL, /* 12h Set max/min LCLK DPM Level for a given NBIO */ 34 /* 13h Reserved */ 35 HSMP_GET_DDR_BANDWIDTH = 0x14, /* 14h Get theoretical maximum and current DDR Bandwidth */ 36 HSMP_GET_TEMP_MONITOR, /* 15h Get per-DIMM temperature and refresh rates */ 37 HSMP_MSG_ID_MAX, 38 }; 39 40 struct hsmp_message { 41 __u32 msg_id; /* Message ID */ 42 __u16 num_args; /* Number of input argument words in message */ 43 __u16 response_sz; /* Number of expected output/response words */ 44 __u32 args[HSMP_MAX_MSG_LEN]; /* argument/response buffer */ 45 __u16 sock_ind; /* socket number */ 46 }; 47 48 enum hsmp_msg_type { 49 HSMP_RSVD = -1, 50 HSMP_SET = 0, 51 HSMP_GET = 1, 52 }; 53 54 struct hsmp_msg_desc { 55 int num_args; 56 int response_sz; 57 enum hsmp_msg_type type; 58 }; 59 60 /* 61 * User may use these comments as reference, please find the 62 * supported list of messages and message definition in the 63 * HSMP chapter of respective family/model PPR. 64 * 65 * Not supported messages would return -ENOMSG. 66 */ 67 static const struct hsmp_msg_desc hsmp_msg_desc_table[] = { 68 /* RESERVED */ 69 {0, 0, HSMP_RSVD}, 70 71 /* 72 * HSMP_TEST, num_args = 1, response_sz = 1 73 * input: args[0] = xx 74 * output: args[0] = xx + 1 75 */ 76 {1, 1, HSMP_GET}, 77 78 /* 79 * HSMP_GET_SMU_VER, num_args = 0, response_sz = 1 80 * output: args[0] = smu fw ver 81 */ 82 {0, 1, HSMP_GET}, 83 84 /* 85 * HSMP_GET_PROTO_VER, num_args = 0, response_sz = 1 86 * output: args[0] = proto version 87 */ 88 {0, 1, HSMP_GET}, 89 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 /* 97 * HSMP_SET_SOCKET_POWER_LIMIT, num_args = 1, response_sz = 0 98 * input: args[0] = power limit value in mWatts 99 */ 100 {1, 0, HSMP_SET}, 101 102 /* 103 * HSMP_GET_SOCKET_POWER_LIMIT, num_args = 0, response_sz = 1 104 * output: args[0] = socket power limit value in mWatts 105 */ 106 {0, 1, HSMP_GET}, 107 108 /* 109 * HSMP_GET_SOCKET_POWER_LIMIT_MAX, num_args = 0, response_sz = 1 110 * output: args[0] = maximuam socket power limit in mWatts 111 */ 112 {0, 1, HSMP_GET}, 113 114 /* 115 * HSMP_SET_BOOST_LIMIT, num_args = 1, response_sz = 0 116 * input: args[0] = apic id[31:16] + boost limit value in MHz[15:0] 117 */ 118 {1, 0, HSMP_SET}, 119 120 /* 121 * HSMP_SET_BOOST_LIMIT_SOCKET, num_args = 1, response_sz = 0 122 * input: args[0] = boost limit value in MHz 123 */ 124 {1, 0, HSMP_SET}, 125 126 /* 127 * HSMP_GET_BOOST_LIMIT, num_args = 1, response_sz = 1 128 * input: args[0] = apic id 129 * output: args[0] = boost limit value in MHz 130 */ 131 {1, 1, HSMP_GET}, 132 133 /* 134 * HSMP_GET_PROC_HOT, num_args = 0, response_sz = 1 135 * output: args[0] = proc hot status 136 */ 137 {0, 1, HSMP_GET}, 138 139 /* 140 * HSMP_SET_XGMI_LINK_WIDTH, num_args = 1, response_sz = 0 141 * input: args[0] = min link width[15:8] + max link width[7:0] 142 */ 143 {1, 0, HSMP_SET}, 144 145 /* 146 * HSMP_SET_DF_PSTATE, num_args = 1, response_sz = 0 147 * input: args[0] = df pstate[7:0] 148 */ 149 {1, 0, HSMP_SET}, 150 151 /* HSMP_SET_AUTO_DF_PSTATE, num_args = 0, response_sz = 0 */ 152 {0, 0, HSMP_SET}, 153 154 /* 155 * HSMP_GET_FCLK_MCLK, num_args = 0, response_sz = 2 156 * output: args[0] = fclk in MHz, args[1] = mclk in MHz 157 */ 158 {0, 2, HSMP_GET}, 159 160 /* 161 * HSMP_GET_CCLK_THROTTLE_LIMIT, num_args = 0, response_sz = 1 162 * output: args[0] = core clock in MHz 163 */ 164 {0, 1, HSMP_GET}, 165 166 /* 167 * HSMP_GET_C0_PERCENT, num_args = 0, response_sz = 1 168 * output: args[0] = average c0 residency 169 */ 170 {0, 1, HSMP_GET}, 171 172 /* 173 * HSMP_SET_NBIO_DPM_LEVEL, num_args = 1, response_sz = 0 174 * input: args[0] = nbioid[23:16] + max dpm level[15:8] + min dpm level[7:0] 175 */ 176 {1, 0, HSMP_SET}, 177 178 /* RESERVED message */ 179 {0, 0, HSMP_RSVD}, 180 181 /* 182 * HSMP_GET_DDR_BANDWIDTH, num_args = 0, response_sz = 1 183 * output: args[0] = max bw in Gbps[31:20] + utilised bw in Gbps[19:8] + 184 * bw in percentage[7:0] 185 */ 186 {0, 1, HSMP_GET}, 187 188 /* 189 * HSMP_GET_TEMP_MONITOR, num_args = 0, response_sz = 1 190 * output: args[0] = temperature in degree celsius. [15:8] integer part + 191 * [7:5] fractional part 192 */ 193 {0, 1, HSMP_GET}, 194 }; 195 196 /* Reset to default packing */ 197 #pragma pack() 198 199 /* Define unique ioctl command for hsmp msgs using generic _IOWR */ 200 #define HSMP_BASE_IOCTL_NR 0xF8 201 #define HSMP_IOCTL_CMD _IOWR(HSMP_BASE_IOCTL_NR, 0, struct hsmp_message) 202 203 #endif /*_ASM_X86_AMD_HSMP_H_*/ 204