mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-02 20:44:00 +00:00
pwm: ep93xx: Implement .apply callback
To ease review this reuses the formerly implemented callbacks. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
This commit is contained in:
parent
868f13bdea
commit
6d45374af5
1 changed files with 39 additions and 4 deletions
|
@ -156,13 +156,48 @@ static void ep93xx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
|
||||||
clk_disable(ep93xx_pwm->clk);
|
clk_disable(ep93xx_pwm->clk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ep93xx_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||||
|
const struct pwm_state *state)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
bool enabled = state->enabled;
|
||||||
|
|
||||||
|
if (state->polarity != pwm->state.polarity) {
|
||||||
|
if (enabled) {
|
||||||
|
ep93xx_pwm_disable(chip, pwm);
|
||||||
|
enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = ep93xx_pwm_polarity(chip, pwm, state->polarity);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!state->enabled) {
|
||||||
|
if (enabled)
|
||||||
|
ep93xx_pwm_disable(chip, pwm);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state->period != pwm->state.period ||
|
||||||
|
state->duty_cycle != pwm->state.duty_cycle) {
|
||||||
|
ret = ep93xx_pwm_config(chip, pwm, (int)state->duty_cycle,
|
||||||
|
(int)state->period);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!enabled)
|
||||||
|
return ep93xx_pwm_enable(chip, pwm);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct pwm_ops ep93xx_pwm_ops = {
|
static const struct pwm_ops ep93xx_pwm_ops = {
|
||||||
.request = ep93xx_pwm_request,
|
.request = ep93xx_pwm_request,
|
||||||
.free = ep93xx_pwm_free,
|
.free = ep93xx_pwm_free,
|
||||||
.config = ep93xx_pwm_config,
|
.apply = ep93xx_pwm_apply,
|
||||||
.set_polarity = ep93xx_pwm_polarity,
|
|
||||||
.enable = ep93xx_pwm_enable,
|
|
||||||
.disable = ep93xx_pwm_disable,
|
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue