Hook up zero RPM enable for 9070 and 9070 XT based on RDNA3
(smu 13.0.0 and 13.0.7) code.

Signed-off-by: Tomasz Pakuła <tomasz.pakula.oficja...@gmail.com>
---
 .../drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c  | 55 ++++++++++++++++++-
 1 file changed, 54 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c 
b/drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c
index 21d1b34ada05..fedf0c8c4741 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c
@@ -79,6 +79,7 @@
 #define PP_OD_FEATURE_FAN_ACOUSTIC_TARGET              8
 #define PP_OD_FEATURE_FAN_TARGET_TEMPERATURE           9
 #define PP_OD_FEATURE_FAN_MINIMUM_PWM                  10
+#define PP_OD_FEATURE_FAN_ZERO_RPM_ENABLE              11
 
 static struct cmn2asic_msg_mapping smu_v14_0_2_message_map[SMU_MSG_MAX_COUNT] 
= {
        MSG_MAP(TestMessage,                    PPSMC_MSG_TestMessage,          
       1),
@@ -1052,6 +1053,10 @@ static void smu_v14_0_2_get_od_setting_limits(struct 
smu_context *smu,
                od_min_setting = overdrive_lowerlimits->FanMinimumPwm;
                od_max_setting = overdrive_upperlimits->FanMinimumPwm;
                break;
+       case PP_OD_FEATURE_FAN_ZERO_RPM_ENABLE:
+               od_min_setting = overdrive_lowerlimits->FanZeroRpmEnable;
+               od_max_setting = overdrive_upperlimits->FanZeroRpmEnable;
+               break;
        default:
                od_min_setting = od_max_setting = INT_MAX;
                break;
@@ -1337,6 +1342,24 @@ static int smu_v14_0_2_print_clk_levels(struct 
smu_context *smu,
                                      min_value, max_value);
                break;
 
+       case SMU_OD_FAN_ZERO_RPM_ENABLE:
+               if (!smu_v14_0_2_is_od_feature_supported(smu,
+                                                        
PP_OD_FEATURE_ZERO_FAN_BIT))
+                       break;
+
+               size += sysfs_emit_at(buf, size, "FAN_ZERO_RPM_ENABLE:\n");
+               size += sysfs_emit_at(buf, size, "%d\n",
+                               (int)od_table->OverDriveTable.FanZeroRpmEnable);
+
+               size += sysfs_emit_at(buf, size, "%s:\n", "OD_RANGE");
+               smu_v14_0_2_get_od_setting_limits(smu,
+                                                 
PP_OD_FEATURE_FAN_ZERO_RPM_ENABLE,
+                                                 &min_value,
+                                                 &max_value);
+               size += sysfs_emit_at(buf, size, "ZERO_RPM_ENABLE: %u %u\n",
+                                     min_value, max_value);
+               break;
+
        case SMU_OD_RANGE:
                if (!smu_v14_0_2_is_od_feature_supported(smu, 
PP_OD_FEATURE_GFXCLK_BIT) &&
                    !smu_v14_0_2_is_od_feature_supported(smu, 
PP_OD_FEATURE_UCLK_BIT) &&
@@ -2281,7 +2304,9 @@ static void 
smu_v14_0_2_set_supported_od_feature_mask(struct smu_context *smu)
                                            
OD_OPS_SUPPORT_FAN_TARGET_TEMPERATURE_RETRIEVE |
                                            
OD_OPS_SUPPORT_FAN_TARGET_TEMPERATURE_SET |
                                            
OD_OPS_SUPPORT_FAN_MINIMUM_PWM_RETRIEVE |
-                                           OD_OPS_SUPPORT_FAN_MINIMUM_PWM_SET;
+                                           OD_OPS_SUPPORT_FAN_MINIMUM_PWM_SET |
+                                           
OD_OPS_SUPPORT_FAN_ZERO_RPM_ENABLE_RETRIEVE |
+                                           
OD_OPS_SUPPORT_FAN_ZERO_RPM_ENABLE_SET;
 }
 
 static int smu_v14_0_2_get_overdrive_table(struct smu_context *smu,
@@ -2360,6 +2385,8 @@ static int smu_v14_0_2_set_default_od_settings(struct 
smu_context *smu)
                        user_od_table_bak.OverDriveTable.FanTargetTemperature;
                user_od_table->OverDriveTable.FanMinimumPwm =
                        user_od_table_bak.OverDriveTable.FanMinimumPwm;
+               user_od_table->OverDriveTable.FanZeroRpmEnable =
+                       user_od_table_bak.OverDriveTable.FanZeroRpmEnable;
        }
 
        smu_v14_0_2_set_supported_od_feature_mask(smu);
@@ -2407,6 +2434,11 @@ static int smu_v14_0_2_od_restore_table_single(struct 
smu_context *smu, long inp
                od_table->OverDriveTable.FanMode = FAN_MODE_AUTO;
                od_table->OverDriveTable.FeatureCtrlMask |= 
BIT(PP_OD_FEATURE_FAN_CURVE_BIT);
                break;
+       case PP_OD_EDIT_FAN_ZERO_RPM_ENABLE:
+               od_table->OverDriveTable.FanZeroRpmEnable =
+                                       
boot_overdrive_table->OverDriveTable.FanZeroRpmEnable;
+               od_table->OverDriveTable.FeatureCtrlMask |= 
BIT(PP_OD_FEATURE_ZERO_FAN_BIT);
+               break;
        case PP_OD_EDIT_ACOUSTIC_LIMIT:
                od_table->OverDriveTable.AcousticLimitRpmThreshold =
                                        
boot_overdrive_table->OverDriveTable.AcousticLimitRpmThreshold;
@@ -2701,6 +2733,27 @@ static int smu_v14_0_2_od_edit_dpm_table(struct 
smu_context *smu,
                od_table->OverDriveTable.FeatureCtrlMask |= 
BIT(PP_OD_FEATURE_FAN_CURVE_BIT);
                break;
 
+       case PP_OD_EDIT_FAN_ZERO_RPM_ENABLE:
+               if (!smu_v14_0_2_is_od_feature_supported(smu, 
PP_OD_FEATURE_ZERO_FAN_BIT)) {
+                       dev_warn(adev->dev, "Zero RPM setting not 
supported!\n");
+                       return -ENOTSUPP;
+               }
+
+               smu_v14_0_2_get_od_setting_limits(smu,
+                                                 
PP_OD_FEATURE_FAN_ZERO_RPM_ENABLE,
+                                                 &minimum,
+                                                 &maximum);
+               if (input[0] < minimum ||
+                   input[0] > maximum) {
+                       dev_info(adev->dev, "zero RPM enable setting(%ld) must 
be within [%d, %d]!\n",
+                                input[0], minimum, maximum);
+                       return -EINVAL;
+               }
+
+               od_table->OverDriveTable.FanZeroRpmEnable = input[0];
+               od_table->OverDriveTable.FeatureCtrlMask |= 
BIT(PP_OD_FEATURE_ZERO_FAN_BIT);
+               break;
+
        case PP_OD_RESTORE_DEFAULT_TABLE:
                if (size == 1) {
                        ret = smu_v14_0_2_od_restore_table_single(smu, 
input[0]);
-- 
2.48.1

Reply via email to