Skip to content

Commit 90c6106

Browse files
Raffael Rostagnonashif
authored andcommitted
drivers: esp32: Interrupts flags configuration
Allows configuring interrupts flags in the device tree for ESP32 devices. Signed-off-by: Raffael Rostagno <[email protected]>
1 parent bb746cd commit 90c6106

File tree

19 files changed

+74
-27
lines changed

19 files changed

+74
-27
lines changed

drivers/can/can_esp32_twai.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ struct can_esp32_twai_config {
7272
const clock_control_subsys_t clock_subsys;
7373
int irq_source;
7474
int irq_priority;
75+
int irq_flags;
7576
#ifndef CONFIG_SOC_SERIES_ESP32
7677
/* 32-bit variant of output clock divider register required for non-ESP32 MCUs */
7778
uint32_t cdr32;
@@ -204,7 +205,8 @@ static int can_esp32_twai_init(const struct device *dev)
204205
#endif /* !CONFIG_SOC_SERIES_ESP32 */
205206

206207
err = esp_intr_alloc(twai_config->irq_source,
207-
ESP_PRIO_TO_FLAGS(twai_config->irq_priority) | ESP_INTR_FLAG_IRAM,
208+
ESP_PRIO_TO_FLAGS(twai_config->irq_priority) |
209+
ESP_INT_FLAGS_CHECK(twai_config->irq_flags) | ESP_INTR_FLAG_IRAM,
208210
can_esp32_twai_isr, (void *)dev, NULL);
209211

210212
if (err != 0) {
@@ -280,6 +282,7 @@ const struct can_driver_api can_esp32_twai_driver_api = {
280282
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \
281283
.irq_source = DT_INST_IRQ_BY_IDX(inst, 0, irq), \
282284
.irq_priority = DT_INST_IRQ_BY_IDX(inst, 0, priority), \
285+
.irq_flags = DT_INST_IRQ_BY_IDX(inst, 0, flags), \
283286
TWAI_CDR32_INIT(inst) \
284287
}; \
285288
CAN_ESP32_TWAI_ASSERT_CLKOUT_DIVIDER(inst); \

drivers/counter/counter_esp32_rtc.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ struct counter_esp32_config {
4343
struct counter_config_info counter_info;
4444
int irq_source;
4545
int irq_priority;
46+
int irq_flags;
4647
const struct device *clock_dev;
4748
};
4849

@@ -57,14 +58,14 @@ static int counter_esp32_init(const struct device *dev)
5758
const struct counter_esp32_config *cfg = dev->config;
5859
struct counter_esp32_data *data = dev->data;
5960

60-
6161
/* RTC_SLOW_CLK is the default clk source */
6262
clock_control_get_rate(cfg->clock_dev,
6363
(clock_control_subsys_t)ESP32_CLOCK_CONTROL_SUBSYS_RTC_SLOW,
6464
&data->clk_src_freq);
6565

6666
int ret = esp_intr_alloc(cfg->irq_source,
67-
ESP_PRIO_TO_FLAGS(cfg->irq_priority),
67+
ESP_PRIO_TO_FLAGS(cfg->irq_priority) |
68+
ESP_INT_FLAGS_CHECK(cfg->irq_flags),
6869
(ESP32_COUNTER_RTC_ISR_HANDLER)counter_esp32_isr,
6970
(void *)dev,
7071
NULL);
@@ -206,7 +207,8 @@ static const struct counter_esp32_config counter_config = {
206207
},
207208
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(0)),
208209
.irq_source = DT_INST_IRQ_BY_IDX(0, 0, irq),
209-
.irq_priority = DT_INST_IRQ_BY_IDX(0, 0, priority)
210+
.irq_priority = DT_INST_IRQ_BY_IDX(0, 0, priority),
211+
.irq_flags = DT_INST_IRQ_BY_IDX(0, 0, flags)
210212
};
211213

212214
static const struct counter_driver_api rtc_timer_esp32_api = {

drivers/counter/counter_esp32_tmr.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ struct counter_esp32_config {
5151
timer_idx_t index;
5252
int irq_source;
5353
int irq_priority;
54+
int irq_flags;
5455
};
5556

5657
struct counter_esp32_data {
@@ -99,7 +100,8 @@ static int counter_esp32_init(const struct device *dev)
99100
k_spin_unlock(&lock, key);
100101

101102
int ret = esp_intr_alloc(cfg->irq_source,
102-
ESP_PRIO_TO_FLAGS(cfg->irq_priority),
103+
ESP_PRIO_TO_FLAGS(cfg->irq_priority) |
104+
ESP_INT_FLAGS_CHECK(cfg->irq_flags),
103105
(ISR_HANDLER)counter_esp32_isr, (void *)dev, NULL);
104106

105107
if (ret != 0) {
@@ -264,7 +266,8 @@ static void counter_esp32_isr(void *arg)
264266
.group = DT_INST_PROP(idx, group), \
265267
.index = DT_INST_PROP(idx, index), \
266268
.irq_source = DT_INST_IRQ_BY_IDX(idx, 0, irq), \
267-
.irq_priority = DT_INST_IRQ_BY_IDX(idx, 0, priority) \
269+
.irq_priority = DT_INST_IRQ_BY_IDX(idx, 0, priority), \
270+
.irq_flags = DT_INST_IRQ_BY_IDX(idx, 0, flags) \
268271
}; \
269272
\
270273
\

drivers/dma/dma_esp32_gdma.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ enum dma_channel_dir {
5555
struct irq_config {
5656
uint8_t irq_source;
5757
uint8_t irq_priority;
58+
int irq_flags;
5859
};
5960

6061
struct dma_esp32_channel {
@@ -548,10 +549,11 @@ static int dma_esp32_configure_irq(const struct device *dev)
548549

549550
for (uint8_t i = 0; i < config->irq_size; i++) {
550551
int ret = esp_intr_alloc(irq_cfg[i].irq_source,
551-
ESP_PRIO_TO_FLAGS(irq_cfg[i].irq_priority) | ESP_INTR_FLAG_IRAM,
552-
(ISR_HANDLER)config->irq_handlers[i],
553-
(void *)dev,
554-
NULL);
552+
ESP_PRIO_TO_FLAGS(irq_cfg[i].irq_priority) |
553+
ESP_INT_FLAGS_CHECK(irq_cfg[i].irq_flags) | ESP_INTR_FLAG_IRAM,
554+
(ISR_HANDLER)config->irq_handlers[i],
555+
(void *)dev,
556+
NULL);
555557
if (ret != 0) {
556558
LOG_ERR("Could not allocate interrupt handler");
557559
return ret;
@@ -670,8 +672,10 @@ static void *irq_handlers[] = {
670672
};
671673

672674
#define IRQ_NUM(idx) DT_NUM_IRQS(DT_DRV_INST(idx))
673-
#define IRQ_ENTRY(n, idx) \
674-
{ DT_INST_IRQ_BY_IDX(idx, n, irq), DT_INST_IRQ_BY_IDX(idx, n, priority) },
675+
#define IRQ_ENTRY(n, idx) { \
676+
DT_INST_IRQ_BY_IDX(idx, n, irq), \
677+
DT_INST_IRQ_BY_IDX(idx, n, priority), \
678+
DT_INST_IRQ_BY_IDX(idx, n, flags) },
675679

676680
#define DMA_ESP32_INIT(idx) \
677681
static struct irq_config irq_config_##idx[] = { \

drivers/ethernet/eth_esp32.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ int eth_esp32_initialize(const struct device *dev)
263263
/* Configure ISR */
264264
res = esp_intr_alloc(DT_IRQ_BY_IDX(DT_NODELABEL(eth), 0, irq),
265265
ESP_PRIO_TO_FLAGS(DT_IRQ_BY_IDX(DT_NODELABEL(eth), 0, priority)) |
266+
ESP_INT_FLAGS_CHECK(DT_IRQ_BY_IDX(DT_NODELABEL(eth), 0, flags)) |
266267
ESP_INTR_FLAG_IRAM,
267268
eth_esp32_isr,
268269
(void *)dev,

drivers/gpio/gpio_esp32.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,8 @@ static int gpio_esp32_init(const struct device *dev)
479479

480480
if (!isr_connected) {
481481
int ret = esp_intr_alloc(DT_IRQ_BY_IDX(DT_NODELABEL(gpio0), 0, irq),
482-
ESP_PRIO_TO_FLAGS(DT_IRQ_BY_IDX(DT_NODELABEL(gpio0), 0, priority)),
482+
ESP_PRIO_TO_FLAGS(DT_IRQ_BY_IDX(DT_NODELABEL(gpio0), 0, priority)) |
483+
ESP_INT_FLAGS_CHECK(DT_IRQ_BY_IDX(DT_NODELABEL(gpio0), 0, flags)),
483484
(ISR_HANDLER)gpio_esp32_isr,
484485
(void *)dev,
485486
NULL);

drivers/i2c/i2c_esp32.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ struct i2c_esp32_config {
9191

9292
int irq_source;
9393
int irq_priority;
94+
int irq_flags;
9495

9596
const uint32_t bitrate;
9697
const uint32_t scl_timeout;
@@ -763,7 +764,8 @@ static int IRAM_ATTR i2c_esp32_init(const struct device *dev)
763764
clock_control_on(config->clock_dev, config->clock_subsys);
764765

765766
ret = esp_intr_alloc(config->irq_source,
766-
ESP_PRIO_TO_FLAGS(config->irq_priority) | ESP_INTR_FLAG_IRAM,
767+
ESP_PRIO_TO_FLAGS(config->irq_priority) |
768+
ESP_INT_FLAGS_CHECK(config->irq_flags) | ESP_INTR_FLAG_IRAM,
767769
i2c_esp32_isr,
768770
(void *)dev,
769771
NULL);
@@ -834,6 +836,7 @@ static int IRAM_ATTR i2c_esp32_init(const struct device *dev)
834836
}, \
835837
.irq_source = DT_INST_IRQ_BY_IDX(idx, 0, irq), \
836838
.irq_priority = DT_INST_IRQ_BY_IDX(idx, 0, priority), \
839+
.irq_flags = DT_INST_IRQ_BY_IDX(idx, 0, flags), \
837840
.bitrate = I2C_FREQUENCY(idx), \
838841
.scl_timeout = I2C_ESP32_TIMEOUT(idx), \
839842
}; \

drivers/input/input_esp32_touch_sensor.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,9 @@ static esp_err_t esp32_rtc_isr_install(intr_handler_t intr_handler, const void *
164164
REG_WRITE(RTC_CNTL_INT_CLR_REG, UINT32_MAX);
165165

166166
err = esp_intr_alloc(DT_IRQ_BY_IDX(DT_NODELABEL(touch), 0, irq),
167-
ESP_PRIO_TO_FLAGS(DT_IRQ_BY_IDX(DT_NODELABEL(touch), 0, priority)),
168-
intr_handler, (void *)handler_arg, NULL);
167+
ESP_PRIO_TO_FLAGS(DT_IRQ_BY_IDX(DT_NODELABEL(touch), 0, priority)) |
168+
ESP_INT_FLAGS_CHECK(DT_IRQ_BY_IDX(DT_NODELABEL(touch), 0, flags)),
169+
intr_handler, (void *)handler_arg, NULL);
169170

170171
return err;
171172
}

drivers/ipm/ipm_esp32.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ struct esp32_ipm_memory {
3535
struct esp32_ipm_config {
3636
int irq_source_pro_cpu;
3737
int irq_priority_pro_cpu;
38+
int irq_flags_pro_cpu;
3839
int irq_source_app_cpu;
3940
int irq_priority_app_cpu;
41+
int irq_flags_app_cpu;
4042
};
4143

4244
struct esp32_ipm_data {
@@ -222,6 +224,7 @@ static int esp32_ipm_init(const struct device *dev)
222224
if (data->this_core_id == 0) {
223225
ret = esp_intr_alloc(cfg->irq_source_pro_cpu,
224226
ESP_PRIO_TO_FLAGS(cfg->irq_priority_pro_cpu) |
227+
ESP_INT_FLAGS_CHECK(cfg->irq_flags_pro_cpu) |
225228
ESP_INTR_FLAG_IRAM,
226229
(intr_handler_t)esp32_ipm_isr,
227230
(void *)dev,
@@ -239,6 +242,7 @@ static int esp32_ipm_init(const struct device *dev)
239242
*/
240243
ret = esp_intr_alloc(cfg->irq_source_app_cpu,
241244
ESP_PRIO_TO_FLAGS(cfg->irq_priority_app_cpu) |
245+
ESP_INT_FLAGS_CHECK(cfg->irq_flags_app_cpu) |
242246
ESP_INTR_FLAG_IRAM,
243247
(intr_handler_t)esp32_ipm_isr,
244248
(void *)dev,
@@ -283,8 +287,10 @@ static const struct ipm_driver_api esp32_ipm_driver_api = {
283287
static struct esp32_ipm_config esp32_ipm_device_cfg_##idx = { \
284288
.irq_source_pro_cpu = DT_INST_IRQ_BY_IDX(idx, 0, irq), \
285289
.irq_priority_pro_cpu = DT_INST_IRQ_BY_IDX(idx, 0, priority), \
290+
.irq_flags_pro_cpu = DT_INST_IRQ_BY_IDX(idx, 0, flags), \
286291
.irq_source_app_cpu = DT_INST_IRQ_BY_IDX(idx, 1, irq), \
287292
.irq_priority_app_cpu = DT_INST_IRQ_BY_IDX(idx, 1, priority), \
293+
.irq_flags_app_cpu = DT_INST_IRQ_BY_IDX(idx, 1, flags), \
288294
}; \
289295
\
290296
static struct esp32_ipm_data esp32_ipm_device_data_##idx = { \

drivers/pwm/pwm_mc_esp32.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,8 @@ static const struct pwm_driver_api mcpwm_esp32_api = {
540540
int ret; \
541541
ret = esp_intr_alloc(DT_INST_IRQ_BY_IDX(idx, 0, irq), \
542542
ESP_PRIO_TO_FLAGS(DT_INST_IRQ_BY_IDX(idx, 0, priority)) | \
543-
ESP_INTR_FLAG_IRAM, \
543+
ESP_INT_FLAGS_CHECK(DT_INST_IRQ_BY_IDX(idx, 0, flags)) | \
544+
ESP_INTR_FLAG_IRAM, \
544545
(intr_handler_t)mcpwm_esp32_isr, (void *)dev, NULL); \
545546
return ret; \
546547
}

0 commit comments

Comments
 (0)