Skip to content

Commit 8362e86

Browse files
Shyam Sundar S Kij-intel
authored andcommitted
platform/x86/amd/pmf: Update sps power thermals according to the platform-profiles
Update power thermals according to the platform-profiles selected by the user. Co-developed-by: Patil Rajesh Reddy <[email protected]> Signed-off-by: Patil Rajesh Reddy <[email protected]> Signed-off-by: Shyam Sundar S K <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent 3eecb43 commit 8362e86

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

drivers/platform/x86/amd/pmf/pmf.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ struct cookie_header {
5555
#define GET_STT_LIMIT_APU 0x20
5656
#define GET_STT_LIMIT_HS2 0x21
5757
#define SET_P3T 0x23 /* P3T: Peak Package Power Limit */
58+
#define SET_PMF_PPT 0x25
59+
#define SET_PMF_PPT_APU_ONLY 0x26
5860

5961
/* OS slider update notification */
6062
#define DC_BEST_PERF 0

drivers/platform/x86/amd/pmf/sps.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,19 @@ static void amd_pmf_load_defaults_sps(struct amd_pmf_dev *dev)
190190
amd_pmf_dump_sps_defaults(&config_store);
191191
}
192192

193+
static void amd_pmf_update_slider_v2(struct amd_pmf_dev *dev, int idx)
194+
{
195+
amd_pmf_send_cmd(dev, SET_PMF_PPT, false, apts_config_store.val[idx].pmf_ppt, NULL);
196+
amd_pmf_send_cmd(dev, SET_PMF_PPT_APU_ONLY, false,
197+
apts_config_store.val[idx].ppt_pmf_apu_only, NULL);
198+
amd_pmf_send_cmd(dev, SET_STT_MIN_LIMIT, false,
199+
apts_config_store.val[idx].stt_min_limit, NULL);
200+
amd_pmf_send_cmd(dev, SET_STT_LIMIT_APU, false,
201+
apts_config_store.val[idx].stt_skin_temp_limit_apu, NULL);
202+
amd_pmf_send_cmd(dev, SET_STT_LIMIT_HS2, false,
203+
apts_config_store.val[idx].stt_skin_temp_limit_hs2, NULL);
204+
}
205+
193206
void amd_pmf_update_slider(struct amd_pmf_dev *dev, bool op, int idx,
194207
struct amd_pmf_static_slider_granular *table)
195208
{
@@ -222,6 +235,32 @@ void amd_pmf_update_slider(struct amd_pmf_dev *dev, bool op, int idx,
222235
}
223236
}
224237

238+
static int amd_pmf_update_sps_power_limits_v2(struct amd_pmf_dev *pdev, int pwr_mode)
239+
{
240+
int src, index;
241+
242+
src = amd_pmf_get_power_source();
243+
244+
switch (pwr_mode) {
245+
case POWER_MODE_PERFORMANCE:
246+
index = config_store_v2.sps_idx.power_states[src][POWER_MODE_BEST_PERFORMANCE];
247+
amd_pmf_update_slider_v2(pdev, index);
248+
break;
249+
case POWER_MODE_BALANCED_POWER:
250+
index = config_store_v2.sps_idx.power_states[src][POWER_MODE_BALANCED];
251+
amd_pmf_update_slider_v2(pdev, index);
252+
break;
253+
case POWER_MODE_POWER_SAVER:
254+
index = config_store_v2.sps_idx.power_states[src][POWER_MODE_BEST_POWER_EFFICIENCY];
255+
amd_pmf_update_slider_v2(pdev, index);
256+
break;
257+
default:
258+
return -EINVAL;
259+
}
260+
261+
return 0;
262+
}
263+
225264
int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf)
226265
{
227266
int mode;
@@ -230,6 +269,9 @@ int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf)
230269
if (mode < 0)
231270
return mode;
232271

272+
if (pmf->pmf_if_version == PMF_IF_V2)
273+
return amd_pmf_update_sps_power_limits_v2(pmf, mode);
274+
233275
amd_pmf_update_slider(pmf, SLIDER_OP_SET, mode, NULL);
234276

235277
return 0;

0 commit comments

Comments
 (0)