Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 333097
b: refs/heads/master
c: 7b27c16
h: refs/heads/master
i:
  333095: 50b6d34
v: v3
  • Loading branch information
Philipp Zabel authored and Thierry Reding committed Sep 12, 2012
1 parent a02475b commit bd6c9a9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 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: 8d1c24bfd20829f5943c76b85c4973db264dd666
refs/heads/master: 7b27c160c68152581c702b9f1fe362338d2a0cad
35 changes: 27 additions & 8 deletions trunk/drivers/pwm/pwm-imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
#define MX3_PWMCR_EN (1 << 0)

struct imx_chip {
struct clk *clk;
struct clk *clk_per;
struct clk *clk_ipg;

int enabled;
void __iomem *mmio_base;
Expand Down Expand Up @@ -106,7 +107,7 @@ static int imx_pwm_config_v2(struct pwm_chip *chip,
unsigned long period_cycles, duty_cycles, prescale;
u32 cr;

c = clk_get_rate(imx->clk);
c = clk_get_rate(imx->clk_per);
c = c * period_ns;
do_div(c, 1000000000);
period_cycles = c;
Expand Down Expand Up @@ -161,16 +162,25 @@ static int imx_pwm_config(struct pwm_chip *chip,
struct pwm_device *pwm, int duty_ns, int period_ns)
{
struct imx_chip *imx = to_imx_chip(chip);
int ret;

ret = clk_prepare_enable(imx->clk_ipg);
if (ret)
return ret;

return imx->config(chip, pwm, duty_ns, period_ns);
ret = imx->config(chip, pwm, duty_ns, period_ns);

clk_disable_unprepare(imx->clk_ipg);

return ret;
}

static int imx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
{
struct imx_chip *imx = to_imx_chip(chip);
int ret;

ret = clk_prepare_enable(imx->clk);
ret = clk_prepare_enable(imx->clk_per);
if (ret)
return ret;

Expand All @@ -187,7 +197,7 @@ static void imx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)

imx->set_enable(chip, false);

clk_disable_unprepare(imx->clk);
clk_disable_unprepare(imx->clk_per);
imx->enabled = 0;
}

Expand Down Expand Up @@ -239,10 +249,19 @@ static int __devinit imx_pwm_probe(struct platform_device *pdev)
return -ENOMEM;
}

imx->clk = devm_clk_get(&pdev->dev, "pwm");
imx->clk_per = devm_clk_get(&pdev->dev, "per");
if (IS_ERR(imx->clk_per)) {
dev_err(&pdev->dev, "getting per clock failed with %ld\n",
PTR_ERR(imx->clk_per));
return PTR_ERR(imx->clk_per);
}

if (IS_ERR(imx->clk))
return PTR_ERR(imx->clk);
imx->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
if (IS_ERR(imx->clk_ipg)) {
dev_err(&pdev->dev, "getting ipg clock failed with %ld\n",
PTR_ERR(imx->clk_ipg));
return PTR_ERR(imx->clk_ipg);
}

imx->chip.ops = &imx_pwm_ops;
imx->chip.dev = &pdev->dev;
Expand Down

0 comments on commit bd6c9a9

Please sign in to comment.