[PATCH v4 2/5] thermal/drivers/mediatek/lvts_thermal: Add suspend and resume

AngeloGioacchino Del Regno angelogioacchino.delregno at collabora.com
Wed May 31 01:05:11 PDT 2023


Il 30/05/23 21:51, Bernhard Rosenkränzer ha scritto:
> From: Balsam CHIHI <bchihi at baylibre.com>
> 
> Add suspend and resume support to LVTS driver.
> 
> Signed-off-by: Balsam CHIHI <bchihi at baylibre.com>
> Signed-off-by: Bernhard Rosenkränzer <bero at baylibre.com>
> Reviewed-by: Matthias Brugger <matthias.bgg at gmail.com>
> ---
>   drivers/thermal/mediatek/lvts_thermal.c | 34 +++++++++++++++++++++++++
>   1 file changed, 34 insertions(+)
> 
> diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
> index d0a3f95b7884b..5ea8a9d569ea6 100644
> --- a/drivers/thermal/mediatek/lvts_thermal.c
> +++ b/drivers/thermal/mediatek/lvts_thermal.c
> @@ -1169,6 +1169,38 @@ static int lvts_remove(struct platform_device *pdev)
>   	return 0;
>   }
>   
> +static int lvts_suspend(struct platform_device *pdev, pm_message_t state)
> +{
> +	struct lvts_domain *lvts_td;
> +	int i;
> +
> +	lvts_td = platform_get_drvdata(pdev);
> +
> +	for (i = 0; i < lvts_td->num_lvts_ctrl; i++)
> +		lvts_ctrl_set_enable(&lvts_td->lvts_ctrl[i], false);
> +
> +	clk_disable_unprepare(lvts_td->clk);
> +
> +	return 0;
> +}
> +
> +static int lvts_resume(struct platform_device *pdev)
> +{
> +	struct lvts_domain *lvts_td;
> +	int i, ret;
> +
> +	lvts_td = platform_get_drvdata(pdev);
> +
> +	ret = clk_prepare_enable(lvts_td->clk);
> +	if (ret)
> +		return ret;
> +
> +	for (i = 0; i < lvts_td->num_lvts_ctrl; i++)
> +		lvts_ctrl_set_enable(&lvts_td->lvts_ctrl[i], true);
> +
> +	return 0;
> +}
> +
>   static const struct lvts_ctrl_data mt8195_lvts_mcu_data_ctrl[] = {
>   	{
>   		.cal_offset = { 0x04, 0x07 },
> @@ -1268,6 +1300,8 @@ MODULE_DEVICE_TABLE(of, lvts_of_match);
>   static struct platform_driver lvts_driver = {
>   	.probe = lvts_probe,
>   	.remove = lvts_remove,
> +	.suspend = lvts_suspend,

Should we do that in noirq handlers?
We're risking to miss a thermal interrupt.

Regards,
Angelo

> +	.resume = lvts_resume,
>   	.driver = {
>   		.name = "mtk-lvts-thermal",
>   		.of_match_table = lvts_of_match,




More information about the Linux-mediatek mailing list