tools/power/x86/intel-speed-select: Abstract read_pm_config
authorZhang Rui <rui.zhang@intel.com>
Mon, 8 Aug 2022 15:19:55 +0000 (23:19 +0800)
committerSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Wed, 22 Mar 2023 20:36:52 +0000 (13:36 -0700)
Allow platform specific implementation to get SST-CP capability and
current state.

No functional changes are expected.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[srinivas.pandruvada@linux.intel.com: changelog edits]
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
tools/power/x86/intel-speed-select/isst-core-mbox.c
tools/power/x86/intel-speed-select/isst-core.c
tools/power/x86/intel-speed-select/isst.h

index ca43cfc..2169ced 100644 (file)
@@ -40,6 +40,24 @@ static int mbox_is_punit_valid(struct isst_id *id)
        return 1;
 }
 
+static int mbox_read_pm_config(struct isst_id *id, int *cp_state, int *cp_cap)
+{
+       unsigned int resp;
+       int ret;
+
+       ret = isst_send_mbox_command(id->cpu, READ_PM_CONFIG, PM_FEATURE, 0, 0,
+                                       &resp);
+       if (ret)
+               return ret;
+
+       debug_printf("cpu:%d READ_PM_CONFIG resp:%x\n", id->cpu, resp);
+
+       *cp_state = resp & BIT(16);
+       *cp_cap = resp & BIT(0) ? 1 : 0;
+
+       return 0;
+}
+
 static int mbox_get_config_levels(struct isst_id *id, struct isst_pkg_ctdp *pkg_dev)
 {
        unsigned int resp;
@@ -803,6 +821,7 @@ static struct isst_platform_ops mbox_ops = {
        .get_trl_max_levels = mbox_get_trl_max_levels,
        .get_trl_level_name = mbox_get_trl_level_name,
        .is_punit_valid = mbox_is_punit_valid,
+       .read_pm_config = mbox_read_pm_config,
        .get_config_levels = mbox_get_config_levels,
        .get_ctdp_control = mbox_get_ctdp_control,
        .get_tdp_info = mbox_get_tdp_info,
index 8ef71a8..c31ab8f 100644 (file)
@@ -249,20 +249,8 @@ int isst_send_msr_command(unsigned int cpu, unsigned int msr, int write,
 
 int isst_read_pm_config(struct isst_id *id, int *cp_state, int *cp_cap)
 {
-       unsigned int resp;
-       int ret;
-
-       ret = isst_send_mbox_command(id->cpu, READ_PM_CONFIG, PM_FEATURE, 0, 0,
-                                    &resp);
-       if (ret)
-               return ret;
-
-       debug_printf("cpu:%d READ_PM_CONFIG resp:%x\n", id->cpu, resp);
-
-       *cp_state = resp & BIT(16);
-       *cp_cap = resp & BIT(0) ? 1 : 0;
-
-       return 0;
+       CHECK_CB(read_pm_config);
+       return isst_ops->read_pm_config(id, cp_state, cp_cap);
 }
 
 int isst_get_ctdp_levels(struct isst_id *id, struct isst_pkg_ctdp *pkg_dev)
index 752991e..c64af51 100644 (file)
@@ -186,6 +186,7 @@ struct isst_platform_ops {
        int (*get_trl_max_levels)(void);
        char *(*get_trl_level_name)(int level);
        int (*is_punit_valid)(struct isst_id *id);
+       int (*read_pm_config)(struct isst_id *id, int *cp_state, int *cp_cap);
        int (*get_config_levels)(struct isst_id *id, struct isst_pkg_ctdp *pkg_ctdp);
        int (*get_ctdp_control)(struct isst_id *id, int config_index, struct isst_pkg_ctdp_level_info *ctdp_level);
        int (*get_tdp_info)(struct isst_id *id, int config_index, struct isst_pkg_ctdp_level_info *ctdp_level);