2 * Copyright 2018 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
25 #include "vega20_hwmgr.h"
26 #include "vega20_powertune.h"
27 #include "vega20_smumgr.h"
28 #include "vega20_ppsmc.h"
29 #include "vega20_inc.h"
32 int vega20_set_power_limit(struct pp_hwmgr
*hwmgr
, uint32_t n
)
34 struct vega20_hwmgr
*data
=
35 (struct vega20_hwmgr
*)(hwmgr
->backend
);
37 if (data
->smu_features
[GNLD_PPT
].enabled
)
38 return smum_send_msg_to_smc_with_parameter(hwmgr
,
39 PPSMC_MSG_SetPptLimit
, n
);
44 int vega20_validate_power_level_request(struct pp_hwmgr
*hwmgr
,
45 uint32_t tdp_percentage_adjustment
, uint32_t tdp_absolute_value_adjustment
)
47 return (tdp_percentage_adjustment
> hwmgr
->platform_descriptor
.TDPLimit
) ? -1 : 0;
50 static int vega20_set_overdrive_target_percentage(struct pp_hwmgr
*hwmgr
,
51 uint32_t adjust_percent
)
53 return smum_send_msg_to_smc_with_parameter(hwmgr
,
54 PPSMC_MSG_OverDriveSetPercentage
, adjust_percent
);
57 int vega20_power_control_set_level(struct pp_hwmgr
*hwmgr
)
59 int adjust_percent
, result
= 0;
61 if (PP_CAP(PHM_PlatformCaps_PowerContainment
)) {
63 hwmgr
->platform_descriptor
.TDPAdjustmentPolarity
?
64 hwmgr
->platform_descriptor
.TDPAdjustment
:
65 (-1 * hwmgr
->platform_descriptor
.TDPAdjustment
);
66 result
= vega20_set_overdrive_target_percentage(hwmgr
,
67 (uint32_t)adjust_percent
);