---
arch/x86/include/uapi/asm/amd_hsmp.h | 255 ++-------------------------
drivers/platform/x86/amd/hsmp/hsmp.c | 245 +++++++++++++++++++++++++
2 files changed, 255 insertions(+), 245 deletions(-)
diff --git a/arch/x86/include/uapi/asm/amd_hsmp.h b/arch/x86/include/uapi/asm/amd_hsmp.h
index e5d182c7373c..dfa6aa985ac4 100644
--- a/arch/x86/include/uapi/asm/amd_hsmp.h
+++ b/arch/x86/include/uapi/asm/amd_hsmp.h
@@ -1,5 +1,15 @@
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * See hsmp_msg_desc_table[] in:
+ * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/platform/x86/amd/hsmp.c
+ *
+ * for some information on number of input- and output arguments
+ * for the various functions.
+ *
+ * Please find the supported list of messages and message definition
+ * in the HSMP chapter of respective family/model PPR.
+ */
#ifndef _UAPI_ASM_X86_AMD_HSMP_H_
#define _UAPI_ASM_X86_AMD_HSMP_H_
@@ -81,251 +91,6 @@ struct hsmp_msg_desc {
enum hsmp_msg_type type;
};
-/*
- * User may use these comments as reference, please find the
- * supported list of messages and message definition in the
- * HSMP chapter of respective family/model PPR.
- *
- * Not supported messages would return -ENOMSG.
- */
-static const struct hsmp_msg_desc hsmp_msg_desc_table[] = {
- /* RESERVED */
- {0, 0, HSMP_RSVD},
-
- /*
- * HSMP_TEST, num_args = 1, response_sz = 1
- * input: args[0] = xx
- * output: args[0] = xx + 1
- */
- {1, 1, HSMP_GET},
-
- /*
- * HSMP_GET_SMU_VER, num_args = 0, response_sz = 1
- * output: args[0] = smu fw ver
- */
- {0, 1, HSMP_GET},
-
- /*
- * HSMP_GET_PROTO_VER, num_args = 0, response_sz = 1
- * output: args[0] = proto version
- */
- {0, 1, HSMP_GET},
-
- /*
- * HSMP_GET_SOCKET_POWER, num_args = 0, response_sz = 1
- * output: args[0] = socket power in mWatts
- */
- {0, 1, HSMP_GET},
-
- /*
- * HSMP_SET_SOCKET_POWER_LIMIT, num_args = 1, response_sz = 0
- * input: args[0] = power limit value in mWatts
- */
- {1, 0, HSMP_SET},
-
- /*
- * HSMP_GET_SOCKET_POWER_LIMIT, num_args = 0, response_sz = 1
- * output: args[0] = socket power limit value in mWatts
- */
- {0, 1, HSMP_GET},
-
- /*
- * HSMP_GET_SOCKET_POWER_LIMIT_MAX, num_args = 0, response_sz = 1
- * output: args[0] = maximuam socket power limit in mWatts
- */
- {0, 1, HSMP_GET},
-
- /*
- * HSMP_SET_BOOST_LIMIT, num_args = 1, response_sz = 0
- * input: args[0] = apic id[31:16] + boost limit value in MHz[15:0]
- */
- {1, 0, HSMP_SET},
-
- /*
- * HSMP_SET_BOOST_LIMIT_SOCKET, num_args = 1, response_sz = 0
- * input: args[0] = boost limit value in MHz
- */
- {1, 0, HSMP_SET},
-
- /*
- * HSMP_GET_BOOST_LIMIT, num_args = 1, response_sz = 1
- * input: args[0] = apic id
- * output: args[0] = boost limit value in MHz
- */
- {1, 1, HSMP_GET},
-
- /*
- * HSMP_GET_PROC_HOT, num_args = 0, response_sz = 1
- * output: args[0] = proc hot status
- */
- {0, 1, HSMP_GET},
-
- /*
- * HSMP_SET_XGMI_LINK_WIDTH, num_args = 1, response_sz = 0
- * input: args[0] = min link width[15:8] + max link width[7:0]
- */
- {1, 0, HSMP_SET},
-
- /*
- * HSMP_SET_DF_PSTATE, num_args = 1, response_sz = 0
- * input: args[0] = df pstate[7:0]
- */
- {1, 0, HSMP_SET},
-
- /* HSMP_SET_AUTO_DF_PSTATE, num_args = 0, response_sz = 0 */
- {0, 0, HSMP_SET},
-
- /*
- * HSMP_GET_FCLK_MCLK, num_args = 0, response_sz = 2
- * output: args[0] = fclk in MHz, args[1] = mclk in MHz
- */
- {0, 2, HSMP_GET},
-
- /*
- * HSMP_GET_CCLK_THROTTLE_LIMIT, num_args = 0, response_sz = 1
- * output: args[0] = core clock in MHz
- */
- {0, 1, HSMP_GET},
-
- /*
- * HSMP_GET_C0_PERCENT, num_args = 0, response_sz = 1
- * output: args[0] = average c0 residency
- */
- {0, 1, HSMP_GET},
-
- /*
- * HSMP_SET_NBIO_DPM_LEVEL, num_args = 1, response_sz = 0
- * input: args[0] = nbioid[23:16] + max dpm level[15:8] + min dpm level[7:0]
- */
- {1, 0, HSMP_SET},
-
- /*
- * HSMP_GET_NBIO_DPM_LEVEL, num_args = 1, response_sz = 1
- * input: args[0] = nbioid[23:16]
- * output: args[0] = max dpm level[15:8] + min dpm level[7:0]
- */
- {1, 1, HSMP_GET},
-
- /*
- * HSMP_GET_DDR_BANDWIDTH, num_args = 0, response_sz = 1
- * output: args[0] = max bw in Gbps[31:20] + utilised bw in Gbps[19:8] +
- * bw in percentage[7:0]
- */
- {0, 1, HSMP_GET},
-
- /*
- * HSMP_GET_TEMP_MONITOR, num_args = 0, response_sz = 1
- * output: args[0] = temperature in degree celsius. [15:8] integer part +
- * [7:5] fractional part
- */
- {0, 1, HSMP_GET},
-
- /*
- * HSMP_GET_DIMM_TEMP_RANGE, num_args = 1, response_sz = 1
- * input: args[0] = DIMM address[7:0]
- * output: args[0] = refresh rate[3] + temperature range[2:0]
- */
- {1, 1, HSMP_GET},
-
- /*
- * HSMP_GET_DIMM_POWER, num_args = 1, response_sz = 1
- * input: args[0] = DIMM address[7:0]
- * output: args[0] = DIMM power in mW[31:17] + update rate in ms[16:8] +
- * DIMM address[7:0]
- */
- {1, 1, HSMP_GET},
-
- /*
- * HSMP_GET_DIMM_THERMAL, num_args = 1, response_sz = 1
- * input: args[0] = DIMM address[7:0]
- * output: args[0] = temperature in degree celsius[31:21] + update rate in ms[16:8] +
- * DIMM address[7:0]
- */
- {1, 1, HSMP_GET},
-
- /*
- * HSMP_GET_SOCKET_FREQ_LIMIT, num_args = 0, response_sz = 1
- * output: args[0] = frequency in MHz[31:16] + frequency source[15:0]
- */
- {0, 1, HSMP_GET},
-
- /*
- * HSMP_GET_CCLK_CORE_LIMIT, num_args = 1, response_sz = 1
- * input: args[0] = apic id [31:0]
- * output: args[0] = frequency in MHz[31:0]
- */
- {1, 1, HSMP_GET},
-
- /*
- * HSMP_GET_RAILS_SVI, num_args = 0, response_sz = 1
- * output: args[0] = power in mW[31:0]
- */
- {0, 1, HSMP_GET},
-
- /*
- * HSMP_GET_SOCKET_FMAX_FMIN, num_args = 0, response_sz = 1
- * output: args[0] = fmax in MHz[31:16] + fmin in MHz[15:0]
- */
- {0, 1, HSMP_GET},
-
- /*
- * HSMP_GET_IOLINK_BANDWITH, num_args = 1, response_sz = 1
- * input: args[0] = link id[15:8] + bw type[2:0]
- * output: args[0] = io bandwidth in Mbps[31:0]
- */
- {1, 1, HSMP_GET},
-
- /*
- * HSMP_GET_XGMI_BANDWITH, num_args = 1, response_sz = 1
- * input: args[0] = link id[15:8] + bw type[2:0]
- * output: args[0] = xgmi bandwidth in Mbps[31:0]
- */
- {1, 1, HSMP_GET},
-
- /*
- * HSMP_SET_GMI3_WIDTH, num_args = 1, response_sz = 0
- * input: args[0] = min link width[15:8] + max link width[7:0]
- */
- {1, 0, HSMP_SET},
-
- /*
- * HSMP_SET_PCI_RATE, num_args = 1, response_sz = 1
- * input: args[0] = link rate control value
- * output: args[0] = previous link rate control value
- */
- {1, 1, HSMP_SET},
-
- /*
- * HSMP_SET_POWER_MODE, num_args = 1, response_sz = 0
- * input: args[0] = power efficiency mode[2:0]
- */
- {1, 0, HSMP_SET},
-
- /*
- * HSMP_SET_PSTATE_MAX_MIN, num_args = 1, response_sz = 0
- * input: args[0] = min df pstate[15:8] + max df pstate[7:0]
- */
- {1, 0, HSMP_SET},
-
- /*
- * HSMP_GET_METRIC_TABLE_VER, num_args = 0, response_sz = 1
- * output: args[0] = metrics table version
- */
- {0, 1, HSMP_GET},
-
- /*
- * HSMP_GET_METRIC_TABLE, num_args = 0, response_sz = 0
- */
- {0, 0, HSMP_GET},
-
- /*
- * HSMP_GET_METRIC_TABLE_DRAM_ADDR, num_args = 0, response_sz = 2
- * output: args[0] = lower 32 bits of the address
- * output: args[1] = upper 32 bits of the address
- */
- {0, 2, HSMP_GET},
-};
-
/* Metrics table (supported only with proto version 6) */
struct hsmp_metric_table {
__u32 accumulation_counter;
diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c
index 82d8ba2e1204..5d21bc8b2fd7 100644
--- a/drivers/platform/x86/amd/hsmp/hsmp.c
+++ b/drivers/platform/x86/amd/hsmp/hsmp.c
@@ -37,6 +37,251 @@
static struct hsmp_plat_device hsmp_pdev;
+/*
+ * User may use these comments as reference, please find the
+ * supported list of messages and message definition in the
+ * HSMP chapter of respective family/model PPR.
+ *
+ * Not supported messages would return -ENOMSG.
+ */
+static const struct hsmp_msg_desc hsmp_msg_desc_table[] = {
+ /* RESERVED */
+ {0, 0, HSMP_RSVD},
+
+ /*
+ * HSMP_TEST, num_args = 1, response_sz = 1
+ * input: args[0] = xx
+ * output: args[0] = xx + 1
+ */
+ {1, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_SMU_VER, num_args = 0, response_sz = 1
+ * output: args[0] = smu fw ver
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_PROTO_VER, num_args = 0, response_sz = 1
+ * output: args[0] = proto version
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_SOCKET_POWER, num_args = 0, response_sz = 1
+ * output: args[0] = socket power in mWatts
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_SET_SOCKET_POWER_LIMIT, num_args = 1, response_sz = 0
+ * input: args[0] = power limit value in mWatts
+ */
+ {1, 0, HSMP_SET},
+
+ /*
+ * HSMP_GET_SOCKET_POWER_LIMIT, num_args = 0, response_sz = 1
+ * output: args[0] = socket power limit value in mWatts
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_SOCKET_POWER_LIMIT_MAX, num_args = 0, response_sz = 1
+ * output: args[0] = maximuam socket power limit in mWatts
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_SET_BOOST_LIMIT, num_args = 1, response_sz = 0
+ * input: args[0] = apic id[31:16] + boost limit value in MHz[15:0]
+ */
+ {1, 0, HSMP_SET},
+
+ /*
+ * HSMP_SET_BOOST_LIMIT_SOCKET, num_args = 1, response_sz = 0
+ * input: args[0] = boost limit value in MHz
+ */
+ {1, 0, HSMP_SET},
+
+ /*
+ * HSMP_GET_BOOST_LIMIT, num_args = 1, response_sz = 1
+ * input: args[0] = apic id
+ * output: args[0] = boost limit value in MHz
+ */
+ {1, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_PROC_HOT, num_args = 0, response_sz = 1
+ * output: args[0] = proc hot status
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_SET_XGMI_LINK_WIDTH, num_args = 1, response_sz = 0
+ * input: args[0] = min link width[15:8] + max link width[7:0]
+ */
+ {1, 0, HSMP_SET},
+
+ /*
+ * HSMP_SET_DF_PSTATE, num_args = 1, response_sz = 0
+ * input: args[0] = df pstate[7:0]
+ */
+ {1, 0, HSMP_SET},
+
+ /* HSMP_SET_AUTO_DF_PSTATE, num_args = 0, response_sz = 0 */
+ {0, 0, HSMP_SET},
+
+ /*
+ * HSMP_GET_FCLK_MCLK, num_args = 0, response_sz = 2
+ * output: args[0] = fclk in MHz, args[1] = mclk in MHz
+ */
+ {0, 2, HSMP_GET},
+
+ /*
+ * HSMP_GET_CCLK_THROTTLE_LIMIT, num_args = 0, response_sz = 1
+ * output: args[0] = core clock in MHz
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_C0_PERCENT, num_args = 0, response_sz = 1
+ * output: args[0] = average c0 residency
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_SET_NBIO_DPM_LEVEL, num_args = 1, response_sz = 0
+ * input: args[0] = nbioid[23:16] + max dpm level[15:8] + min dpm level[7:0]
+ */
+ {1, 0, HSMP_SET},
+
+ /*
+ * HSMP_GET_NBIO_DPM_LEVEL, num_args = 1, response_sz = 1
+ * input: args[0] = nbioid[23:16]
+ * output: args[0] = max dpm level[15:8] + min dpm level[7:0]
+ */
+ {1, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_DDR_BANDWIDTH, num_args = 0, response_sz = 1
+ * output: args[0] = max bw in Gbps[31:20] + utilised bw in Gbps[19:8] +
+ * bw in percentage[7:0]
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_TEMP_MONITOR, num_args = 0, response_sz = 1
+ * output: args[0] = temperature in degree celsius. [15:8] integer part +
+ * [7:5] fractional part
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_DIMM_TEMP_RANGE, num_args = 1, response_sz = 1
+ * input: args[0] = DIMM address[7:0]
+ * output: args[0] = refresh rate[3] + temperature range[2:0]
+ */
+ {1, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_DIMM_POWER, num_args = 1, response_sz = 1
+ * input: args[0] = DIMM address[7:0]
+ * output: args[0] = DIMM power in mW[31:17] + update rate in ms[16:8] +
+ * DIMM address[7:0]
+ */
+ {1, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_DIMM_THERMAL, num_args = 1, response_sz = 1
+ * input: args[0] = DIMM address[7:0]
+ * output: args[0] = temperature in degree celsius[31:21] + update rate in ms[16:8] +
+ * DIMM address[7:0]
+ */
+ {1, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_SOCKET_FREQ_LIMIT, num_args = 0, response_sz = 1
+ * output: args[0] = frequency in MHz[31:16] + frequency source[15:0]
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_CCLK_CORE_LIMIT, num_args = 1, response_sz = 1
+ * input: args[0] = apic id [31:0]
+ * output: args[0] = frequency in MHz[31:0]
+ */
+ {1, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_RAILS_SVI, num_args = 0, response_sz = 1
+ * output: args[0] = power in mW[31:0]
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_SOCKET_FMAX_FMIN, num_args = 0, response_sz = 1
+ * output: args[0] = fmax in MHz[31:16] + fmin in MHz[15:0]
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_IOLINK_BANDWITH, num_args = 1, response_sz = 1
+ * input: args[0] = link id[15:8] + bw type[2:0]
+ * output: args[0] = io bandwidth in Mbps[31:0]
+ */
+ {1, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_XGMI_BANDWITH, num_args = 1, response_sz = 1
+ * input: args[0] = link id[15:8] + bw type[2:0]
+ * output: args[0] = xgmi bandwidth in Mbps[31:0]
+ */
+ {1, 1, HSMP_GET},
+
+ /*
+ * HSMP_SET_GMI3_WIDTH, num_args = 1, response_sz = 0
+ * input: args[0] = min link width[15:8] + max link width[7:0]
+ */
+ {1, 0, HSMP_SET},
+
+ /*
+ * HSMP_SET_PCI_RATE, num_args = 1, response_sz = 1
+ * input: args[0] = link rate control value
+ * output: args[0] = previous link rate control value
+ */
+ {1, 1, HSMP_SET},
+
+ /*
+ * HSMP_SET_POWER_MODE, num_args = 1, response_sz = 0
+ * input: args[0] = power efficiency mode[2:0]
+ */
+ {1, 0, HSMP_SET},
+
+ /*
+ * HSMP_SET_PSTATE_MAX_MIN, num_args = 1, response_sz = 0
+ * input: args[0] = min df pstate[15:8] + max df pstate[7:0]
+ */
+ {1, 0, HSMP_SET},
+
+ /*
+ * HSMP_GET_METRIC_TABLE_VER, num_args = 0, response_sz = 1
+ * output: args[0] = metrics table version
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_METRIC_TABLE, num_args = 0, response_sz = 0
+ */
+ {0, 0, HSMP_GET},
+
+ /*
+ * HSMP_GET_METRIC_TABLE_DRAM_ADDR, num_args = 0, response_sz = 2
+ * output: args[0] = lower 32 bits of the address
+ * output: args[1] = upper 32 bits of the address
+ */
+ {0, 2, HSMP_GET},
+};
+
/*
* Send a message to the HSMP port via PCI-e config space registers
* or by writing to MMIO space.