Skip to content

Commit 0cb755a

Browse files
Raffael Rostagnokartben
authored andcommitted
drivers: mcpwm: esp32c6: Add support
Add MCPWM support to ESP32C6 Signed-off-by: Raffael Rostagno <[email protected]>
1 parent 87cec85 commit 0cb755a

File tree

3 files changed

+1405
-1298
lines changed

3 files changed

+1405
-1298
lines changed

drivers/pwm/pwm_mc_esp32.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,21 @@
1919
#include <zephyr/drivers/clock_control.h>
2020
#include <esp_clk_tree.h>
2121
#ifdef CONFIG_PWM_CAPTURE
22+
#if defined(CONFIG_RISCV)
23+
#include <zephyr/drivers/interrupt_controller/intc_esp32c3.h>
24+
#else
2225
#include <zephyr/drivers/interrupt_controller/intc_esp32.h>
26+
#endif
2327
#endif /* CONFIG_PWM_CAPTURE */
2428
#include <zephyr/logging/log.h>
2529
LOG_MODULE_REGISTER(mcpwm_esp32, CONFIG_PWM_LOG_LEVEL);
2630

31+
#if defined(CONFIG_RISCV)
32+
#define ISR_HANDLER isr_handler_t
33+
#else
34+
#define ISR_HANDLER intr_handler_t
35+
#endif
36+
2737
#ifdef CONFIG_PWM_CAPTURE
2838
#define SKIP_IRQ_NUM 4U
2939
#define CAP_INT_MASK 7U
@@ -544,7 +554,7 @@ static DEVICE_API(pwm, mcpwm_esp32_api) = {
544554
ESP_PRIO_TO_FLAGS(DT_INST_IRQ_BY_IDX(idx, 0, priority)) | \
545555
ESP_INT_FLAGS_CHECK(DT_INST_IRQ_BY_IDX(idx, 0, flags)) | \
546556
ESP_INTR_FLAG_IRAM, \
547-
(intr_handler_t)mcpwm_esp32_isr, (void *)dev, NULL); \
557+
(ISR_HANDLER)mcpwm_esp32_isr, (void *)dev, NULL); \
548558
return ret; \
549559
}
550560
#define CAPTURE_INIT(idx) .irq_config_func = mcpwm_esp32_irq_config_func_##idx

dts/riscv/espressif/esp32c6/esp32c6_common.dtsi

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,5 +241,15 @@
241241
clocks = <&rtc ESP32_LEDC_MODULE>;
242242
status = "disabled";
243243
};
244+
245+
mcpwm0: mcpwm@60014000 {
246+
compatible = "espressif,esp32-mcpwm";
247+
reg = <0x60014000 DT_SIZE_K(4)>;
248+
interrupts = <MCPWM0_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
249+
interrupt-parent = <&intc>;
250+
clocks = <&rtc ESP32_MCPWM0_MODULE>;
251+
#pwm-cells = <3>;
252+
status = "disabled";
253+
};
244254
};
245255
};

0 commit comments

Comments
 (0)