diff --git a/arch/risc-v/src/litex/litex_serial.c b/arch/risc-v/src/litex/litex_serial.c index c4d4af496c..72130df2fc 100644 --- a/arch/risc-v/src/litex/litex_serial.c +++ b/arch/risc-v/src/litex/litex_serial.c @@ -124,6 +124,7 @@ struct up_dev_s uintptr_t uartbase; /* Base address of UART registers */ uint32_t baud; /* Configured baud */ uint8_t irq; /* IRQ associated with this UART */ + spinlock_t lock; /* Spinlock */ uint8_t im; /* Interrupt mask state */ }; @@ -190,6 +191,7 @@ static struct up_dev_s g_uart0priv = .uartbase = LITEX_UART0_BASE, .baud = CONFIG_UART0_BAUD, .irq = LITEX_IRQ_UART0, + .lock = SP_UNLOCKED, }; static uart_dev_t g_uart0port = @@ -240,7 +242,7 @@ static void up_serialout(struct up_dev_s *priv, int offset, uint32_t value) static void up_restoreuartint(struct up_dev_s *priv, uint8_t im) { - irqstate_t flags = spin_lock_irqsave(NULL); + irqstate_t flags = spin_lock_irqsave(&priv->lock); priv->im = im; @@ -248,7 +250,7 @@ static void up_restoreuartint(struct up_dev_s *priv, uint8_t im) LITEX_CONSOLE_BASE + UART_EV_PENDING_OFFSET); up_serialout(priv, UART_EV_ENABLE_OFFSET, im); - spin_unlock_irqrestore(NULL, flags); + spin_unlock_irqrestore(&priv->lock, flags); } /**************************************************************************** @@ -257,7 +259,7 @@ static void up_restoreuartint(struct up_dev_s *priv, uint8_t im) static void up_disableuartint(struct up_dev_s *priv, uint8_t *im) { - irqstate_t flags = spin_lock_irqsave(NULL); + irqstate_t flags = spin_lock_irqsave(&priv->lock); /* Return the current interrupt mask value */ @@ -274,7 +276,7 @@ static void up_disableuartint(struct up_dev_s *priv, uint8_t *im) LITEX_CONSOLE_BASE + UART_EV_PENDING_OFFSET); up_serialout(priv, UART_EV_ENABLE_OFFSET, 0); - spin_unlock_irqrestore(NULL, flags); + spin_unlock_irqrestore(&priv->lock, flags); } /****************************************************************************