lkml.org 
[lkml]   [2022]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 1/6] soc: mediatek: mtk-svs: Commonize t-calibration-data fuse array read
From


On 26/07/2022 16:16, AngeloGioacchino Del Regno wrote:
> Commonize the repeating pattern for reading the "t-calibration-data"
> efuse data in a new function svs_thermal_efuse_get_data(), reducing
> the size of this driver.
>
> No functional changes.
>
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---
> drivers/soc/mediatek/mtk-svs.c | 111 +++++++++++----------------------
> 1 file changed, 38 insertions(+), 73 deletions(-)
>
> diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c
> index 5ac431a04548..600492dc334c 100644
> --- a/drivers/soc/mediatek/mtk-svs.c
> +++ b/drivers/soc/mediatek/mtk-svs.c
> @@ -1684,11 +1684,36 @@ static int svs_bank_resource_setup(struct svs_platform *svsp)
> return 0;
> }
>
> +static int svs_thermal_efuse_get_data(struct svs_platform *svsp)
> +{
> + struct nvmem_cell *cell;
> +
> + /* Thermal efuse parsing */
> + cell = nvmem_cell_get(svsp->dev, "t-calibration-data");
> + if (IS_ERR_OR_NULL(cell)) {
> + dev_err(svsp->dev, "no \"t-calibration-data\"? %ld\n", PTR_ERR(cell));
> + return PTR_ERR(cell);
> + }
> +
> + svsp->tefuse = nvmem_cell_read(cell, &svsp->tefuse_max);
> + if (IS_ERR(svsp->tefuse)) {
> + dev_err(svsp->dev, "cannot read thermal efuse: %ld\n",
> + PTR_ERR(svsp->tefuse));
> + nvmem_cell_put(cell);
> + return PTR_ERR(svsp->tefuse);
> + }
> +
> + svsp->tefuse_max /= sizeof(u32);
> + nvmem_cell_put(cell);
> +
> + return 0;
> +}
> +
> static bool svs_mt8195_efuse_parsing(struct svs_platform *svsp)

Please rebase on upstream driver, no support for mt8195 for now.

Regards,
Matthias

> {
> struct svs_bank *svsb;
> - struct nvmem_cell *cell;
> u32 idx, i, ft_pgm, vmin, golden_temp;
> + int ret;
>
> for (i = 0; i < svsp->efuse_max; i++)
> if (svsp->efuse[i])
> @@ -1730,24 +1755,9 @@ static bool svs_mt8195_efuse_parsing(struct svs_platform *svsp)
> svsb->vmax += svsb->dvt_fixed;
> }
>
> - /* Thermal efuse parsing */
> - cell = nvmem_cell_get(svsp->dev, "t-calibration-data");
> - if (IS_ERR_OR_NULL(cell)) {
> - dev_err(svsp->dev, "no \"t-calibration-data\"? %ld\n",
> - PTR_ERR(cell));
> - return false;
> - }
> -
> - svsp->tefuse = nvmem_cell_read(cell, &svsp->tefuse_max);
> - if (IS_ERR(svsp->tefuse)) {
> - dev_err(svsp->dev, "cannot read thermal efuse: %ld\n",
> - PTR_ERR(svsp->tefuse));
> - nvmem_cell_put(cell);
> + ret = svs_thermal_efuse_get_data(svsp);
> + if (ret)
> return false;
> - }
> -
> - svsp->tefuse_max /= sizeof(u32);
> - nvmem_cell_put(cell);
>
> for (i = 0; i < svsp->tefuse_max; i++)
> if (svsp->tefuse[i] != 0)
> @@ -1770,8 +1780,8 @@ static bool svs_mt8195_efuse_parsing(struct svs_platform *svsp)
> static bool svs_mt8192_efuse_parsing(struct svs_platform *svsp)
> {
> struct svs_bank *svsb;
> - struct nvmem_cell *cell;
> u32 idx, i, vmin, golden_temp;
> + int ret;
>
> for (i = 0; i < svsp->efuse_max; i++)
> if (svsp->efuse[i])
> @@ -1809,24 +1819,9 @@ static bool svs_mt8192_efuse_parsing(struct svs_platform *svsp)
> svsb->vmax += svsb->dvt_fixed;
> }
>
> - /* Thermal efuse parsing */
> - cell = nvmem_cell_get(svsp->dev, "t-calibration-data");
> - if (IS_ERR_OR_NULL(cell)) {
> - dev_err(svsp->dev, "no \"t-calibration-data\"? %ld\n",
> - PTR_ERR(cell));
> - return false;
> - }
> -
> - svsp->tefuse = nvmem_cell_read(cell, &svsp->tefuse_max);
> - if (IS_ERR(svsp->tefuse)) {
> - dev_err(svsp->dev, "cannot read thermal efuse: %ld\n",
> - PTR_ERR(svsp->tefuse));
> - nvmem_cell_put(cell);
> + ret = svs_thermal_efuse_get_data(svsp);
> + if (ret)
> return false;
> - }
> -
> - svsp->tefuse_max /= sizeof(u32);
> - nvmem_cell_put(cell);
>
> for (i = 0; i < svsp->tefuse_max; i++)
> if (svsp->tefuse[i] != 0)
> @@ -1849,8 +1844,8 @@ static bool svs_mt8192_efuse_parsing(struct svs_platform *svsp)
> static bool svs_mt8186_efuse_parsing(struct svs_platform *svsp)
> {
> struct svs_bank *svsb;
> - struct nvmem_cell *cell;
> u32 idx, i, golden_temp;
> + int ret;
>
> for (i = 0; i < svsp->efuse_max; i++)
> if (svsp->efuse[i])
> @@ -1911,24 +1906,9 @@ static bool svs_mt8186_efuse_parsing(struct svs_platform *svsp)
> svsb->vmax += svsb->dvt_fixed;
> }
>
> - /* Thermal efuse parsing */
> - cell = nvmem_cell_get(svsp->dev, "t-calibration-data");
> - if (IS_ERR_OR_NULL(cell)) {
> - dev_err(svsp->dev, "no \"t-calibration-data\"? %ld\n",
> - PTR_ERR(cell));
> + ret = svs_thermal_efuse_get_data(svsp);
> + if (ret)
> return false;
> - }
> -
> - svsp->tefuse = nvmem_cell_read(cell, &svsp->tefuse_max);
> - if (IS_ERR(svsp->tefuse)) {
> - dev_err(svsp->dev, "cannot read thermal efuse: %ld\n",
> - PTR_ERR(svsp->tefuse));
> - nvmem_cell_put(cell);
> - return false;
> - }
> -
> - svsp->tefuse_max /= sizeof(u32);
> - nvmem_cell_put(cell);
>
> golden_temp = (svsp->tefuse[0] >> 24) & GENMASK(7, 0);
> if (!golden_temp)
> @@ -1946,11 +1926,11 @@ static bool svs_mt8186_efuse_parsing(struct svs_platform *svsp)
> static bool svs_mt8183_efuse_parsing(struct svs_platform *svsp)
> {
> struct svs_bank *svsb;
> - struct nvmem_cell *cell;
> int format[6], x_roomt[6], o_vtsmcu[5], o_vtsabb, tb_roomt = 0;
> int adc_ge_t, adc_oe_t, ge, oe, gain, degc_cali, adc_cali_en_t;
> int o_slope, o_slope_sign, ts_id;
> u32 idx, i, ft_pgm, mts, temp0, temp1, temp2;
> + int ret;
>
> for (i = 0; i < svsp->efuse_max; i++)
> if (svsp->efuse[i])
> @@ -2026,24 +2006,9 @@ static bool svs_mt8183_efuse_parsing(struct svs_platform *svsp)
> }
> }
>
> - /* Get thermal efuse by nvmem */
> - cell = nvmem_cell_get(svsp->dev, "t-calibration-data");
> - if (IS_ERR(cell)) {
> - dev_err(svsp->dev, "no \"t-calibration-data\"? %ld\n",
> - PTR_ERR(cell));
> - goto remove_mt8183_svsb_mon_mode;
> - }
> -
> - svsp->tefuse = nvmem_cell_read(cell, &svsp->tefuse_max);
> - if (IS_ERR(svsp->tefuse)) {
> - dev_err(svsp->dev, "cannot read thermal efuse: %ld\n",
> - PTR_ERR(svsp->tefuse));
> - nvmem_cell_put(cell);
> - goto remove_mt8183_svsb_mon_mode;
> - }
> -
> - svsp->tefuse_max /= sizeof(u32);
> - nvmem_cell_put(cell);
> + ret = svs_thermal_efuse_get_data(svsp);
> + if (ret)
> + return false;
>
> /* Thermal efuse parsing */
> adc_ge_t = (svsp->tefuse[1] >> 22) & GENMASK(9, 0);

\
 
 \ /
  Last update: 2022-08-25 15:28    [W:0.078 / U:0.544 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site