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

Shenwei Wang shenwei.wang at nxp.com
Mon Jul 1 14:14:28 PDT 2024



> -----Original Message-----
> From: Uwe Kleine-König <u.kleine-koenig at baylibre.com>
> Sent: Monday, July 1, 2024 3:46 PM
> To: Shenwei Wang <shenwei.wang at nxp.com>
> Cc: Shawn Guo <shawnguo at kernel.org>; Sascha Hauer
> <s.hauer at pengutronix.de>; Pengutronix Kernel Team
> <kernel at pengutronix.de>; Fabio Estevam <festevam at gmail.com>; linux-
> pwm at vger.kernel.org; imx at lists.linux.dev; linux-arm-
> kernel at lists.infradead.org; dl-linux-imx <linux-imx at nxp.com>
> Subject: [EXT] Re: [PATCH] pwm: imx-tpm: Enable pinctrl setting for sleep state
> 
> 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?
> 

If we need to take care the imbalance of pinctrl states in the error path in .resume
function, should I also take care of the imbalance of clk states in the error path in .suspend function?

Thank you for the review!
Shenwei

> Best regards
> Uwe



More information about the linux-arm-kernel mailing list