drm/radeon/rv7xx/eg: implement get_current_sclk/mclk
authorAlex Deucher <alexander.deucher@amd.com>
Tue, 30 Sep 2014 14:34:39 +0000 (10:34 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 19 Mar 2015 16:26:30 +0000 (12:26 -0400)
Will be used for exposing current clocks via INFO ioctl.

Tested-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/radeon_asic.c
drivers/gpu/drm/radeon/radeon_asic.h
drivers/gpu/drm/radeon/rv770_dpm.c

index 0e3f7d493c130bb5d1d2a706cc052e9f3200425e..0794cbd886b4648584fbe45d952e357b47ec9d4b 100644 (file)
@@ -1278,6 +1278,8 @@ static struct radeon_asic rv770_asic = {
                .debugfs_print_current_performance_level = &rv770_dpm_debugfs_print_current_performance_level,
                .force_performance_level = &rv770_dpm_force_performance_level,
                .vblank_too_short = &rv770_dpm_vblank_too_short,
+               .get_current_sclk = &rv770_dpm_get_current_sclk,
+               .get_current_mclk = &rv770_dpm_get_current_mclk,
        },
        .pflip = {
                .page_flip = &rv770_page_flip,
@@ -1395,6 +1397,8 @@ static struct radeon_asic evergreen_asic = {
                .debugfs_print_current_performance_level = &rv770_dpm_debugfs_print_current_performance_level,
                .force_performance_level = &rv770_dpm_force_performance_level,
                .vblank_too_short = &cypress_dpm_vblank_too_short,
+               .get_current_sclk = &rv770_dpm_get_current_sclk,
+               .get_current_mclk = &rv770_dpm_get_current_mclk,
        },
        .pflip = {
                .page_flip = &evergreen_page_flip,
index 7ae66c0b3bea0c2909a6a1e9a9bf93522a9c0a6f..ceac66ac79fd149ab2a0c68739e478e8021deab2 100644 (file)
@@ -492,6 +492,8 @@ void rv770_dpm_debugfs_print_current_performance_level(struct radeon_device *rde
 int rv770_dpm_force_performance_level(struct radeon_device *rdev,
                                      enum radeon_dpm_forced_level level);
 bool rv770_dpm_vblank_too_short(struct radeon_device *rdev);
+u32 rv770_dpm_get_current_sclk(struct radeon_device *rdev);
+u32 rv770_dpm_get_current_mclk(struct radeon_device *rdev);
 
 /*
  * evergreen
index 306732641b231aefb16ddc3186359ae872af5801..b9c770745a7a1f717cb9c894a6882c090fd8153c 100644 (file)
@@ -2492,6 +2492,50 @@ void rv770_dpm_debugfs_print_current_performance_level(struct radeon_device *rde
        }
 }
 
+u32 rv770_dpm_get_current_sclk(struct radeon_device *rdev)
+{
+       struct radeon_ps *rps = rdev->pm.dpm.current_ps;
+       struct rv7xx_ps *ps = rv770_get_ps(rps);
+       struct rv7xx_pl *pl;
+       u32 current_index =
+               (RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) & CURRENT_PROFILE_INDEX_MASK) >>
+               CURRENT_PROFILE_INDEX_SHIFT;
+
+       if (current_index > 2) {
+               return 0;
+       } else {
+               if (current_index == 0)
+                       pl = &ps->low;
+               else if (current_index == 1)
+                       pl = &ps->medium;
+               else /* current_index == 2 */
+                       pl = &ps->high;
+               return  pl->sclk;
+       }
+}
+
+u32 rv770_dpm_get_current_mclk(struct radeon_device *rdev)
+{
+       struct radeon_ps *rps = rdev->pm.dpm.current_ps;
+       struct rv7xx_ps *ps = rv770_get_ps(rps);
+       struct rv7xx_pl *pl;
+       u32 current_index =
+               (RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) & CURRENT_PROFILE_INDEX_MASK) >>
+               CURRENT_PROFILE_INDEX_SHIFT;
+
+       if (current_index > 2) {
+               return 0;
+       } else {
+               if (current_index == 0)
+                       pl = &ps->low;
+               else if (current_index == 1)
+                       pl = &ps->medium;
+               else /* current_index == 2 */
+                       pl = &ps->high;
+               return  pl->mclk;
+       }
+}
+
 void rv770_dpm_fini(struct radeon_device *rdev)
 {
        int i;