arch/xtensa/esp32: Propagate RTC IRQ status register to lower levels

This commit is contained in:
Lucas Saavedra Vaz 2023-01-30 16:42:42 -03:00 committed by Xiang Xiao
parent 9f027208d4
commit f07885541c

View File

@ -63,6 +63,7 @@ enum rtcio_lh_out_mode_e
#ifdef CONFIG_ESP32_RTCIO_IRQ #ifdef CONFIG_ESP32_RTCIO_IRQ
static int g_rtcio_cpuint; static int g_rtcio_cpuint;
static uint32_t last_status;
#endif #endif
static const uint32_t rtc_gpio_to_addr[] = static const uint32_t rtc_gpio_to_addr[] =
@ -114,12 +115,11 @@ static inline bool is_valid_rtc_gpio(uint32_t rtcio_num)
* Name: rtcio_dispatch * Name: rtcio_dispatch
* *
* Description: * Description:
* Second level dispatch for RTC interrupt handling. * Second level dispatch for the RTC interrupt.
* *
* Input Parameters: * Input Parameters:
* irq - The IRQ number; * irq - The IRQ number;
* status - The interrupt status register; * reg_status - Pointer to a copy of the interrupt status register.
* context - The interrupt context.
* *
* Returned Value: * Returned Value:
* None. * None.
@ -127,8 +127,9 @@ static inline bool is_valid_rtc_gpio(uint32_t rtcio_num)
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_ESP32_RTCIO_IRQ #ifdef CONFIG_ESP32_RTCIO_IRQ
static void rtcio_dispatch(int irq, uint32_t status, uint32_t *context) static void rtcio_dispatch(int irq, uint32_t *reg_status)
{ {
uint32_t status = *reg_status;
uint32_t mask; uint32_t mask;
int i; int i;
@ -141,9 +142,11 @@ static void rtcio_dispatch(int irq, uint32_t status, uint32_t *context)
mask = (UINT32_C(1) << i); mask = (UINT32_C(1) << i);
if ((status & mask) != 0) if ((status & mask) != 0)
{ {
/* Yes... perform the second level dispatch */ /* Yes... perform the second level dispatch. The IRQ context will
* contain the contents of the status register.
*/
irq_dispatch(irq + i, context); irq_dispatch(irq + i, (void *)reg_status);
/* Clear the bit in the status so that we might execute this loop /* Clear the bit in the status so that we might execute this loop
* sooner. * sooner.
@ -174,16 +177,14 @@ static void rtcio_dispatch(int irq, uint32_t status, uint32_t *context)
#ifdef CONFIG_ESP32_RTCIO_IRQ #ifdef CONFIG_ESP32_RTCIO_IRQ
static int rtcio_interrupt(int irq, void *context, void *arg) static int rtcio_interrupt(int irq, void *context, void *arg)
{ {
uint32_t status;
/* Read and clear the lower RTC interrupt status */ /* Read and clear the lower RTC interrupt status */
status = getreg32(RTC_CNTL_INT_ST_REG); last_status = getreg32(RTC_CNTL_INT_ST_REG);
putreg32(status, RTC_CNTL_INT_CLR_REG); putreg32(last_status, RTC_CNTL_INT_CLR_REG);
/* Dispatch pending interrupts in the RTC status register */ /* Dispatch pending interrupts in the RTC status register */
rtcio_dispatch(ESP32_FIRST_RTCIOIRQ_PERIPH, status, (uint32_t *)context); rtcio_dispatch(ESP32_FIRST_RTCIOIRQ_PERIPH, &last_status);
return OK; return OK;
} }