Update power thermals according to the platform-profiles selected by the user. Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@xxxxxxx> Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@xxxxxxx> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@xxxxxxx> --- drivers/platform/x86/amd/pmf/pmf.h | 2 ++ drivers/platform/x86/amd/pmf/sps.c | 54 ++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index f99805827510..09600b612964 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -51,6 +51,8 @@ #define GET_STT_LIMIT_APU 0x20 #define GET_STT_LIMIT_HS2 0x21 #define SET_P3T 0x23 /* P3T: Peak Package Power Limit */ +#define SET_PMF_PPT 0x25 +#define SET_PMF_PPT_APU_ONLY 0x26 /* OS slider update notification */ #define DC_BEST_PERF 0 diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index 067fabdaa503..1ae06a4743a8 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -177,6 +177,19 @@ static void amd_pmf_load_defaults_sps(struct amd_pmf_dev *dev) amd_pmf_dump_sps_defaults(&config_store); } +static void amd_pmf_update_slider_v2(struct amd_pmf_dev *dev, int idx) +{ + amd_pmf_send_cmd(dev, SET_PMF_PPT, false, apts_config_store.val[idx].pmf_ppt, NULL); + amd_pmf_send_cmd(dev, SET_PMF_PPT_APU_ONLY, false, + apts_config_store.val[idx].ppt_pmf_apu_only, NULL); + amd_pmf_send_cmd(dev, SET_STT_MIN_LIMIT, false, + apts_config_store.val[idx].stt_min_limit, NULL); + amd_pmf_send_cmd(dev, SET_STT_LIMIT_APU, false, + apts_config_store.val[idx].stt_skin_temp_limit_apu, NULL); + amd_pmf_send_cmd(dev, SET_STT_LIMIT_HS2, false, + apts_config_store.val[idx].stt_skin_temp_limit_hs2, NULL); +} + void amd_pmf_update_slider(struct amd_pmf_dev *dev, bool op, int idx, struct amd_pmf_static_slider_granular *table) { @@ -209,6 +222,44 @@ void amd_pmf_update_slider(struct amd_pmf_dev *dev, bool op, int idx, } } +static int amd_pmf_update_sps_power_limits_v2(struct amd_pmf_dev *pdev, int pwr_mode) +{ + int src = amd_pmf_get_power_source(); + + if (src == POWER_SOURCE_AC) { + switch (pwr_mode) { + case POWER_MODE_PERFORMANCE: + amd_pmf_update_slider_v2(pdev, config_store_v2.sps_idx.ac_best_perf); + break; + case POWER_MODE_BALANCED_POWER: + amd_pmf_update_slider_v2(pdev, config_store_v2.sps_idx.ac_balanced); + break; + case POWER_MODE_POWER_SAVER: + amd_pmf_update_slider_v2(pdev, + config_store_v2.sps_idx.ac_best_pwr_efficiency); + break; + default: + return -EINVAL; + } + } else if (src == POWER_SOURCE_DC) { + switch (pwr_mode) { + case POWER_MODE_PERFORMANCE: + amd_pmf_update_slider_v2(pdev, config_store_v2.sps_idx.dc_best_perf); + break; + case POWER_MODE_BALANCED_POWER: + amd_pmf_update_slider_v2(pdev, config_store_v2.sps_idx.dc_balanced); + break; + case POWER_MODE_POWER_SAVER: + amd_pmf_update_slider_v2(pdev, + config_store_v2.sps_idx.dc_best_pwr_efficiency); + break; + default: + return -EINVAL; + } + } + return 0; +} + int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf) { int mode; @@ -217,6 +268,9 @@ int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf) if (mode < 0) return mode; + if (pmf->pmf_if_version == PMF_IF_V2) + return amd_pmf_update_sps_power_limits_v2(pmf, mode); + amd_pmf_update_slider(pmf, SLIDER_OP_SET, mode, NULL); return 0; -- 2.25.1