drm/amd/powerplay: add function avfs control in smu7
authorEric Huang <JinHuiEric.Huang@amd.com>
Wed, 1 Mar 2017 20:56:17 +0000 (15:56 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 30 Mar 2017 03:53:28 +0000 (23:53 -0400)
Signed-off-by: Eric Huang <JinHuiEric.Huang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c

index 320c705f225582af8d3c68f781259e2752015a39..9997ecc2ecc09b081927db56c50fb87402931d71 100644 (file)
@@ -4619,6 +4619,25 @@ static int smu7_set_power_profile_state(struct pp_hwmgr *hwmgr,
        return result;
 }
 
+static int smu7_avfs_control(struct pp_hwmgr *hwmgr, bool enable)
+{
+       if (enable) {
+               if (!PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device,
+                               CGS_IND_REG__SMC, FEATURE_STATUS, AVS_ON))
+                       PP_ASSERT_WITH_CODE(!smum_send_msg_to_smc(
+                                       hwmgr->smumgr, PPSMC_MSG_EnableAvfs),
+                                       "Failed to enable AVFS!",
+                                       return -EINVAL);
+       } else if (PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device,
+                       CGS_IND_REG__SMC, FEATURE_STATUS, AVS_ON))
+               PP_ASSERT_WITH_CODE(!smum_send_msg_to_smc(
+                               hwmgr->smumgr, PPSMC_MSG_DisableAvfs),
+                               "Failed to disable AVFS!",
+                               return -EINVAL);
+
+       return 0;
+}
+
 static const struct pp_hwmgr_func smu7_hwmgr_funcs = {
        .backend_init = &smu7_hwmgr_backend_init,
        .backend_fini = &smu7_hwmgr_backend_fini,
@@ -4669,6 +4688,7 @@ static const struct pp_hwmgr_func smu7_hwmgr_funcs = {
        .request_firmware = smu7_request_firmware,
        .release_firmware = smu7_release_firmware,
        .set_power_profile_state = smu7_set_power_profile_state,
+       .avfs_control = smu7_avfs_control,
 };
 
 uint8_t smu7_get_sleep_divider_id_from_clock(uint32_t clock,