diff mbox

[U-Boot,4/4] rockchip: pwm: add mask for config setting

Message ID 1500465263-25544-4-git-send-email-kever.yang@rock-chips.com
State Accepted
Commit 06f4e36baf7833c2fa40af34b240e4132898689b
Delegated to: Philipp Tomsich
Headers show

Commit Message

Kever Yang July 19, 2017, 11:54 a.m. UTC
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

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
---

 arch/arm/include/asm/arch-rockchip/pwm.h | 2 ++
 drivers/pwm/rk_pwm.c                     | 1 +
 2 files changed, 3 insertions(+)

Comments

Philipp Tomsich July 19, 2017, 12:42 p.m. UTC | #1
> 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
> 
> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
> ---
> 
>  arch/arm/include/asm/arch-rockchip/pwm.h | 2 ++
>  drivers/pwm/rk_pwm.c                     | 1 +
>  2 files changed, 3 insertions(+)
> 

Acked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Philipp Tomsich July 26, 2017, 4:52 p.m. UTC | #2
> 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
> 
> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
> Acked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> ---
> 
>  arch/arm/include/asm/arch-rockchip/pwm.h | 2 ++
>  drivers/pwm/rk_pwm.c                     | 1 +
>  2 files changed, 3 insertions(+)
> 

Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Philipp Tomsich July 27, 2017, 8:32 a.m. UTC | #3
> 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
> 
> 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 | 2 ++
>  drivers/pwm/rk_pwm.c                     | 1 +
>  2 files changed, 3 insertions(+)
> 

Applied to u-boot-rockchip, thanks!
Simon Glass July 27, 2017, 3:14 p.m. UTC | #4
On 19 July 2017 at 05:54, Kever Yang <kever.yang@rock-chips.com> wrote:
> 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
>
> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
> ---
>
>  arch/arm/include/asm/arch-rockchip/pwm.h | 2 ++
>  drivers/pwm/rk_pwm.c                     | 1 +
>  2 files changed, 3 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox

Patch

diff --git a/arch/arm/include/asm/arch-rockchip/pwm.h b/arch/arm/include/asm/arch-rockchip/pwm.h
index 08ff945..b1d8047 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 28de62d..2364c2d 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