arch/xtensa/esp32: Keep track to which CPU the interrupt was attached.

This is used when dettaching.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
This commit is contained in:
Abdelatif Guettouche 2021-08-02 11:13:10 +02:00 committed by Xiang Xiao
parent 0ca5fb4edc
commit 239f0e257b
2 changed files with 12 additions and 12 deletions

View File

@ -227,6 +227,7 @@ struct esp32_dmadesc_s s_dma_txdesc[UART_DMA_CONTROLLERS_NUM]
struct esp32_config_s
{
const uint8_t id; /* UART id */
uint8_t cpu; /* CPU ID */
uint8_t periph; /* UART peripheral ID */
uint8_t irq; /* IRQ number assigned to the peripheral */
uint8_t txpin; /* Tx pin number (0-39) */
@ -1010,7 +1011,6 @@ static void esp32_shutdown(struct uart_dev_s *dev)
static int esp32_attach(struct uart_dev_s *dev)
{
struct esp32_dev_s *priv = (struct esp32_dev_s *)dev->priv;
int cpu;
int ret = OK;
/* Allocate a level-sensitive, priority 1 CPU interrupt for the UART */
@ -1025,12 +1025,13 @@ static int esp32_attach(struct uart_dev_s *dev)
/* Set up to receive peripheral interrupts on the current CPU */
cpu = up_cpu_index();
priv->config->cpu = up_cpu_index();
/* Attach the GPIO peripheral to the allocated CPU interrupt */
up_disable_irq(priv->cpuint);
esp32_attach_peripheral(cpu, priv->config->periph, priv->cpuint);
esp32_attach_peripheral(priv->config->cpu, priv->config->periph,
priv->cpuint);
/* Attach and enable the IRQ */
@ -1060,7 +1061,6 @@ static int esp32_attach(struct uart_dev_s *dev)
static void esp32_detach(struct uart_dev_s *dev)
{
struct esp32_dev_s *priv = (struct esp32_dev_s *)dev->priv;
int cpu;
/* Disable and detach the CPU interrupt */
@ -1069,8 +1069,8 @@ static void esp32_detach(struct uart_dev_s *dev)
/* Disassociate the peripheral interrupt from the CPU interrupt */
cpu = up_cpu_index();
esp32_detach_peripheral(cpu, priv->config->periph, priv->cpuint);
esp32_detach_peripheral(priv->config->cpu, priv->config->periph,
priv->cpuint);
/* And release the CPU interrupt */

View File

@ -51,6 +51,7 @@ struct esp32_wdt_priv_s
{
FAR struct esp32_wdt_ops_s *ops;
uint32_t base; /* WDT register base address */
uint8_t cpu; /* CPU ID */
uint8_t periph; /* Peripheral ID */
uint8_t irq; /* Interrupt ID */
int cpuint; /* CPU interrupt assigned to this wdt */
@ -696,7 +697,6 @@ static int esp32_wdt_setisr(FAR struct esp32_wdt_dev_s *dev, xcpt_t handler,
{
FAR struct esp32_wdt_priv_s *wdt = NULL;
int ret = OK;
uint8_t cpu;
DEBUGASSERT(dev);
@ -715,8 +715,7 @@ static int esp32_wdt_setisr(FAR struct esp32_wdt_dev_s *dev, xcpt_t handler,
*/
up_disable_irq(wdt->cpuint);
cpu = up_cpu_index();
esp32_detach_peripheral(cpu, wdt->periph, wdt->cpuint);
esp32_detach_peripheral(wdt->cpu, wdt->periph, wdt->cpuint);
esp32_free_cpuint(wdt->cpuint);
irq_detach(wdt->irq);
}
@ -739,6 +738,8 @@ static int esp32_wdt_setisr(FAR struct esp32_wdt_dev_s *dev, xcpt_t handler,
goto errout;
}
wdt->cpu = up_cpu_index();
/* Disable the provided CPU Interrupt to configure it */
up_disable_irq(wdt->cpuint);
@ -747,8 +748,7 @@ static int esp32_wdt_setisr(FAR struct esp32_wdt_dev_s *dev, xcpt_t handler,
* the current core
*/
cpu = up_cpu_index();
esp32_attach_peripheral(cpu, wdt->periph, wdt->cpuint);
esp32_attach_peripheral(wdt->cpu, wdt->periph, wdt->cpuint);
/* Associate an IRQ Number (from the WDT) to an ISR */
@ -756,7 +756,7 @@ static int esp32_wdt_setisr(FAR struct esp32_wdt_dev_s *dev, xcpt_t handler,
if (ret != OK)
{
esp32_detach_peripheral(cpu, wdt->periph, wdt->cpuint);
esp32_detach_peripheral(wdt->cpu, wdt->periph, wdt->cpuint);
esp32_free_cpuint(wdt->cpuint);
tmrerr("ERROR: Failed to associate an IRQ Number");
goto errout;