summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKever Yang <kever.yang@rock-chips.com>2017-07-19 14:05:00 +0300
committerKever Yang <kever.yang@rock-chips.com>2017-07-21 05:28:52 +0300
commit74b7c2437ed183c9bb11281137f9f82dd763af01 (patch)
treea16d61f258653eb689980b3e82331bcc29120120
parentab2d7d206c99666e7ad2980f4540b6c0ba8d969f (diff)
downloadu-boot-74b7c2437ed183c9bb11281137f9f82dd763af01.tar.xz
rockchip: pwm: add mask for config setting
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. Fixs: 3851059 rockchip: Setup default PWM flags Change-Id: Id991f5af0917a70cf25e9ff7434b7b4e9592d0a0 Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
-rw-r--r--arch/arm/include/asm/arch-rockchip/pwm.h2
-rw-r--r--drivers/pwm/rk_pwm.c1
2 files changed, 3 insertions, 0 deletions
diff --git a/arch/arm/include/asm/arch-rockchip/pwm.h b/arch/arm/include/asm/arch-rockchip/pwm.h
index 08ff94591c..b1d8047691 100644
--- a/arch/arm/include/asm/arch-rockchip/pwm.h
+++ b/arch/arm/include/asm/arch-rockchip/pwm.h
@@ -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)
diff --git a/drivers/pwm/rk_pwm.c b/drivers/pwm/rk_pwm.c
index 28de62d716..2364c2dfdd 100644
--- a/drivers/pwm/rk_pwm.c
+++ b/drivers/pwm/rk_pwm.c
@@ -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