Skip to contentSkip to conversation

pwm: imx: Don't drop the enable bit once set

PATCH In review Miquel Raynal 2 participants 3 messages Sep 10, 2024 – Sep 11, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pwm: imx: Don't drop the enable bit once set

Changing the duty-cycle should not blindly override (and clear) the enable (EN) bit if it has already been set. For instance, a PWM backlight can be enabled and set to a specific intensity using two operations. The order of these operations should not matter.

---
 drivers/pwm/pwm-imx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pwm/pwm-imx.c +3 -2
index 8fbb40cc276..8bcc8f2af02 100644
@@ -21,10 +21,11 @@ int pwm_config_internal(struct pwm_regs *pwm, unsigned long period_cycles,
 	u32 cr;
 
 	writel(0, &pwm->ir);
-	cr = PWMCR_PRESCALER(prescale) |
+
+	cr = readl(&pwm->cr) & PWMCR_EN;
+	cr |= PWMCR_PRESCALER(prescale) |
 		PWMCR_DOZEEN | PWMCR_WAITEN |
 		PWMCR_DBGEN | PWMCR_CLKSRC_IPG_HIGH;
-
 	writel(cr, &pwm->cr);
 	/* set duty cycles */
 	writel(duty_cycles, &pwm->sar);
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Miquel Raynal

Changing the duty-cycle should not blindly override (and clear) the enable (EN) bit if it has already been set. For instance, a PWM backlight can be enabled and set to a specific intensity using two operations. The order of these operations should not matter.

reviewer
#2 lore raw
In reply to Miquel Raynal
Quoted 7 lines · Miquel Raynal

Changing the duty-cycle should not blindly override (and clear) the enable (EN) bit if it has already been set. For instance, a PWM backlight can be enabled and set to a specific intensity using two operations. The order of these operations should not matter.

Applied to u-boot-imx/next, thanks.