From fc8119deed409ca4579fcb25889a8818c6e44d45 Mon Sep 17 00:00:00 2001 From: Raffael Rostagno Date: Sun, 12 Jan 2025 10:25:22 -0300 Subject: [PATCH] drivers: pwm_led: esp32: Add inverted flag Add inverted flag to bindings, as pwms field is supposed to be used by application only. Signed-off-by: Raffael Rostagno --- drivers/pwm/pwm_led_esp32.c | 2 +- dts/bindings/pwm/espressif,esp32-ledc.yaml | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm_led_esp32.c b/drivers/pwm/pwm_led_esp32.c index 83556e07479a..f2a46abd886e 100644 --- a/drivers/pwm/pwm_led_esp32.c +++ b/drivers/pwm/pwm_led_esp32.c @@ -400,7 +400,7 @@ PINCTRL_DT_INST_DEFINE(0); .timer_num = DT_PROP(node_id, timer), \ .speed_mode = DT_REG_ADDR(node_id) < SOC_LEDC_CHANNEL_NUM ? LEDC_LOW_SPEED_MODE \ : !LEDC_LOW_SPEED_MODE, \ - .inverted = DT_PWMS_FLAGS(node_id), \ + .inverted = DT_PROP(node_id, inverted), \ }, static struct pwm_ledc_esp32_channel_config channel_config[] = { diff --git a/dts/bindings/pwm/espressif,esp32-ledc.yaml b/dts/bindings/pwm/espressif,esp32-ledc.yaml index 39d4c3c59fee..e46a7c787609 100644 --- a/dts/bindings/pwm/espressif,esp32-ledc.yaml +++ b/dts/bindings/pwm/espressif,esp32-ledc.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Espressif Systems (Shanghai) Co., Ltd. +# Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd. # SPDX-License-Identifier: Apache-2.0 description: | @@ -64,6 +64,7 @@ description: | channel9@9 { reg = <0x9>; timer = <0>; + inverted; }; channel10@a { reg = <0xa>; @@ -71,6 +72,9 @@ description: | }; }; + For the channel to be initially inverted after the driver's init, the flag 'inverted' can + be declared, as shown above for channel 9. + Note: The channel's 'reg' property defines the ID of the channel. It must match the channel used in the 'pinmux'. @@ -130,6 +134,14 @@ child-binding: For maximum flexibility, the high-speed as well as the low-speed channels can be driven from one of four high-speed/low-speed timers. + inverted: + type: boolean + description: | + Initial channel output level. + This flag defines if the channel will remain initially inverted after driver init, + as any pwm_set() operation will re-evaluate if the output is inverted or not + according to the flag passed as parameter. + pwm-cells: - channel - period