mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(esp32p4): Fixed interrupt handling to use the CLIC controller
This commit is contained in:
@@ -156,21 +156,32 @@ void esp_cpu_wait_for_intr(void)
|
||||
|
||||
#if SOC_CPU_HAS_FLEXIBLE_INTC
|
||||
|
||||
|
||||
#if SOC_INT_CLIC_SUPPORTED
|
||||
|
||||
static bool is_intr_num_resv(int ext_intr_num) {
|
||||
/* On targets that uses CLIC as the interrupt controller, the first 16 lines (0..15) are reserved for software
|
||||
* interrupts, all the other lines starting from 16 and above can be used by external peripheral.
|
||||
* in the case of this function, the parameter only refers to the external peripheral index, so if
|
||||
* `ext_intr_num` is 0, it refers to interrupt index 16.
|
||||
*
|
||||
* Only interrupt line 6 is reserved at the moment since it is used for disabling interrupts */
|
||||
return ext_intr_num == 6;
|
||||
}
|
||||
|
||||
#else // !SOC_INT_CLIC_SUPPORTED
|
||||
|
||||
static bool is_intr_num_resv(int intr_num)
|
||||
{
|
||||
// Workaround to reserve interrupt number 1 for Wi-Fi, 5,8 for Bluetooth, 6 for "permanently disabled interrupt"
|
||||
// [TODO: IDF-2465]
|
||||
uint32_t reserved = BIT(1) | BIT(5) | BIT(6) | BIT(8);
|
||||
|
||||
// int_num 0,3,4,7 are inavaliable for PULP cpu
|
||||
// int_num 0,3,4,7 are unavailable for PULP cpu
|
||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2// TODO: IDF-5728 replace with a better macro name
|
||||
reserved |= BIT(0) | BIT(3) | BIT(4) | BIT(7);
|
||||
#endif
|
||||
|
||||
#if SOC_INT_CLIC_SUPPORTED
|
||||
//TODO: IDF-7795
|
||||
return false;
|
||||
#endif
|
||||
if (reserved & BIT(intr_num)) {
|
||||
return true;
|
||||
}
|
||||
@@ -185,6 +196,8 @@ static bool is_intr_num_resv(int intr_num)
|
||||
return destination != (intptr_t)&_interrupt_handler;
|
||||
}
|
||||
|
||||
#endif // SOC_INT_CLIC_SUPPORTED
|
||||
|
||||
void esp_cpu_intr_get_desc(int core_id, int intr_num, esp_cpu_intr_desc_t *intr_desc_ret)
|
||||
{
|
||||
intr_desc_ret->priority = 1; //Todo: We should make this -1
|
||||
|
||||
@@ -233,7 +233,7 @@ FORCE_INLINE_ATTR void esp_cpu_intr_set_ivt_addr(const void *ivt_addr)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32P4
|
||||
#if SOC_INT_CLIC_SUPPORTED
|
||||
//TODO: IDF-7863
|
||||
//"MTVT is only implemented in RISC-V arch"
|
||||
/**
|
||||
@@ -245,7 +245,7 @@ FORCE_INLINE_ATTR void esp_cpu_intr_set_mtvt_addr(const void *mtvt_addr)
|
||||
{
|
||||
rv_utils_set_mtvt((uint32_t)mtvt_addr);
|
||||
}
|
||||
#endif //#if CONFIG_IDF_TARGET_ESP32P4
|
||||
#endif //#if SOC_INT_CLIC_SUPPORTED
|
||||
|
||||
#if SOC_CPU_HAS_FLEXIBLE_INTC
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -30,6 +30,9 @@
|
||||
#include "esp_ipc.h"
|
||||
#endif
|
||||
|
||||
/* For targets that uses a CLIC as their interrupt controller, CPU_INT_LINES_COUNT represents the external interrupts count */
|
||||
#define CPU_INT_LINES_COUNT 32
|
||||
|
||||
static const char* TAG = "intr_alloc";
|
||||
|
||||
#define ETS_INTERNAL_TIMER0_INTR_NO 6
|
||||
@@ -161,7 +164,7 @@ static vector_desc_t *get_desc_for_int(int intno, int cpu)
|
||||
}
|
||||
}
|
||||
|
||||
//Returns a vector_desc entry for an source, the cpu parameter is used to tell GPIO_INT and GPIO_NMI from different CPUs
|
||||
//Returns a vector_desc entry for a source, the cpu parameter is used to tell GPIO_INT and GPIO_NMI from different CPUs
|
||||
static vector_desc_t * find_desc_for_source(int source, int cpu)
|
||||
{
|
||||
vector_desc_t *vd = vector_desc_head;
|
||||
@@ -326,11 +329,11 @@ static int get_available_int(int flags, int cpu, int force, int source)
|
||||
vector_desc_t *vd = find_desc_for_source(source, cpu);
|
||||
if (vd) {
|
||||
// if existing vd found, don't need to search any more.
|
||||
ALCHLOG("get_avalible_int: existing vd found. intno: %d", vd->intno);
|
||||
ALCHLOG("get_available_int: existing vd found. intno: %d", vd->intno);
|
||||
if ( force != -1 && force != vd->intno ) {
|
||||
ALCHLOG("get_avalible_int: intr forced but not matach existing. existing intno: %d, force: %d", vd->intno, force);
|
||||
ALCHLOG("get_available_int: intr forced but does not match existing. existing intno: %d, force: %d", vd->intno, force);
|
||||
} else if (!is_vect_desc_usable(vd, flags, cpu, force)) {
|
||||
ALCHLOG("get_avalible_int: existing vd invalid.");
|
||||
ALCHLOG("get_available_int: existing vd invalid.");
|
||||
} else {
|
||||
best = vd->intno;
|
||||
}
|
||||
@@ -348,14 +351,14 @@ static int get_available_int(int flags, int cpu, int force, int source)
|
||||
if (is_vect_desc_usable(vd, flags, cpu, force)) {
|
||||
best = vd->intno;
|
||||
} else {
|
||||
ALCHLOG("get_avalible_int: forced vd invalid.");
|
||||
ALCHLOG("get_avalaible_int: forced vd invalid.");
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
ALCHLOG("get_free_int: start looking. Current cpu: %d", cpu);
|
||||
//No allocated handlers as well as forced intr, iterate over the 32 possible interrupts
|
||||
for (x = 0; x < 32; x++) {
|
||||
/* No allocated handlers as well as forced intr, iterate over the 32 possible interrupts */
|
||||
for (x = 0; x < CPU_INT_LINES_COUNT; x++) {
|
||||
//Grab the vector_desc for this vector.
|
||||
vd = find_desc_for_int(x, cpu);
|
||||
if (vd == NULL) {
|
||||
@@ -811,12 +814,13 @@ esp_err_t IRAM_ATTR esp_intr_enable(intr_handle_t handle)
|
||||
|
||||
esp_err_t IRAM_ATTR esp_intr_disable(intr_handle_t handle)
|
||||
{
|
||||
if (!handle) {
|
||||
if (handle == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
int source;
|
||||
bool disabled = 1;
|
||||
bool disabled = true;
|
||||
if (handle->shared_vector_desc) {
|
||||
handle->shared_vector_desc->disabled = 1;
|
||||
source=handle->shared_vector_desc->source;
|
||||
@@ -824,8 +828,8 @@ esp_err_t IRAM_ATTR esp_intr_disable(intr_handle_t handle)
|
||||
shared_vector_desc_t *svd = handle->vector_desc->shared_vec_info;
|
||||
assert(svd != NULL);
|
||||
while(svd) {
|
||||
if (svd->source == source && svd->disabled == 0) {
|
||||
disabled = 0;
|
||||
if (svd->source == source && !svd->disabled) {
|
||||
disabled = false;
|
||||
break;
|
||||
}
|
||||
svd = svd->next;
|
||||
@@ -924,7 +928,7 @@ esp_err_t esp_intr_dump(FILE *stream)
|
||||
for (int cpu = 0; cpu < cpu_num; ++cpu) {
|
||||
fprintf(stream, "CPU %d interrupt status:\n", cpu);
|
||||
fprintf(stream, " Int Level Type Status\n");
|
||||
for (int i_num = 0; i_num < 32; ++i_num) {
|
||||
for (int i_num = 0; i_num < CPU_INT_LINES_COUNT; ++i_num) {
|
||||
fprintf(stream, " %2d ", i_num);
|
||||
esp_cpu_intr_desc_t intr_desc;
|
||||
esp_cpu_intr_get_desc(cpu, i_num, &intr_desc);
|
||||
|
||||
Reference in New Issue
Block a user