Merge git://git.denx.de/u-boot-sunxi
[oweals/u-boot.git] / drivers / pwm / rk_pwm.c
index 59eae0956e67b88b51f7d8f9849a56a0d5eb26f2..4c1ee6739e6dcaff937eee6c7e897787e357c2fe 100644 (file)
@@ -16,8 +16,6 @@
 #include <asm/arch/pwm.h>
 #include <power/regulator.h>
 
-DECLARE_GLOBAL_DATA_PTR;
-
 struct rk_pwm_priv {
        struct rk3288_pwm *regs;
        ulong freq;
@@ -29,6 +27,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
@@ -75,7 +74,7 @@ static int rk_pwm_ofdata_to_platdata(struct udevice *dev)
 {
        struct rk_pwm_priv *priv = dev_get_priv(dev);
 
-       priv->regs = (struct rk3288_pwm *)devfdt_get_addr(dev);
+       priv->regs = (struct rk3288_pwm *)dev_read_addr(dev);
 
        return 0;
 }
@@ -92,6 +91,7 @@ static int rk_pwm_probe(struct udevice *dev)
                return -EINVAL;
        }
        priv->freq = clk_get_rate(&clk);
+       priv->enable_conf = PWM_DUTY_POSTIVE | PWM_INACTIVE_POSTIVE;
 
        return 0;
 }