tools/power/x86/intel-speed-select: Abstract get_ctdp_control

Allow platform specific implementation to get SST-TF/BF/CP capabilities
and status.

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>
This commit is contained in:
Zhang Rui 2022-08-08 20:28:06 +08:00 committed by Srinivas Pandruvada
parent 724387448a
commit bbe32d8752
3 changed files with 39 additions and 30 deletions

View file

@ -67,12 +67,48 @@ static int mbox_get_config_levels(struct isst_id *id, struct isst_pkg_ctdp *pkg_
return 0;
}
static int mbox_get_ctdp_control(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level)
{
int cp_state, cp_cap;
unsigned int resp;
int ret;
ret = isst_send_mbox_command(id->cpu, CONFIG_TDP,
CONFIG_TDP_GET_TDP_CONTROL, 0,
config_index, &resp);
if (ret)
return ret;
ctdp_level->fact_support = resp & BIT(0);
ctdp_level->pbf_support = !!(resp & BIT(1));
ctdp_level->fact_enabled = !!(resp & BIT(16));
ctdp_level->pbf_enabled = !!(resp & BIT(17));
ret = isst_read_pm_config(id, &cp_state, &cp_cap);
if (ret) {
debug_printf("cpu:%d pm_config is not supported\n", id->cpu);
} else {
debug_printf("cpu:%d pm_config SST-CP state:%d cap:%d\n", id->cpu, cp_state, cp_cap);
ctdp_level->sst_cp_support = cp_cap;
ctdp_level->sst_cp_enabled = cp_state;
}
debug_printf(
"cpu:%d CONFIG_TDP_GET_TDP_CONTROL resp:%x fact_support:%d pbf_support: %d fact_enabled:%d pbf_enabled:%d\n",
id->cpu, resp, ctdp_level->fact_support, ctdp_level->pbf_support,
ctdp_level->fact_enabled, ctdp_level->pbf_enabled);
return 0;
}
static struct isst_platform_ops mbox_ops = {
.get_disp_freq_multiplier = mbox_get_disp_freq_multiplier,
.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,
.get_config_levels = mbox_get_config_levels,
.get_ctdp_control = mbox_get_ctdp_control,
};
struct isst_platform_ops *mbox_get_platform_ops(void)

View file

@ -294,36 +294,8 @@ int isst_get_ctdp_levels(struct isst_id *id, struct isst_pkg_ctdp *pkg_dev)
int isst_get_ctdp_control(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level)
{
int cp_state, cp_cap;
unsigned int resp;
int ret;
ret = isst_send_mbox_command(id->cpu, CONFIG_TDP,
CONFIG_TDP_GET_TDP_CONTROL, 0,
config_index, &resp);
if (ret)
return ret;
ctdp_level->fact_support = resp & BIT(0);
ctdp_level->pbf_support = !!(resp & BIT(1));
ctdp_level->fact_enabled = !!(resp & BIT(16));
ctdp_level->pbf_enabled = !!(resp & BIT(17));
ret = isst_read_pm_config(id, &cp_state, &cp_cap);
if (ret) {
debug_printf("cpu:%d pm_config is not supported\n", id->cpu);
} else {
debug_printf("cpu:%d pm_config SST-CP state:%d cap:%d\n", id->cpu, cp_state, cp_cap);
ctdp_level->sst_cp_support = cp_cap;
ctdp_level->sst_cp_enabled = cp_state;
}
debug_printf(
"cpu:%d CONFIG_TDP_GET_TDP_CONTROL resp:%x fact_support:%d pbf_support: %d fact_enabled:%d pbf_enabled:%d\n",
id->cpu, resp, ctdp_level->fact_support, ctdp_level->pbf_support,
ctdp_level->fact_enabled, ctdp_level->pbf_enabled);
return 0;
CHECK_CB(get_ctdp_control);
return isst_ops->get_ctdp_control(id, config_index, ctdp_level);
}
int isst_get_tdp_info(struct isst_id *id, int config_index,

View file

@ -187,6 +187,7 @@ struct isst_platform_ops {
char *(*get_trl_level_name)(int level);
int (*is_punit_valid)(struct isst_id *id);
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);
};
extern int is_cpu_in_power_domain(int cpu, struct isst_id *id);