Message ID | 20180106165843.3461-2-paul@crapouillou.net |
---|---|
State | Accepted |
Headers | show |
Series | [1/4] pwm: jz4740: Make disable operation compatible with TCU2 mode | expand |
Hi, Could this patchset get a bit of love? I have other changes waiting for this patchset to get in, so it'd be great to see it in 4.17-rc1. Thanks, -Paul Le sam. 6 janv. 2018 à 17:58, Paul Cercueil <paul@crapouillou.net> a écrit : > This permits clients of this driver to specify the polarity to use for > their PWM channel. > > Signed-off-by: Paul Cercueil <paul@crapouillou.net> > --- > drivers/pwm/pwm-jz4740.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c > index 2e41ba213f39..6539c001fe32 100644 > --- a/drivers/pwm/pwm-jz4740.c > +++ b/drivers/pwm/pwm-jz4740.c > @@ -130,10 +130,29 @@ static int jz4740_pwm_config(struct pwm_chip > *chip, struct pwm_device *pwm, > 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 = { > .request = jz4740_pwm_request, > .free = jz4740_pwm_free, > .config = jz4740_pwm_config, > + .set_polarity = jz4740_pwm_set_polarity, > .enable = jz4740_pwm_enable, > .disable = jz4740_pwm_disable, > .owner = THIS_MODULE, > -- > 2.11.0 > -- To unsubscribe from this list: send the line "unsubscribe linux-pwm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c index 2e41ba213f39..6539c001fe32 100644 --- a/drivers/pwm/pwm-jz4740.c +++ b/drivers/pwm/pwm-jz4740.c @@ -130,10 +130,29 @@ static int jz4740_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, 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 = { .request = jz4740_pwm_request, .free = jz4740_pwm_free, .config = jz4740_pwm_config, + .set_polarity = jz4740_pwm_set_polarity, .enable = jz4740_pwm_enable, .disable = jz4740_pwm_disable, .owner = THIS_MODULE,
This permits clients of this driver to specify the polarity to use for their PWM channel. Signed-off-by: Paul Cercueil <paul@crapouillou.net> --- drivers/pwm/pwm-jz4740.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)