]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
pwm: imx: Don't drop the enable bit once set
authorMiquel Raynal <miquel.raynal@bootlin.com>
Tue, 10 Sep 2024 09:13:59 +0000 (11:13 +0200)
committerFabio Estevam <festevam@gmail.com>
Wed, 11 Sep 2024 20:02:36 +0000 (17:02 -0300)
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.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
drivers/pwm/pwm-imx.c

index 320ea7c4239ab605f1e50f01734d0767c9a597c8..bb37b39fa0e2964955cbdbec3dd908cf75e210e5 100644 (file)
@@ -20,10 +20,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);