Skip to content

Commit 3962c24

Browse files
ViorelSumanUwe Kleine-König
authored andcommitted
pwm: imx-tpm: Count the number of enabled channels in probe
On a soft reset TPM PWM IP may preserve its internal state from previous runtime, therefore on a subsequent OS boot and driver probe "enable_count" value and TPM PWM IP internal channels "enabled" states may get unaligned. In consequence on a suspend/resume cycle the call "if (--tpm->enable_count == 0)" may lead to "enable_count" overflow the system being blocked from entering suspend due to: if (tpm->enable_count > 0) return -EBUSY; Fix the problem by counting the enabled channels in probe function. Signed-off-by: Viorel Suman (OSS) <viorel.suman@oss.nxp.com> Fixes: 738a1cf ("pwm: Add i.MX TPM PWM driver support") Link: https://patch.msgid.link/20260311123309.348904-1-viorel.suman@oss.nxp.com Cc: stable@vger.kernel.org Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
1 parent 6de23f8 commit 3962c24

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

drivers/pwm/pwm-imx-tpm.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ static int pwm_imx_tpm_probe(struct platform_device *pdev)
352352
struct clk *clk;
353353
void __iomem *base;
354354
int ret;
355-
unsigned int npwm;
355+
unsigned int i, npwm;
356356
u32 val;
357357

358358
base = devm_platform_ioremap_resource(pdev, 0);
@@ -382,6 +382,13 @@ static int pwm_imx_tpm_probe(struct platform_device *pdev)
382382

383383
mutex_init(&tpm->lock);
384384

385+
/* count the enabled channels */
386+
for (i = 0; i < npwm; ++i) {
387+
val = readl(base + PWM_IMX_TPM_CnSC(i));
388+
if (FIELD_GET(PWM_IMX_TPM_CnSC_ELS, val))
389+
++tpm->enable_count;
390+
}
391+
385392
ret = devm_pwmchip_add(&pdev->dev, chip);
386393
if (ret)
387394
return dev_err_probe(&pdev->dev, ret, "failed to add PWM chip\n");

0 commit comments

Comments
 (0)