提交 174dcc8e 编写于 作者: P Paul Cercueil 提交者: Thierry Reding

pwm: jz4740: Implement ->set_polarity()

This permits clients of this driver to specify the polarity to use for
their PWM channel.
Signed-off-by: NPaul Cercueil <paul@crapouillou.net>
Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
上级 df56b171
...@@ -130,10 +130,29 @@ static int jz4740_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, ...@@ -130,10 +130,29 @@ static int jz4740_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
return 0; return 0;
} }
static int jz4740_pwm_set_polarity(struct pwm_chip *chip,
struct pwm_device *pwm, enum pwm_polarity polarity)
{
uint32_t ctrl = jz4740_timer_get_ctrl(pwm->pwm);
switch (polarity) {
case PWM_POLARITY_NORMAL:
ctrl &= ~JZ_TIMER_CTRL_PWM_ACTIVE_LOW;
break;
case PWM_POLARITY_INVERSED:
ctrl |= JZ_TIMER_CTRL_PWM_ACTIVE_LOW;
break;
}
jz4740_timer_set_ctrl(pwm->hwpwm, ctrl);
return 0;
}
static const struct pwm_ops jz4740_pwm_ops = { static const struct pwm_ops jz4740_pwm_ops = {
.request = jz4740_pwm_request, .request = jz4740_pwm_request,
.free = jz4740_pwm_free, .free = jz4740_pwm_free,
.config = jz4740_pwm_config, .config = jz4740_pwm_config,
.set_polarity = jz4740_pwm_set_polarity,
.enable = jz4740_pwm_enable, .enable = jz4740_pwm_enable,
.disable = jz4740_pwm_disable, .disable = jz4740_pwm_disable,
.owner = THIS_MODULE, .owner = THIS_MODULE,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册