drm/radeon/dpm: add thermal dpm support for CI
authorAlex Deucher <alexander.deucher@amd.com>
Mon, 15 Sep 2014 06:15:04 +0000 (02:15 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 20 Nov 2014 18:00:10 +0000 (13:00 -0500)
Not currently used.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/ci_dpm.c
drivers/gpu/drm/radeon/ci_dpm.h
drivers/gpu/drm/radeon/ppsmc.h

index 4581d6cf90e856b96e8af103fc6ebe467b9d36d2..83121403ce3b0e2f6001a8dda77c06d5096d66ce 100644 (file)
@@ -714,6 +714,25 @@ static int ci_enable_smc_cac(struct radeon_device *rdev, bool enable)
        return ret;
 }
 
+static int ci_enable_thermal_based_sclk_dpm(struct radeon_device *rdev,
+                                           bool enable)
+{
+       struct ci_power_info *pi = ci_get_pi(rdev);
+       PPSMC_Result smc_result = PPSMC_Result_OK;
+
+       if (pi->thermal_sclk_dpm_enabled) {
+               if (enable)
+                       smc_result = ci_send_msg_to_smc(rdev, PPSMC_MSG_ENABLE_THERMAL_DPM);
+               else
+                       smc_result = ci_send_msg_to_smc(rdev, PPSMC_MSG_DISABLE_THERMAL_DPM);
+       }
+
+       if (smc_result == PPSMC_Result_OK)
+               return 0;
+       else
+               return -EINVAL;
+}
+
 static int ci_power_control_set_level(struct radeon_device *rdev)
 {
        struct ci_power_info *pi = ci_get_pi(rdev);
@@ -5177,6 +5196,12 @@ int ci_dpm_enable(struct radeon_device *rdev)
 
        ci_enable_auto_throttle_source(rdev, RADEON_DPM_AUTO_THROTTLE_SRC_THERMAL, true);
 
+       ret = ci_enable_thermal_based_sclk_dpm(rdev, true);
+       if (ret) {
+               DRM_ERROR("ci_enable_thermal_based_sclk_dpm failed\n");
+               return ret;
+       }
+
        ci_thermal_start_thermal_controller(rdev);
 
        ci_update_current_ps(rdev, boot_ps);
@@ -5240,6 +5265,7 @@ void ci_dpm_disable(struct radeon_device *rdev)
        ci_reset_to_default(rdev);
        ci_dpm_stop_smc(rdev);
        ci_force_switch_to_arb_f0(rdev);
+       ci_enable_thermal_based_sclk_dpm(rdev, false);
 
        ci_update_current_ps(rdev, boot_ps);
 }
@@ -5639,6 +5665,7 @@ int ci_dpm_init(struct radeon_device *rdev)
        pi->sclk_dpm_key_disabled = 0;
        pi->mclk_dpm_key_disabled = 0;
        pi->pcie_dpm_key_disabled = 0;
+       pi->thermal_sclk_dpm_enabled = 0;
 
        /* mclk dpm is unstable on some R7 260X cards with the old mc ucode */
        if ((rdev->pdev->device == 0x6658) &&
index bb19fbf3ab8ad8e5decc705e970de7c95f9ec5d2..84e3d3bcf9f327a6a0f410d951ce841090bf9bb0 100644 (file)
@@ -239,6 +239,7 @@ struct ci_power_info {
        u32 sclk_dpm_key_disabled;
        u32 mclk_dpm_key_disabled;
        u32 pcie_dpm_key_disabled;
+       u32 thermal_sclk_dpm_enabled;
        struct ci_pcie_perf_range pcie_gen_performance;
        struct ci_pcie_perf_range pcie_lane_performance;
        struct ci_pcie_perf_range pcie_gen_powersaving;
index ff698b05bdf5d25901f63dac69e91589714e15d8..7e5724a12f8b0d067445df96c15f14ba47cdc152 100644 (file)
@@ -162,6 +162,9 @@ typedef uint8_t PPSMC_Result;
 #define PPSMC_MSG_Remove_DC_Clamp             ((uint16_t) 0x191)
 #define PPSMC_MSG_SetFanPwmMax                ((uint16_t) 0x19A)
 
+#define PPSMC_MSG_ENABLE_THERMAL_DPM          ((uint16_t) 0x19C)
+#define PPSMC_MSG_DISABLE_THERMAL_DPM         ((uint16_t) 0x19D)
+
 #define PPSMC_MSG_API_GetSclkFrequency        ((uint16_t) 0x200)
 #define PPSMC_MSG_API_GetMclkFrequency        ((uint16_t) 0x201)