drm/amd/pm: correct Polaris powertune table setup
authorEvan Quan <evan.quan@amd.com>
Fri, 25 Sep 2020 05:02:40 +0000 (13:02 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 27 Oct 2020 15:59:10 +0000 (11:59 -0400)
Correct powertune table setup for Polaris.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/inc/hwmgr.h
drivers/gpu/drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h
drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c

index dad703b..0e4707a 100644 (file)
@@ -441,6 +441,7 @@ struct phm_cac_tdp_table {
        uint8_t  ucPlx_I2C_Line;
        uint32_t usBoostPowerLimit;
        uint8_t  ucCKS_LDO_REFSEL;
+       uint8_t  ucHotSpotOnly;
 };
 
 struct phm_tdp_table {
index 614f61a..b0ac4d1 100644 (file)
@@ -419,6 +419,42 @@ typedef struct _ATOM_Fiji_PowerTune_Table {
        USHORT usReserved;
 } ATOM_Fiji_PowerTune_Table;
 
+typedef struct _ATOM_Polaris_PowerTune_Table
+{
+    UCHAR  ucRevId;
+    USHORT usTDP;
+    USHORT usConfigurableTDP;
+    USHORT usTDC;
+    USHORT usBatteryPowerLimit;
+    USHORT usSmallPowerLimit;
+    USHORT usLowCACLeakage;
+    USHORT usHighCACLeakage;
+    USHORT usMaximumPowerDeliveryLimit;
+    USHORT usTjMax;  // For Fiji, this is also usTemperatureLimitEdge;
+    USHORT usPowerTuneDataSetID;
+    USHORT usEDCLimit;
+    USHORT usSoftwareShutdownTemp;
+    USHORT usClockStretchAmount;
+    USHORT usTemperatureLimitHotspot;  //The following are added for Fiji
+    USHORT usTemperatureLimitLiquid1;
+    USHORT usTemperatureLimitLiquid2;
+    USHORT usTemperatureLimitVrVddc;
+    USHORT usTemperatureLimitVrMvdd;
+    USHORT usTemperatureLimitPlx;
+    UCHAR  ucLiquid1_I2C_address;  //Liquid
+    UCHAR  ucLiquid2_I2C_address;
+    UCHAR  ucLiquid_I2C_Line;
+    UCHAR  ucVr_I2C_address;  //VR
+    UCHAR  ucVr_I2C_Line;
+    UCHAR  ucPlx_I2C_address;  //PLX
+    UCHAR  ucPlx_I2C_Line;
+    USHORT usBoostPowerLimit;
+    UCHAR  ucCKS_LDO_REFSEL;
+    UCHAR  ucHotSpotOnly;
+    UCHAR  ucReserve;
+    USHORT usReserve;
+} ATOM_Polaris_PowerTune_Table;
+
 #define ATOM_PPM_A_A    1
 #define ATOM_PPM_A_I    2
 typedef struct _ATOM_Tonga_PPM_Table {
index 4ed9f81..801a565 100644 (file)
@@ -613,7 +613,7 @@ static int get_cac_tdp_table(
                        le16_to_cpu(tonga_table->usSoftwareShutdownTemp);
                tdp_table->usClockStretchAmount =
                        le16_to_cpu(tonga_table->usClockStretchAmount);
-       } else {   /* Fiji and newer */
+       } else if (table->ucRevId < 4) {   /* Fiji and newer */
                const ATOM_Fiji_PowerTune_Table *fijitable =
                        (ATOM_Fiji_PowerTune_Table *)table;
                tdp_table->usTDP = le16_to_cpu(fijitable->usTDP);
@@ -657,6 +657,53 @@ static int get_cac_tdp_table(
                tdp_table->ucVr_I2C_Line = fijitable->ucVr_I2C_Line;
                tdp_table->ucPlx_I2C_address = fijitable->ucPlx_I2C_address;
                tdp_table->ucPlx_I2C_Line = fijitable->ucPlx_I2C_Line;
+       } else {
+               const ATOM_Polaris_PowerTune_Table *polaristable =
+                       (ATOM_Polaris_PowerTune_Table *)table;
+               tdp_table->usTDP = le16_to_cpu(polaristable->usTDP);
+               tdp_table->usConfigurableTDP = le16_to_cpu(polaristable->usConfigurableTDP);
+               tdp_table->usTDC = le16_to_cpu(polaristable->usTDC);
+               tdp_table->usBatteryPowerLimit = le16_to_cpu(polaristable->usBatteryPowerLimit);
+               tdp_table->usSmallPowerLimit = le16_to_cpu(polaristable->usSmallPowerLimit);
+               tdp_table->usLowCACLeakage = le16_to_cpu(polaristable->usLowCACLeakage);
+               tdp_table->usHighCACLeakage = le16_to_cpu(polaristable->usHighCACLeakage);
+               tdp_table->usMaximumPowerDeliveryLimit =
+                       le16_to_cpu(polaristable->usMaximumPowerDeliveryLimit);
+               tdp_table->usDefaultTargetOperatingTemp =
+                       le16_to_cpu(polaristable->usTjMax);
+               tdp_table->usTargetOperatingTemp =
+                       le16_to_cpu(polaristable->usTjMax); /*Set the initial temp to the same as default */
+               tdp_table->usPowerTuneDataSetID =
+                       le16_to_cpu(polaristable->usPowerTuneDataSetID);
+               tdp_table->usSoftwareShutdownTemp =
+                       le16_to_cpu(polaristable->usSoftwareShutdownTemp);
+               tdp_table->usClockStretchAmount =
+                       le16_to_cpu(polaristable->usClockStretchAmount);
+               tdp_table->usTemperatureLimitHotspot =
+                       le16_to_cpu(polaristable->usTemperatureLimitHotspot);
+               tdp_table->usTemperatureLimitLiquid1 =
+                       le16_to_cpu(polaristable->usTemperatureLimitLiquid1);
+               tdp_table->usTemperatureLimitLiquid2 =
+                       le16_to_cpu(polaristable->usTemperatureLimitLiquid2);
+               tdp_table->usTemperatureLimitVrVddc =
+                       le16_to_cpu(polaristable->usTemperatureLimitVrVddc);
+               tdp_table->usTemperatureLimitVrMvdd =
+                       le16_to_cpu(polaristable->usTemperatureLimitVrMvdd);
+               tdp_table->usTemperatureLimitPlx =
+                       le16_to_cpu(polaristable->usTemperatureLimitPlx);
+               tdp_table->ucLiquid1_I2C_address =
+                       polaristable->ucLiquid1_I2C_address;
+               tdp_table->ucLiquid2_I2C_address =
+                       polaristable->ucLiquid2_I2C_address;
+               tdp_table->ucLiquid_I2C_Line =
+                       polaristable->ucLiquid_I2C_Line;
+               tdp_table->ucVr_I2C_address = polaristable->ucVr_I2C_address;
+               tdp_table->ucVr_I2C_Line = polaristable->ucVr_I2C_Line;
+               tdp_table->ucPlx_I2C_address = polaristable->ucPlx_I2C_address;
+               tdp_table->ucPlx_I2C_Line = polaristable->ucPlx_I2C_Line;
+               tdp_table->usBoostPowerLimit = polaristable->usBoostPowerLimit;
+               tdp_table->ucCKS_LDO_REFSEL = polaristable->ucCKS_LDO_REFSEL;
+               tdp_table->ucHotSpotOnly = polaristable->ucHotSpotOnly;
        }
 
        *cac_tdp_table = tdp_table;