<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:15pt;" align="Left">
[AMD Official Use Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<comments inline></div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Lazar, Lijo <Lijo.Lazar@amd.com><br>
<b>Sent:</b> Thursday, July 15, 2021 3:47 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Zhang, Hawking <Hawking.Zhang@amd.com>; Wang, Kevin(Yang) <Kevin1.Wang@amd.com>; Feng, Kenneth <Kenneth.Feng@amd.com>; Quan, Evan <Evan.Quan@amd.com><br>
<b>Subject:</b> [PATCH] drm/amd/pm: Support board calibration on aldebaran</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">Add support for board power calibration on Aldebaran.<br>
Board calibration is done after DC offset calibration.<br>
<br>
Signed-off-by: Lijo Lazar <lijo.lazar@amd.com><br>
---<br>
 drivers/gpu/drm/amd/pm/inc/aldebaran_ppsmc.h  |  3 +-<br>
 drivers/gpu/drm/amd/pm/inc/smu_types.h        |  3 +-<br>
 .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c    | 42 ++++++++++++++-----<br>
 3 files changed, 36 insertions(+), 12 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/pm/inc/aldebaran_ppsmc.h b/drivers/gpu/drm/amd/pm/inc/aldebaran_ppsmc.h<br>
index 610266088ff1..35fa0d8e92dd 100644<br>
--- a/drivers/gpu/drm/amd/pm/inc/aldebaran_ppsmc.h<br>
+++ b/drivers/gpu/drm/amd/pm/inc/aldebaran_ppsmc.h<br>
@@ -101,7 +101,8 @@<br>
 #define PPSMC_MSG_SetSystemVirtualSTBtoDramAddrLow  0x41<br>
 <br>
 #define PPSMC_MSG_GfxDriverResetRecovery        0x42<br>
-#define PPSMC_Message_Count                    0x43<br>
+#define PPSMC_MSG_BoardPowerCalibration         0x43<br>
+#define PPSMC_Message_Count                    0x44<br>
 <br>
 //PPSMC Reset Types<br>
 #define PPSMC_RESET_TYPE_WARM_RESET              0x00<br>
diff --git a/drivers/gpu/drm/amd/pm/inc/smu_types.h b/drivers/gpu/drm/amd/pm/inc/smu_types.h<br>
index 89a16dcd0fff..1d3765b873df 100644<br>
--- a/drivers/gpu/drm/amd/pm/inc/smu_types.h<br>
+++ b/drivers/gpu/drm/amd/pm/inc/smu_types.h<br>
@@ -225,7 +225,8 @@<br>
         __SMU_DUMMY_MAP(DisableDeterminism),            \<br>
         __SMU_DUMMY_MAP(SetUclkDpmMode),                \<br>
         __SMU_DUMMY_MAP(LightSBR),                      \<br>
-       __SMU_DUMMY_MAP(GfxDriverResetRecovery),<br>
+       __SMU_DUMMY_MAP(GfxDriverResetRecovery),        \<br>
+       __SMU_DUMMY_MAP(BoardPowerCalibration),<br>
 <br>
 #undef __SMU_DUMMY_MAP<br>
 #define __SMU_DUMMY_MAP(type)   SMU_MSG_##type<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c<br>
index c16ca0c78e93..1400ccb3bf52 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c<br>
@@ -134,6 +134,7 @@ static const struct cmn2asic_msg_mapping aldebaran_message_map[SMU_MSG_MAX_COUNT<br>
         MSG_MAP(DisableDeterminism,                  PPSMC_MSG_DisableDeterminism,               0),<br>
         MSG_MAP(SetUclkDpmMode,                      PPSMC_MSG_SetUclkDpmMode,                   0),<br>
         MSG_MAP(GfxDriverResetRecovery,              PPSMC_MSG_GfxDriverResetRecovery,           0),<br>
+       MSG_MAP(BoardPowerCalibration,               PPSMC_MSG_BoardPowerCalibration,            0),<br>
 };<br>
 <br>
 static const struct cmn2asic_mapping aldebaran_clk_map[SMU_CLK_COUNT] = {<br>
@@ -440,6 +441,35 @@ static int aldebaran_setup_pptable(struct smu_context *smu)<br>
         return ret;<br>
 }<br>
 <br>
+static bool aldebaran_is_primary(struct smu_context *smu)<br>
+{<br>
+       struct amdgpu_device *adev = smu->adev;<br>
+<br>
+       if (adev->smuio.funcs && adev->smuio.funcs->get_die_id)<br>
+               return adev->smuio.funcs->get_die_id(adev) == 0;<br>
+<br>
+       return true;<br>
+}<br>
+<br>
+static int aldebaran_run_board_btc(struct smu_context *smu)<br>
+{<br>
+       u32 smu_version;</div>
<div class="PlainText">[kevin]:</div>
<div class="PlainText">change type to uint32_t is better match with smu driver coding style.<br>
+       int ret;<br>
+<br>
+       if (!aldebaran_is_primary(smu))<br>
+               return 0;<br>
+<br>
+       smu_cmn_get_smc_version(smu, NULL, &smu_version);</div>
<div class="PlainText">[kevin]:</div>
<div class="PlainText">you'd better to check return value first before using smu_version.</div>
<div class="PlainText"><br>
</div>
<div class="PlainText">others is fine for me.</div>
<div class="PlainText"><br>
</div>
<div class="PlainText">Reviewed-by: Kevin Wang <kevin1.wang@amd.com></div>
<div class="PlainText"><br>
+       if (smu_version <= 0x00441d00)<br>
+               return 0;<br>
+<br>
+       ret = smu_cmn_send_smc_msg(smu, SMU_MSG_BoardPowerCalibration, NULL);<br>
+       if (ret)<br>
+               dev_err(smu->adev->dev, "Board power calibration failed!\n");<br>
+<br>
+       return ret;<br>
+}<br>
+<br>
 static int aldebaran_run_btc(struct smu_context *smu)<br>
 {<br>
         int ret;<br>
@@ -447,6 +477,8 @@ static int aldebaran_run_btc(struct smu_context *smu)<br>
         ret = smu_cmn_send_smc_msg(smu, SMU_MSG_RunDcBtc, NULL);<br>
         if (ret)<br>
                 dev_err(smu->adev->dev, "RunDcBtc failed!\n");<br>
+       else<br>
+               ret = aldebaran_run_board_btc(smu);<br>
 <br>
         return ret;<br>
 }<br>
@@ -524,16 +556,6 @@ static int aldebaran_freqs_in_same_level(int32_t frequency1,<br>
         return (abs(frequency1 - frequency2) <= EPSILON);<br>
 }<br>
 <br>
-static bool aldebaran_is_primary(struct smu_context *smu)<br>
-{<br>
-       struct amdgpu_device *adev = smu->adev;<br>
-<br>
-       if (adev->smuio.funcs && adev->smuio.funcs->get_die_id)<br>
-               return adev->smuio.funcs->get_die_id(adev) == 0;<br>
-<br>
-       return true;<br>
-}<br>
-<br>
 static int aldebaran_get_smu_metrics_data(struct smu_context *smu,<br>
                                           MetricsMember_t member,<br>
                                           uint32_t *value)<br>
-- <br>
2.17.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>