diff mbox series

pwm: imx-tpm: force 'real_period' to be zero in suspend

Message ID 20230505065839.3973693-1-xiaoning.wang@nxp.com (mailing list archive)
State New, archived
Headers show
Series pwm: imx-tpm: force 'real_period' to be zero in suspend | expand

Commit Message

Clark Wang May 5, 2023, 6:58 a.m. UTC
From: Fancy Fang <chen.fang@nxp.com>

During suspend, all the tpm registers will lose values.
So the 'real_period' value of struct 'imx_tpm_pwm_chip'
should be forced to be zero to force the period update
code can be executed after system resume back.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
---
 drivers/pwm/pwm-imx-tpm.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Uwe Kleine-König June 14, 2023, 8:59 a.m. UTC | #1
On Fri, May 05, 2023 at 02:58:39PM +0800, Clark Wang wrote:
> From: Fancy Fang <chen.fang@nxp.com>
> 
> During suspend, all the tpm registers will lose values.
> So the 'real_period' value of struct 'imx_tpm_pwm_chip'
> should be forced to be zero to force the period update
> code can be executed after system resume back.
> 
> Signed-off-by: Fancy Fang <chen.fang@nxp.com>
> Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>

Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fixes: 738a1cfec2ed ("pwm: Add i.MX TPM PWM driver support")

Best regards
Uwe
Thierry Reding June 23, 2023, 2:51 p.m. UTC | #2
On Fri, 05 May 2023 14:58:39 +0800, Clark Wang wrote:
> During suspend, all the tpm registers will lose values.
> So the 'real_period' value of struct 'imx_tpm_pwm_chip'
> should be forced to be zero to force the period update
> code can be executed after system resume back.
> 
> 

Applied, thanks!

[1/1] pwm: imx-tpm: force 'real_period' to be zero in suspend
      commit: 661dfb7f46298e53f6c3deaa772fa527aae86193

Best regards,
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-imx-tpm.c b/drivers/pwm/pwm-imx-tpm.c
index 5e2b452ee5f2..98ab65c89685 100644
--- a/drivers/pwm/pwm-imx-tpm.c
+++ b/drivers/pwm/pwm-imx-tpm.c
@@ -397,6 +397,13 @@  static int __maybe_unused pwm_imx_tpm_suspend(struct device *dev)
 	if (tpm->enable_count > 0)
 		return -EBUSY;
 
+	/*
+	 * Force 'real_period' to be zero to force period update code
+	 * can be executed after system resume back, since suspend causes
+	 * the period related registers to become their reset values.
+	 */
+	tpm->real_period = 0;
+
 	clk_disable_unprepare(tpm->clk);
 
 	return 0;