drivers: pwm: add support for inverted PWM signals

Add support for requesting an inverted PWM pulse (active-low) when
setting up the period and pulse width of a PWM pin. This is useful
when driving external, active-low circuitry (e.g. an LED) with a PWM
signal.

All in-tree PWM drivers is updated to match the new API signature, but
no driver support for inverted PWM signals is added yet.

All in-tree PWM consumers are updated to pass a flags value of 0
(0 meaning default, which is normal PWM polarity).

Fixes #21384.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
Henrik Brix Andersen 2019-11-13 14:46:37 +01:00 committed by Carles Cufí
commit db611e6781
24 changed files with 152 additions and 38 deletions

View file

@ -311,7 +311,7 @@ static int pwm_led_esp32_timer_set(int speed_mode, int timer,
/* period_cycles is not used, set frequency on menuconfig instead. */
static int pwm_led_esp32_pin_set_cycles(struct device *dev,
u32_t pwm, u32_t period_cycles,
u32_t pulse_cycles)
u32_t pulse_cycles, pwm_flags_t flags)
{
int speed_mode;
int channel;
@ -322,6 +322,11 @@ static int pwm_led_esp32_pin_set_cycles(struct device *dev,
ARG_UNUSED(period_cycles);
if (flags) {
/* PWM polarity not supported (yet?) */
return -ENOTSUP;
}
channel = pwm_led_esp32_get_gpio_config(pwm, config->ch_cfg);
if (channel < 0) {
return -EINVAL;