soc: mtk-svs: mt8183: refactor o_slope calculation

The o_slope value is dependent of the o_slope_sign, refactor code to get
rid of unnecessary if constructs.

Signed-off-by: Roger Lu <roger.lu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20230111074528.29354-15-roger.lu@mediatek.com
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
This commit is contained in:
Roger Lu 2023-01-11 15:45:28 +08:00 committed by Matthias Brugger
parent 01c9a8bd23
commit d5a7d80990
1 changed files with 22 additions and 29 deletions

View File

@ -1921,13 +1921,18 @@ static bool svs_mt8183_efuse_parsing(struct svs_platform *svsp)
o_slope_sign = (svsp->tefuse[0] >> 7) & BIT(0); o_slope_sign = (svsp->tefuse[0] >> 7) & BIT(0);
ts_id = (svsp->tefuse[1] >> 9) & BIT(0); ts_id = (svsp->tefuse[1] >> 9) & BIT(0);
if (!ts_id) {
o_slope = 1534;
} else {
o_slope = (svsp->tefuse[0] >> 26) & GENMASK(5, 0); o_slope = (svsp->tefuse[0] >> 26) & GENMASK(5, 0);
if (!o_slope_sign)
o_slope = 1534 + o_slope * 10;
else
o_slope = 1534 - o_slope * 10;
}
if (adc_cali_en_t == 1) { if (adc_cali_en_t == 0 ||
if (!ts_id) adc_ge_t < 265 || adc_ge_t > 758 ||
o_slope = 0;
if (adc_ge_t < 265 || adc_ge_t > 758 ||
adc_oe_t < 265 || adc_oe_t > 758 || adc_oe_t < 265 || adc_oe_t > 758 ||
o_vtsmcu[0] < -8 || o_vtsmcu[0] > 484 || o_vtsmcu[0] < -8 || o_vtsmcu[0] > 484 ||
o_vtsmcu[1] < -8 || o_vtsmcu[1] > 484 || o_vtsmcu[1] < -8 || o_vtsmcu[1] > 484 ||
@ -1939,10 +1944,6 @@ static bool svs_mt8183_efuse_parsing(struct svs_platform *svsp)
dev_err(svsp->dev, "bad thermal efuse, no mon mode\n"); dev_err(svsp->dev, "bad thermal efuse, no mon mode\n");
goto remove_mt8183_svsb_mon_mode; goto remove_mt8183_svsb_mon_mode;
} }
} else {
dev_err(svsp->dev, "no thermal efuse, no mon mode\n");
goto remove_mt8183_svsb_mon_mode;
}
ge = ((adc_ge_t - 512) * 10000) / 4096; ge = ((adc_ge_t - 512) * 10000) / 4096;
oe = (adc_oe_t - 512); oe = (adc_oe_t - 512);
@ -1959,11 +1960,7 @@ static bool svs_mt8183_efuse_parsing(struct svs_platform *svsp)
x_roomt[i] = (((format[i] * 10000) / 4096) * 10000) / gain; x_roomt[i] = (((format[i] * 10000) / 4096) * 10000) / gain;
temp0 = (10000 * 100000 / gain) * 15 / 18; temp0 = (10000 * 100000 / gain) * 15 / 18;
mts = (temp0 * 10) / o_slope;
if (!o_slope_sign)
mts = (temp0 * 10) / (1534 + o_slope * 10);
else
mts = (temp0 * 10) / (1534 - o_slope * 10);
for (idx = 0; idx < svsp->bank_max; idx++) { for (idx = 0; idx < svsp->bank_max; idx++) {
svsb = &svsp->banks[idx]; svsb = &svsp->banks[idx];
@ -1990,11 +1987,7 @@ static bool svs_mt8183_efuse_parsing(struct svs_platform *svsp)
temp0 = (degc_cali * 10 / 2); temp0 = (degc_cali * 10 / 2);
temp1 = ((10000 * 100000 / 4096 / gain) * temp1 = ((10000 * 100000 / 4096 / gain) *
oe + tb_roomt * 10) * 15 / 18; oe + tb_roomt * 10) * 15 / 18;
temp2 = temp1 * 100 / o_slope;
if (!o_slope_sign)
temp2 = temp1 * 100 / (1534 + o_slope * 10);
else
temp2 = temp1 * 100 / (1534 - o_slope * 10);
svsb->bts = (temp0 + temp2 - 250) * 4 / 10; svsb->bts = (temp0 + temp2 - 250) * 4 / 10;
} }