Skip to content

Commit

Permalink
[ARM] 5087/1: Get the PWM layer to handle clock enable/disable properly.
Browse files Browse the repository at this point in the history
Allow pwm_enable()/pwm_disable() to be called as many times
as the driver wants (and not even count them).
The PWM model is different from things like the clock API
where we need enable counting, because PWMs have one
exclusive user per PWM whereas the clock API can have
multiple users of the same clock.

Acked-by: eric miao <eric.miao@marvell.com>
Signed-off-by: Robert Jarzmik <rjarzmik@free.fr>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Robert Jarzmik authored and Russell King committed Jul 3, 2008
1 parent b5f0228 commit c860d70
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions arch/arm/mach-pxa/pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ struct pwm_device {

const char *label;
struct clk *clk;
int clk_enabled;
void __iomem *mmio_base;

unsigned int use_count;
Expand Down Expand Up @@ -87,13 +88,23 @@ EXPORT_SYMBOL(pwm_config);

int pwm_enable(struct pwm_device *pwm)
{
return clk_enable(pwm->clk);
int rc = 0;

if (!pwm->clk_enabled) {
rc = clk_enable(pwm->clk);
if (!rc)
pwm->clk_enabled = 1;
}
return rc;
}
EXPORT_SYMBOL(pwm_enable);

void pwm_disable(struct pwm_device *pwm)
{
clk_disable(pwm->clk);
if (pwm->clk_enabled) {
clk_disable(pwm->clk);
pwm->clk_enabled = 0;
}
}
EXPORT_SYMBOL(pwm_disable);

Expand Down Expand Up @@ -161,6 +172,7 @@ static struct pwm_device *pwm_probe(struct platform_device *pdev,
ret = PTR_ERR(pwm->clk);
goto err_free;
}
pwm->clk_enabled = 0;

pwm->use_count = 0;
pwm->pwm_id = pwm_id;
Expand Down

0 comments on commit c860d70

Please sign in to comment.