rockchip: pwm: add mask for config setting
authorKever Yang <kever.yang@rock-chips.com>
Wed, 19 Jul 2017 11:54:23 +0000 (19:54 +0800)
committerPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>
Thu, 27 Jul 2017 12:59:01 +0000 (14:59 +0200)
Use mask to clear old setting before direct set the new config,
or else there it will mess up the config when it's not the same
with default value.

Fixes: 3851059 rockchip: Setup default PWM flags
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Acked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
arch/arm/include/asm/arch-rockchip/pwm.h
drivers/pwm/rk_pwm.c

index 08ff94591c9aec33adaded1839563d7425cc8a05..b1d8047691e77804a7f67e5bf2c0b653c19f2d58 100644 (file)
@@ -25,9 +25,11 @@ check_member(rk3288_pwm, ctrl, 0xc);
 
 #define PWM_DUTY_POSTIVE                (1 << 3)
 #define PWM_DUTY_NEGATIVE               (0 << 3)
+#define PWM_DUTY_MASK                  (1 << 3)
 
 #define PWM_INACTIVE_POSTIVE            (1 << 4)
 #define PWM_INACTIVE_NEGATIVE           (0 << 4)
+#define PWM_INACTIVE_MASK              (1 << 4)
 
 #define PWM_OUTPUT_LEFT                 (0 << 5)
 #define PWM_OUTPUT_CENTER               (1 << 5)
index 28de62d71611087ace2f188c85f4a57ec60f42f4..2364c2dfddc9ad9473ed5196a5dde120a432ded4 100644 (file)
@@ -29,6 +29,7 @@ static int rk_pwm_set_invert(struct udevice *dev, uint channel, bool polarity)
        struct rk_pwm_priv *priv = dev_get_priv(dev);
 
        debug("%s: polarity=%u\n", __func__, polarity);
+       priv->enable_conf &= ~(PWM_DUTY_MASK | PWM_INACTIVE_MASK);
        if (polarity)
                priv->enable_conf |= PWM_DUTY_NEGATIVE | PWM_INACTIVE_POSTIVE;
        else