Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 347115
b: refs/heads/master
c: 422470a
h: refs/heads/master
i:
  347113: 0f44508
  347111: 0e78f82
v: v3
  • Loading branch information
Tony Prisk authored and Thierry Reding committed Nov 22, 2012
1 parent 1f00378 commit 4c083dd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2f9569f7ceab31242b306d040861737580e1876f
refs/heads/master: 422470a8265fbb1d182c00ab2421f4b416ab2dba
14 changes: 12 additions & 2 deletions trunk/drivers/pwm/pwm-vt8500.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ static int vt8500_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
struct vt8500_chip *vt8500 = to_vt8500_chip(chip);
unsigned long long c;
unsigned long period_cycles, prescale, pv, dc;
int err;

err = clk_enable(vt8500->clk);
if (err < 0) {
dev_err(chip->dev, "failed to enable clock\n");
return err;
}

c = clk_get_rate(vt8500->clk);
c = c * period_ns;
Expand All @@ -75,8 +82,10 @@ static int vt8500_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
if (pv > 4095)
pv = 4095;

if (prescale > 1023)
if (prescale > 1023) {
clk_disable(vt8500->clk);
return -EINVAL;
}

c = (unsigned long long)pv * duty_ns;
do_div(c, period_ns);
Expand All @@ -91,6 +100,7 @@ static int vt8500_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
pwm_busy_wait(vt8500->base + 0x40 + pwm->hwpwm, (1 << 3));
writel(dc, vt8500->base + 0xc + (pwm->hwpwm << 4));

clk_disable(vt8500->clk);
return 0;
}

Expand All @@ -103,7 +113,7 @@ static int vt8500_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
if (err < 0) {
dev_err(chip->dev, "failed to enable clock\n");
return err;
};
}

pwm_busy_wait(vt8500->base + 0x40 + pwm->hwpwm, (1 << 0));
writel(5, vt8500->base + (pwm->hwpwm << 4));
Expand Down

0 comments on commit 4c083dd

Please sign in to comment.