esp32s3/wifi: Enable peripheral interrupt to the same CPU interrupt

The low-level Wi-Fi driver registers two peripheral interrupts to
the same CPU interrupt. Although the registered ISR is the same for
both peripherals interrupt, it's needed to call `up_enable_irq` to
ensure that the interrupt matrix is being set accordingly.

Please note that the current implementation of the  ESP32-S3's IRQ
driver - although allow us to set a callback for each IRQ, which
represents the peripherals interrupt - doesn't allow us to call
both callbacks when these IRQs refers to a same CPU interrupt.
`g_cpu0_intmap` (or `g_cpu1_intmap`) associates each CPU interrupt
to a single IRQ/peripheral and, then, when a CPU interrupt is
triggered, only the last registered IRQ's callback will be called.
This isn't a problem here because 1) the registered callback is the
same for both IRQ's (in fact, it considers the CPU interrupt) and
2) we know in advance which peripheral interrupts will be attached
to which CPU interrupt and, then, we can set them directly.
This commit is contained in:
Tiago Medicci Serrano 2023-08-08 10:20:15 -03:00 committed by Alan Carvalho de Assis
parent 655d00b1e7
commit 7d605551cd
3 changed files with 18 additions and 6 deletions

View File

@ -446,6 +446,7 @@
#define ESP32S3_CPUINT_NMISET 0x00004000
#define ESP32S3_CPUINT_MAC 0
#define ESP32S3_CPUINT_PWR 0
#define ESP32S3_CPUINT_RWBLE 5
#define ESP32S3_CPUINT_TIMER0 6
#define ESP32S3_CPUINT_SOFTWARE0 7

View File

@ -431,6 +431,7 @@ void up_irqinitialize(void)
#ifdef CONFIG_ESP32S3_WIFI
g_irqmap[ESP32S3_IRQ_MAC] = IRQ_MKMAP(0, ESP32S3_CPUINT_MAC);
g_irqmap[ESP32S3_IRQ_PWR] = IRQ_MKMAP(0, ESP32S3_CPUINT_PWR);
#endif
#ifdef CONFIG_ESP32S3_BLE
@ -445,7 +446,8 @@ void up_irqinitialize(void)
/* Reserve CPU0 interrupt for some special drivers */
#ifdef CONFIG_ESP32S3_WIFI
g_cpu0_intmap[ESP32S3_CPUINT_MAC] = CPUINT_ASSIGN(ESP32S3_IRQ_MAC);
g_cpu0_intmap[ESP32S3_CPUINT_MAC] = CPUINT_ASSIGN(ESP32S3_IRQ_MAC);
g_cpu0_intmap[ESP32S3_CPUINT_PWR] = CPUINT_ASSIGN(ESP32S3_IRQ_PWR);
xtensa_enable_cpuint(&g_intenable[0], 1 << ESP32S3_CPUINT_MAC);
#endif

View File

@ -740,14 +740,14 @@ static void esp_set_isr(int32_t n, void *f, void *arg)
struct irq_adpt *adapter;
int irq = n + XTENSA_IRQ_FIRSTPERIPH;
wlinfo("n=%d f=%p arg=%p irq=%d\n", n, f, arg, irq);
wlinfo("n=%d f=%p arg=%p", n, f, arg);
if (g_irqvector[irq].handler &&
g_irqvector[irq].handler != irq_unexpected_isr)
{
wlinfo("irq=%d has been set handler=%p\n", irq,
g_irqvector[irq].handler);
return ;
return;
}
tmp = sizeof(struct irq_adpt);
@ -756,18 +756,26 @@ static void esp_set_isr(int32_t n, void *f, void *arg)
{
wlerr("Failed to alloc %d memory\n", tmp);
assert(0);
return ;
return;
}
adapter->func = f;
adapter->arg = arg;
ret = irq_attach(irq, esp_int_adpt_cb, adapter);
ret = irq_attach(ESP32S3_IRQ_MAC, esp_int_adpt_cb, adapter);
if (ret)
{
wlerr("Failed to attach IRQ %d\n", irq);
assert(0);
return ;
return;
}
ret = irq_attach(ESP32S3_IRQ_PWR, esp_int_adpt_cb, adapter);
if (ret)
{
wlerr("Failed to attach IRQ %d\n", irq);
assert(0);
return;
}
}
@ -792,6 +800,7 @@ static void esp32s3_ints_on(uint32_t mask)
wlinfo("INFO mask=%08x irq=%d\n", mask, irq);
up_enable_irq(ESP32S3_IRQ_MAC);
up_enable_irq(ESP32S3_IRQ_PWR);
}
/****************************************************************************