[PATCH] pwm: imx-tpm: reset module on probe

Viorel Suman (OSS) viorel.suman at oss.nxp.com
Thu Feb 1 04:22:42 PST 2024


From: Viorel Suman <viorel.suman at nxp.com>

Reset Timer PWM module on probe so that the module
takes the default state after probe is finished.

Signed-off-by: Viorel Suman <viorel.suman at nxp.com>
Signed-off-by: Florin Leotescu <florin.leotescu at nxp.com>
---
 drivers/pwm/pwm-imx-tpm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/pwm/pwm-imx-tpm.c b/drivers/pwm/pwm-imx-tpm.c
index 9fc290e647e1..27e6a5342693 100644
--- a/drivers/pwm/pwm-imx-tpm.c
+++ b/drivers/pwm/pwm-imx-tpm.c
@@ -33,6 +33,7 @@
 #define PWM_IMX_TPM_CnV(n)	(0x24 + (n) * 0x8)
 
 #define PWM_IMX_TPM_PARAM_CHAN			GENMASK(7, 0)
+#define PWM_IMX_TPM_GLOBAL_RST			BIT(1)
 
 #define PWM_IMX_TPM_SC_PS			GENMASK(2, 0)
 #define PWM_IMX_TPM_SC_CMOD			GENMASK(4, 3)
@@ -362,6 +363,10 @@ static int pwm_imx_tpm_probe(struct platform_device *pdev)
 	val = readl(tpm->base + PWM_IMX_TPM_PARAM);
 	tpm->chip.npwm = FIELD_GET(PWM_IMX_TPM_PARAM_CHAN, val);
 
+	/* Resets all internal logic and registers */
+	writel(PWM_IMX_TPM_GLOBAL_RST, tpm->base + PWM_IMX_TPM_GLOBAL);
+	writel(0, tpm->base + PWM_IMX_TPM_GLOBAL);
+
 	mutex_init(&tpm->lock);
 
 	ret = devm_pwmchip_add(&pdev->dev, &tpm->chip);
-- 
2.34.1




More information about the linux-arm-kernel mailing list