drm/amdgpu/smu11: add a helper to set the power source
authorAlex Deucher <alexander.deucher@amd.com>
Fri, 20 Mar 2020 17:42:26 +0000 (13:42 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 25 Mar 2020 21:00:11 +0000 (17:00 -0400)
Add a common smu11 helper to set the AC/DC power source.

Bug: https://gitlab.freedesktop.org/drm/amd/issues/1043
Reviewed-by: Evan Quan <evan.quan@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
drivers/gpu/drm/amd/powerplay/smu_v11_0.c

index 1c88219fe403267ff2e5b89aca06f1ecf4bf28af..674e426ed59bbe1d056b2371fbf5777492604f27 100644 (file)
@@ -267,4 +267,7 @@ uint32_t smu_v11_0_get_max_power_limit(struct smu_context *smu);
 int smu_v11_0_set_performance_level(struct smu_context *smu,
                                    enum amd_dpm_forced_level level);
 
+int smu_v11_0_set_power_source(struct smu_context *smu,
+                              enum smu_power_src_type power_src);
+
 #endif
index 4fd77c7cfc806f25b18004857c0d659b718ba461..20174bed11ce43cf68eda2728fffef79ddb107c3 100644 (file)
@@ -1939,3 +1939,18 @@ int smu_v11_0_set_performance_level(struct smu_context *smu,
        return ret;
 }
 
+int smu_v11_0_set_power_source(struct smu_context *smu,
+                              enum smu_power_src_type power_src)
+{
+       int pwr_source;
+
+       pwr_source = smu_power_get_index(smu, (uint32_t)power_src);
+       if (pwr_source < 0)
+               return -EINVAL;
+
+       return smu_send_smc_msg_with_param(smu,
+                                       SMU_MSG_NotifyPowerSource,
+                                       pwr_source,
+                                       NULL);
+}
+