[PATCH] pwm: imx-tpm: Enable pinctrl setting for sleep state

Uwe Kleine-König u.kleine-koenig at baylibre.com
Mon Jul 1 13:45:31 PDT 2024


Hello,

On Tue, May 14, 2024 at 03:05:34PM -0500, Shenwei Wang wrote:
> Apply the pinctrl setting of sleep state when system enters
> suspend state.
> Restore to the default pinctrl setting when system resumes.
> 
> Signed-off-by: Shenwei Wang <shenwei.wang at nxp.com>
> ---
>  drivers/pwm/pwm-imx-tpm.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pwm/pwm-imx-tpm.c b/drivers/pwm/pwm-imx-tpm.c
> index c50ddbac43c8..19245790c67c 100644
> --- a/drivers/pwm/pwm-imx-tpm.c
> +++ b/drivers/pwm/pwm-imx-tpm.c
> @@ -393,7 +393,7 @@ static int pwm_imx_tpm_suspend(struct device *dev)
>  
>  	clk_disable_unprepare(tpm->clk);
>  
> -	return 0;
> +	return pinctrl_pm_select_sleep_state(dev);
>  }
>  
>  static int pwm_imx_tpm_resume(struct device *dev)
> @@ -401,6 +401,10 @@ static int pwm_imx_tpm_resume(struct device *dev)
>  	struct imx_tpm_pwm_chip *tpm = dev_get_drvdata(dev);
>  	int ret = 0;
>  
> +	ret = pinctrl_pm_select_default_state(dev);
> +	if (ret)
> +		return ret;
> +
>  	ret = clk_prepare_enable(tpm->clk);
>  	if (ret)
>  		dev_err(dev, "failed to prepare or enable clock: %d\n", ret);

If .resume() failed (consider clk_prepare_enable() failing), and
the resume is retried later: Is there an unexpected (though maybe
harmless) imbalance because pinctrl_pm_select_default_state() isn't
undone in .resume()'s error path?

Best regards
Uwe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20240701/69398e40/attachment.sig>


More information about the linux-arm-kernel mailing list