Skip to content

Commit

Permalink
pwm: ep93xx: Prepare clock before using it
Browse files Browse the repository at this point in the history
Use clk_prepare_enable()/clk_disable_unprepare() in preparation for switch
to Common Clock Framework.

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
  • Loading branch information
Alexander Sverdlin authored and Thierry Reding committed Jun 30, 2021
1 parent 72cce47 commit b235f8a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions drivers/pwm/pwm-ep93xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ static int ep93xx_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
if (state->polarity != pwm->state.polarity) {
if (enabled) {
writew(0x0, ep93xx_pwm->base + EP93XX_PWMx_ENABLE);
clk_disable(ep93xx_pwm->clk);
clk_disable_unprepare(ep93xx_pwm->clk);
enabled = false;
}

/*
* The clock needs to be enabled to access the PWM registers.
* Polarity can only be changed when the PWM is disabled.
*/
ret = clk_enable(ep93xx_pwm->clk);
ret = clk_prepare_enable(ep93xx_pwm->clk);
if (ret)
return ret;

Expand All @@ -85,13 +85,13 @@ static int ep93xx_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
else
writew(0x0, ep93xx_pwm->base + EP93XX_PWMx_INVERT);

clk_disable(ep93xx_pwm->clk);
clk_disable_unprepare(ep93xx_pwm->clk);
}

if (!state->enabled) {
if (enabled) {
writew(0x0, ep93xx_pwm->base + EP93XX_PWMx_ENABLE);
clk_disable(ep93xx_pwm->clk);
clk_disable_unprepare(ep93xx_pwm->clk);
}

return 0;
Expand All @@ -111,7 +111,7 @@ static int ep93xx_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
* Configuration can be changed at any time.
*/
if (!pwm_is_enabled(pwm)) {
ret = clk_enable(ep93xx_pwm->clk);
ret = clk_prepare_enable(ep93xx_pwm->clk);
if (ret)
return ret;
}
Expand Down Expand Up @@ -142,14 +142,14 @@ static int ep93xx_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
}

if (!pwm_is_enabled(pwm))
clk_disable(ep93xx_pwm->clk);
clk_disable_unprepare(ep93xx_pwm->clk);

if (ret)
return ret;
}

if (!enabled) {
ret = clk_enable(ep93xx_pwm->clk);
ret = clk_prepare_enable(ep93xx_pwm->clk);
if (ret)
return ret;

Expand Down

0 comments on commit b235f8a

Please sign in to comment.