From: Kevin Wang <kevin1.w...@amd.com>

This patch implements get_current_clk_freq for smu11 future use.

Signed-off-by: Kevin Wang <kevin1.w...@amd.com>
Reviewed-by: Huang Rui <ray.hu...@amd.com>
---
 drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h |  3 +++
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c      | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h 
b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
index db3d0f57..bdd930d 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
@@ -251,6 +251,7 @@ struct smu_funcs
        int (*disable_all_mask)(struct smu_context *smu);
        int (*notify_display_change)(struct smu_context *smu);
        int (*get_power_limit)(struct smu_context *smu);
+       int (*get_current_clk_freq)(struct smu_context *smu, uint32_t clk_id, 
uint32_t *value);
 };
 
 #define smu_init_microcode(smu) \
@@ -327,6 +328,8 @@ struct smu_funcs
        ((smu)->ppt_funcs->populate_umd_state_clk ? 
(smu)->ppt_funcs->populate_umd_state_clk((smu)) : 0)
 #define smu_get_power_limit(smu) \
        ((smu)->funcs->get_power_limit? (smu)->funcs->get_power_limit((smu)) : 
0)
+#define smu_get_current_clk_freq(smu, clk_id, value) \
+       ((smu)->funcs->get_current_clk_freq? 
(smu)->funcs->get_current_clk_freq((smu), (clk_id), (value)) : 0)
 
 #define smu_msg_get_index(smu, msg) \
        ((smu)->ppt_funcs? ((smu)->ppt_funcs->get_smu_msg_index? 
(smu)->ppt_funcs->get_smu_msg_index((smu), (msg)) : -EINVAL) : -EINVAL)
diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c 
b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
index 4919867..def64f5 100644
--- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
+++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
@@ -757,6 +757,29 @@ static int smu_v11_0_get_power_limit(struct smu_context 
*smu)
        return 0;
 }
 
+static int smu_v11_0_get_current_clk_freq(struct smu_context *smu, uint32_t 
clk_id, uint32_t *value)
+{
+       int ret = 0;
+       uint32_t freq;
+
+       if (clk_id >= PPCLK_COUNT || !value)
+               return -EINVAL;
+
+       ret = smu_send_smc_msg_with_param(smu,
+                       SMU_MSG_GetDpmClockFreq, (clk_id << 16));
+       if (ret)
+               return ret;
+
+       ret = smu_read_smc_arg(smu, &freq);
+       if (ret)
+               return ret;
+
+       freq *= 100;
+       *value = freq;
+
+       return ret;
+}
+
 static const struct smu_funcs smu_v11_0_funcs = {
        .init_microcode = smu_v11_0_init_microcode,
        .load_microcode = smu_v11_0_load_microcode,
@@ -786,6 +809,7 @@ static const struct smu_funcs smu_v11_0_funcs = {
        .disable_all_mask = smu_v11_0_disable_all_mask,
        .notify_display_change = smu_v11_0_notify_display_change,
        .get_power_limit = smu_v11_0_get_power_limit,
+       .get_current_clk_freq = smu_v11_0_get_current_clk_freq,
 };
 
 void smu_v11_0_set_smu_funcs(struct smu_context *smu)
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to