Skip to content

Commit b9fc4cc

Browse files
Raffael Rostagnommahadevan108
authored andcommitted
drivers: pwm: ledc: esp32c2: esp32c6: Fix clock frequency
Fix clock frequency for both devices. Signed-off-by: Raffael Rostagno <[email protected]>
1 parent ba52c8c commit b9fc4cc

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

drivers/pwm/pwm_led_esp32.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@
2222
#include <zephyr/logging/log.h>
2323
LOG_MODULE_REGISTER(pwm_ledc_esp32, CONFIG_PWM_LOG_LEVEL);
2424

25+
#if SOC_LEDC_SUPPORT_APB_CLOCK
26+
#define CLOCK_SOURCE LEDC_APB_CLK
27+
#elif SOC_LEDC_SUPPORT_PLL_DIV_CLOCK
28+
#define CLOCK_SOURCE LEDC_SCLK
29+
#if defined(CONFIG_SOC_SERIES_ESP32C2)
30+
#define SCLK_CLK_FREQ MHZ(60)
31+
#elif defined(CONFIG_SOC_SERIES_ESP32C6)
32+
#define SCLK_CLK_FREQ MHZ(80)
33+
#endif
34+
#endif
35+
2536
struct pwm_ledc_esp32_data {
2637
ledc_hal_context_t hal;
2738
struct k_sem cmd_sem;
@@ -350,12 +361,6 @@ static const struct pwm_driver_api pwm_led_esp32_api = {
350361

351362
PINCTRL_DT_INST_DEFINE(0);
352363

353-
#if SOC_LEDC_SUPPORT_APB_CLOCK
354-
#define CLOCK_SOURCE LEDC_APB_CLK
355-
#elif SOC_LEDC_SUPPORT_PLL_DIV_CLOCK
356-
#define CLOCK_SOURCE LEDC_SCLK
357-
#endif
358-
359364
#define CHANNEL_CONFIG(node_id) \
360365
{ \
361366
.idx = DT_REG_ADDR(node_id), \

0 commit comments

Comments
 (0)