Commit 18973c6e authored by Evan Quan's avatar Evan Quan Committed by Alex Deucher
Browse files

drm/amd/powerplay: separate Polaris fan table setup from Tonga



Instead of sharing the fan table setup with Tonga, Polaris has
its own fan table setup.

Signed-off-by: default avatarEvan Quan <evan.quan@amd.com>
Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 8c23cc29
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -315,6 +315,36 @@ typedef struct _ATOM_Fiji_Fan_Table {
	USHORT  usReserved;
} ATOM_Fiji_Fan_Table;

typedef struct _ATOM_Polaris_Fan_Table {
	UCHAR   ucRevId;						 /* Change this if the table format changes or version changes so that the other fields are not the same. */
	UCHAR   ucTHyst;						 /* Temperature hysteresis. Integer. */
	USHORT  usTMin; 						 /* The temperature, in 0.01 centigrades, below which we just run at a minimal PWM. */
	USHORT  usTMed; 						 /* The middle temperature where we change slopes. */
	USHORT  usTHigh;						 /* The high point above TMed for adjusting the second slope. */
	USHORT  usPWMMin;						 /* The minimum PWM value in percent (0.01% increments). */
	USHORT  usPWMMed;						 /* The PWM value (in percent) at TMed. */
	USHORT  usPWMHigh;						 /* The PWM value at THigh. */
	USHORT  usTMax; 						 /* The max temperature */
	UCHAR   ucFanControlMode;				  /* Legacy or Fuzzy Fan mode */
	USHORT  usFanPWMMax;					  /* Maximum allowed fan power in percent */
	USHORT  usFanOutputSensitivity;		  /* Sensitivity of fan reaction to temepature changes */
	USHORT  usFanRPMMax;					  /* The default value in RPM */
	ULONG  ulMinFanSCLKAcousticLimit;		/* Minimum Fan Controller SCLK Frequency Acoustic Limit. */
	UCHAR   ucTargetTemperature;			 /* Advanced fan controller target temperature. */
	UCHAR   ucMinimumPWMLimit; 			  /* The minimum PWM that the advanced fan controller can set.	This should be set to the highest PWM that will run the fan at its lowest RPM. */
	USHORT  usFanGainEdge;
	USHORT  usFanGainHotspot;
	USHORT  usFanGainLiquid;
	USHORT  usFanGainVrVddc;
	USHORT  usFanGainVrMvdd;
	USHORT  usFanGainPlx;
	USHORT  usFanGainHbm;
	UCHAR   ucEnableZeroRPM;
	UCHAR   ucFanStopTemperature;
	UCHAR   ucFanStartTemperature;
	USHORT  usReserved;
} ATOM_Polaris_Fan_Table;

typedef struct _ATOM_Tonga_Thermal_Controller {
	UCHAR ucRevId;
	UCHAR ucType;		   /* one of ATOM_TONGA_PP_THERMALCONTROLLER_* */
+57 −1
Original line number Diff line number Diff line
@@ -949,7 +949,7 @@ static int init_thermal_controller(
			= tonga_fan_table->ucTargetTemperature;
		hwmgr->thermal_controller.advanceFanControlParameters.ucMinimumPWMLimit
			= tonga_fan_table->ucMinimumPWMLimit;
	} else {
	} else if (fan_table->ucRevId == 8) {
		const ATOM_Fiji_Fan_Table *fiji_fan_table =
			(ATOM_Fiji_Fan_Table *)fan_table;
		hwmgr->thermal_controller.advanceFanControlParameters.ucTHyst
@@ -999,6 +999,62 @@ static int init_thermal_controller(
			= le16_to_cpu(fiji_fan_table->usFanGainPlx);
		hwmgr->thermal_controller.advanceFanControlParameters.usFanGainHbm
			= le16_to_cpu(fiji_fan_table->usFanGainHbm);
	} else if (fan_table->ucRevId >= 9) {
		const ATOM_Polaris_Fan_Table *polaris_fan_table =
			(ATOM_Polaris_Fan_Table *)fan_table;
		hwmgr->thermal_controller.advanceFanControlParameters.ucTHyst
			= polaris_fan_table->ucTHyst;
		hwmgr->thermal_controller.advanceFanControlParameters.usTMin
			= le16_to_cpu(polaris_fan_table->usTMin);
		hwmgr->thermal_controller.advanceFanControlParameters.usTMed
			= le16_to_cpu(polaris_fan_table->usTMed);
		hwmgr->thermal_controller.advanceFanControlParameters.usTHigh
			= le16_to_cpu(polaris_fan_table->usTHigh);
		hwmgr->thermal_controller.advanceFanControlParameters.usPWMMin
			= le16_to_cpu(polaris_fan_table->usPWMMin);
		hwmgr->thermal_controller.advanceFanControlParameters.usPWMMed
			= le16_to_cpu(polaris_fan_table->usPWMMed);
		hwmgr->thermal_controller.advanceFanControlParameters.usPWMHigh
			= le16_to_cpu(polaris_fan_table->usPWMHigh);
		hwmgr->thermal_controller.advanceFanControlParameters.usTMax
			= le16_to_cpu(polaris_fan_table->usTMax);
		hwmgr->thermal_controller.advanceFanControlParameters.ucFanControlMode
			= polaris_fan_table->ucFanControlMode;
		hwmgr->thermal_controller.advanceFanControlParameters.usDefaultMaxFanPWM
			= le16_to_cpu(polaris_fan_table->usFanPWMMax);
		hwmgr->thermal_controller.advanceFanControlParameters.usDefaultFanOutputSensitivity
			= 4836;
		hwmgr->thermal_controller.advanceFanControlParameters.usFanOutputSensitivity
			= le16_to_cpu(polaris_fan_table->usFanOutputSensitivity);
		hwmgr->thermal_controller.advanceFanControlParameters.usDefaultMaxFanRPM
			= le16_to_cpu(polaris_fan_table->usFanRPMMax);
		hwmgr->thermal_controller.advanceFanControlParameters.ulMinFanSCLKAcousticLimit
			= (le32_to_cpu(polaris_fan_table->ulMinFanSCLKAcousticLimit) / 100); /* PPTable stores it in 10Khz unit for 2 decimal places.  SMC wants MHz. */
		hwmgr->thermal_controller.advanceFanControlParameters.ucTargetTemperature
			= polaris_fan_table->ucTargetTemperature;
		hwmgr->thermal_controller.advanceFanControlParameters.ucMinimumPWMLimit
			= polaris_fan_table->ucMinimumPWMLimit;

		hwmgr->thermal_controller.advanceFanControlParameters.usFanGainEdge
			= le16_to_cpu(polaris_fan_table->usFanGainEdge);
		hwmgr->thermal_controller.advanceFanControlParameters.usFanGainHotspot
			= le16_to_cpu(polaris_fan_table->usFanGainHotspot);
		hwmgr->thermal_controller.advanceFanControlParameters.usFanGainLiquid
			= le16_to_cpu(polaris_fan_table->usFanGainLiquid);
		hwmgr->thermal_controller.advanceFanControlParameters.usFanGainVrVddc
			= le16_to_cpu(polaris_fan_table->usFanGainVrVddc);
		hwmgr->thermal_controller.advanceFanControlParameters.usFanGainVrMvdd
			= le16_to_cpu(polaris_fan_table->usFanGainVrMvdd);
		hwmgr->thermal_controller.advanceFanControlParameters.usFanGainPlx
			= le16_to_cpu(polaris_fan_table->usFanGainPlx);
		hwmgr->thermal_controller.advanceFanControlParameters.usFanGainHbm
			= le16_to_cpu(polaris_fan_table->usFanGainHbm);
		hwmgr->thermal_controller.advanceFanControlParameters.ucEnableZeroRPM
			= le16_to_cpu(polaris_fan_table->ucEnableZeroRPM);
		hwmgr->thermal_controller.advanceFanControlParameters.ucFanStopTemperature
			= le16_to_cpu(polaris_fan_table->ucFanStopTemperature);
		hwmgr->thermal_controller.advanceFanControlParameters.ucFanStartTemperature
			= le16_to_cpu(polaris_fan_table->ucFanStartTemperature);
	}

	return 0;