Linux-mediatek Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthias Brugger <matthias.bgg@gmail.com>
To: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cc: roger.lu@mediatek.com, khilman@baylibre.com,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
	nfraprado@collabora.com, kernel@collabora.com
Subject: Re: [PATCH 1/6] soc: mediatek: mtk-svs: Commonize t-calibration-data fuse array read
Date: Thu, 25 Aug 2022 15:27:33 +0200	[thread overview]
Message-ID: <d41d392b-d80f-c6e2-9d4e-d28663e5b06c@gmail.com> (raw)
In-Reply-To: <20220726141653.177948-2-angelogioacchino.delregno@collabora.com>



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);


  reply	other threads:[~2022-08-25 13:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-26 14:16 [PATCH 0/6] soc: mediatek: Cleanups for MediaTek SVS driver AngeloGioacchino Del Regno
2022-07-26 14:16 ` [PATCH 1/6] soc: mediatek: mtk-svs: Commonize t-calibration-data fuse array read AngeloGioacchino Del Regno
2022-08-25 13:27   ` Matthias Brugger [this message]
2022-07-26 14:16 ` [PATCH 2/6] soc: mediatek: mtk-svs: Switch to platform_get_irq() AngeloGioacchino Del Regno
2022-08-25 13:26   ` Matthias Brugger
2022-07-26 14:16 ` [PATCH 3/6] soc: mediatek: mtk-svs: Remove hardcoded irqflags AngeloGioacchino Del Regno
2022-08-25 13:28   ` Matthias Brugger
2022-07-26 14:16 ` [PATCH 4/6] soc: mediatek: mtk-svs: Drop of_match_ptr() for of_match_table AngeloGioacchino Del Regno
2022-08-25 13:28   ` Matthias Brugger
2022-07-26 14:16 ` [PATCH 5/6] soc: mediatek: mtk-svs: Use devm variant for dev_pm_opp_of_add_table() AngeloGioacchino Del Regno
2022-08-25 13:28   ` Matthias Brugger
2022-07-26 14:16 ` [PATCH 6/6] soc: mediatek: mtk-svs: Use bitfield access macros where possible AngeloGioacchino Del Regno
2022-08-25 13:29   ` Matthias Brugger
2022-08-25 18:50     ` Nícolas F. R. A. Prado
2022-08-29  9:36       ` AngeloGioacchino Del Regno
2022-08-29  9:33     ` AngeloGioacchino Del Regno
2022-08-29 11:02       ` Matthias Brugger
2022-07-26 14:22 ` [PATCH 0/6] soc: mediatek: Cleanups for MediaTek SVS driver AngeloGioacchino Del Regno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d41d392b-d80f-c6e2-9d4e-d28663e5b06c@gmail.com \
    --to=matthias.bgg@gmail.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=kernel@collabora.com \
    --cc=khilman@baylibre.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=nfraprado@collabora.com \
    --cc=roger.lu@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox