@@ -21,19 +21,24 @@ LOG_MODULE_REGISTER(dma_esp32_gdma, CONFIG_DMA_LOG_LEVEL);
21
21
#include <zephyr/drivers/dma.h>
22
22
#include <zephyr/drivers/dma/dma_esp32.h>
23
23
#include <zephyr/drivers/clock_control.h>
24
- #ifndef CONFIG_SOC_SERIES_ESP32C3
25
- #include <zephyr/drivers/interrupt_controller/intc_esp32.h>
26
- #else
24
+ #if defined(CONFIG_SOC_SERIES_ESP32C3 ) || defined(CONFIG_SOC_SERIES_ESP32C6 )
27
25
#include <zephyr/drivers/interrupt_controller/intc_esp32c3.h>
26
+ #else
27
+ #include <zephyr/drivers/interrupt_controller/intc_esp32.h>
28
28
#endif
29
29
30
- #ifdef CONFIG_SOC_SERIES_ESP32C3
30
+ #if defined( CONFIG_SOC_SERIES_ESP32C3 ) || defined( CONFIG_SOC_SERIES_ESP32C6 )
31
31
#define ISR_HANDLER isr_handler_t
32
32
#else
33
33
#define ISR_HANDLER intr_handler_t
34
34
#endif
35
35
36
+ #if defined(CONFIG_SOC_SERIES_ESP32C6 )
37
+ #define DMA_MAX_CHANNEL SOC_GDMA_PAIRS_PER_GROUP_MAX
38
+ #else
36
39
#define DMA_MAX_CHANNEL SOC_GDMA_PAIRS_PER_GROUP
40
+ #endif
41
+
37
42
#define ESP_DMA_M2M_ON 0
38
43
#define ESP_DMA_M2M_OFF 1
39
44
@@ -103,6 +108,7 @@ static void IRAM_ATTR dma_esp32_isr_handle_tx(const struct device *dev,
103
108
}
104
109
}
105
110
111
+ #if !defined(CONFIG_SOC_SERIES_ESP32C6 )
106
112
static void IRAM_ATTR dma_esp32_isr_handle (const struct device * dev , uint8_t rx_id , uint8_t tx_id )
107
113
{
108
114
struct dma_esp32_config * config = (struct dma_esp32_config * )dev -> config ;
@@ -121,6 +127,7 @@ static void IRAM_ATTR dma_esp32_isr_handle(const struct device *dev, uint8_t rx_
121
127
dma_esp32_isr_handle_tx (dev , dma_channel_tx , intr_status );
122
128
}
123
129
}
130
+ #endif
124
131
125
132
#if defined(CONFIG_SOC_SERIES_ESP32C3 )
126
133
static int dma_esp32_enable_interrupt (const struct device * dev ,
@@ -138,6 +145,20 @@ static int dma_esp32_disable_interrupt(const struct device *dev,
138
145
139
146
return esp_intr_disable (config -> irq_src [dma_channel -> channel_id ]);
140
147
}
148
+ #elif defined(CONFIG_SOC_SERIES_ESP32C6 )
149
+ static int dma_esp32_enable_interrupt (const struct device * dev , uint32_t channel )
150
+ {
151
+ struct dma_esp32_config * config = (struct dma_esp32_config * )dev -> config ;
152
+
153
+ return esp_intr_enable (config -> irq_src [channel ]);
154
+ }
155
+
156
+ static int dma_esp32_disable_interrupt (const struct device * dev , uint32_t channel )
157
+ {
158
+ struct dma_esp32_config * config = (struct dma_esp32_config * )dev -> config ;
159
+
160
+ return esp_intr_disable (config -> irq_src [channel ]);
161
+ }
141
162
#else
142
163
static int dma_esp32_enable_interrupt (const struct device * dev ,
143
164
struct dma_esp32_channel * dma_channel )
@@ -338,7 +359,11 @@ static int dma_esp32_start(const struct device *dev, uint32_t channel)
338
359
return - EINVAL ;
339
360
}
340
361
362
+ #if defined(CONFIG_SOC_SERIES_ESP32C6 )
363
+ if (dma_esp32_enable_interrupt (dev , channel )) {
364
+ #else
341
365
if (dma_esp32_enable_interrupt (dev , dma_channel )) {
366
+ #endif
342
367
return - EINVAL ;
343
368
}
344
369
@@ -384,7 +409,11 @@ static int dma_esp32_stop(const struct device *dev, uint32_t channel)
384
409
return - EINVAL ;
385
410
}
386
411
412
+ #if defined(CONFIG_SOC_SERIES_ESP32C6 )
413
+ if (dma_esp32_disable_interrupt (dev , channel )) {
414
+ #else
387
415
if (dma_esp32_disable_interrupt (dev , dma_channel )) {
416
+ #endif
388
417
return - EINVAL ;
389
418
}
390
419
@@ -470,7 +499,7 @@ static int dma_esp32_reload(const struct device *dev, uint32_t channel, uint32_t
470
499
return 0 ;
471
500
}
472
501
473
- #if defined(CONFIG_SOC_SERIES_ESP32C3 )
502
+ #if defined(CONFIG_SOC_SERIES_ESP32C3 ) || defined( CONFIG_SOC_SERIES_ESP32C6 )
474
503
static int dma_esp32_configure_irq (const struct device * dev )
475
504
{
476
505
struct dma_esp32_config * config = (struct dma_esp32_config * )dev -> config ;
@@ -559,14 +588,49 @@ static const struct dma_driver_api dma_esp32_api = {
559
588
.reload = dma_esp32_reload ,
560
589
};
561
590
591
+ #if defined(CONFIG_SOC_SERIES_ESP32C6 )
592
+
593
+ #define DMA_ESP32_DEFINE_IRQ_HANDLER (channel ) \
594
+ __attribute__((unused)) static void IRAM_ATTR dma_esp32_isr_##channel##_rx( \
595
+ const struct device *dev) \
596
+ { \
597
+ struct dma_esp32_config *config = (struct dma_esp32_config *)dev->config; \
598
+ struct dma_esp32_data *data = (struct dma_esp32_data *const)(dev)->data; \
599
+ uint32_t intr_status = gdma_ll_rx_get_interrupt_status(data->hal.dev, channel); \
600
+ if (intr_status) { \
601
+ dma_esp32_isr_handle_rx(dev, &config->dma_channel[channel * 2], \
602
+ intr_status); \
603
+ } \
604
+ } \
605
+ \
606
+ __attribute__((unused)) static void IRAM_ATTR dma_esp32_isr_##channel##_tx( \
607
+ const struct device *dev) \
608
+ { \
609
+ struct dma_esp32_config *config = (struct dma_esp32_config *)dev->config; \
610
+ struct dma_esp32_data *data = (struct dma_esp32_data *const)(dev)->data; \
611
+ uint32_t intr_status = gdma_ll_tx_get_interrupt_status(data->hal.dev, channel); \
612
+ if (intr_status) { \
613
+ dma_esp32_isr_handle_tx(dev, &config->dma_channel[channel * 2 + 1], \
614
+ intr_status); \
615
+ } \
616
+ }
617
+
618
+ #else
619
+
562
620
#define DMA_ESP32_DEFINE_IRQ_HANDLER (channel ) \
563
621
__attribute__((unused)) static void IRAM_ATTR dma_esp32_isr_##channel( \
564
622
const struct device *dev) \
565
623
{ \
566
624
dma_esp32_isr_handle(dev, channel * 2, channel * 2 + 1); \
567
625
}
568
626
627
+ #endif
628
+
629
+ #if defined(CONFIG_SOC_SERIES_ESP32C6 )
630
+ #define ESP32_DMA_HANDLER (channel ) dma_esp32_isr_##channel##_rx, dma_esp32_isr_##channel##_tx
631
+ #else
569
632
#define ESP32_DMA_HANDLER (channel ) dma_esp32_isr_##channel
633
+ #endif
570
634
571
635
DMA_ESP32_DEFINE_IRQ_HANDLER (0 )
572
636
DMA_ESP32_DEFINE_IRQ_HANDLER (1 )
0 commit comments