Skip to content

Commit bd0a62a

Browse files
mtk-rogerlumbgg
authored andcommitted
soc: mediatek: mtk-svs: add thermal voltage compensation if needed
Some extreme test environment may keep IC temperature very low or very high during system boot stage. For stability concern, we add thermal voltage compenstation if needed no matter svs bank phase is in init02 or mon mode. Signed-off-by: Roger Lu <roger.lu@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20230202124104.16504-4-roger.lu@mediatek.com Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
1 parent edecdcc commit bd0a62a

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

drivers/soc/mediatek/mtk-svs.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ static int svs_adjust_pm_opp_volts(struct svs_bank *svsb)
558558
}
559559

560560
/* Get thermal effect */
561-
if (svsb->phase == SVSB_PHASE_MON) {
561+
if (!IS_ERR_OR_NULL(svsb->tzd)) {
562562
ret = thermal_zone_get_temp(svsb->tzd, &tzone_temp);
563563
if (ret || (svsb->temp > SVSB_TEMP_UPPER_BOUND &&
564564
svsb->temp < SVSB_TEMP_LOWER_BOUND)) {
@@ -573,7 +573,8 @@ static int svs_adjust_pm_opp_volts(struct svs_bank *svsb)
573573
temp_voffset += svsb->tzone_ltemp_voffset;
574574

575575
/* 2-line bank update all opp volts when running mon mode */
576-
if (svsb->type == SVSB_HIGH || svsb->type == SVSB_LOW) {
576+
if (svsb->phase == SVSB_PHASE_MON && (svsb->type == SVSB_HIGH ||
577+
svsb->type == SVSB_LOW)) {
577578
opp_start = 0;
578579
opp_stop = svsb->opp_count;
579580
}
@@ -589,11 +590,6 @@ static int svs_adjust_pm_opp_volts(struct svs_bank *svsb)
589590
/* do nothing */
590591
goto unlock_mutex;
591592
case SVSB_PHASE_INIT02:
592-
svsb_volt = max(svsb->volt[i], svsb->vmin);
593-
opp_volt = svs_bank_volt_to_opp_volt(svsb_volt,
594-
svsb->volt_step,
595-
svsb->volt_base);
596-
break;
597593
case SVSB_PHASE_MON:
598594
svsb_volt = max(svsb->volt[i] + temp_voffset, svsb->vmin);
599595
opp_volt = svs_bank_volt_to_opp_volt(svsb_volt,
@@ -1683,7 +1679,7 @@ static int svs_bank_resource_setup(struct svs_platform *svsp)
16831679
}
16841680
}
16851681

1686-
if (svsb->mode_support & SVSB_MODE_MON) {
1682+
if (!IS_ERR_OR_NULL(svsb->tzone_name)) {
16871683
svsb->tzd = thermal_zone_get_zone_by_name(svsb->tzone_name);
16881684
if (IS_ERR(svsb->tzd)) {
16891685
dev_err(svsb->dev, "cannot get \"%s\" thermal zone\n",
@@ -2122,6 +2118,7 @@ static struct svs_bank svs_mt8192_banks[] = {
21222118
.type = SVSB_LOW,
21232119
.set_freq_pct = svs_set_bank_freq_pct_v3,
21242120
.get_volts = svs_get_bank_volts_v3,
2121+
.tzone_name = "gpu1",
21252122
.volt_flags = SVSB_REMOVE_DVTFIXED_VOLT,
21262123
.mode_support = SVSB_MODE_INIT02,
21272124
.opp_count = MAX_OPP_ENTRIES,
@@ -2139,6 +2136,10 @@ static struct svs_bank svs_mt8192_banks[] = {
21392136
.core_sel = 0x0fff0100,
21402137
.int_st = BIT(0),
21412138
.ctl0 = 0x00540003,
2139+
.tzone_htemp = 85000,
2140+
.tzone_htemp_voffset = 0,
2141+
.tzone_ltemp = 25000,
2142+
.tzone_ltemp_voffset = 7,
21422143
},
21432144
{
21442145
.sw_id = SVSB_GPU,

0 commit comments

Comments
 (0)