drivers/serial: The upper half serial driver configuration CONFIG_SERIAL_DMA used to enable DMA on both RX and TX streams. This was replaced with CONFIG_SERIAL_RXDMA and CONFIG_SERIAKL_TXDMA which will permit supporting DMA on only one or both streams.

This commit is contained in:
Gregory Nutt
2019-04-24 12:11:40 -06:00
parent 2609b0dff3
commit 0d203fd535
7 changed files with 78 additions and 36 deletions
+15 -4
View File
@@ -85,7 +85,11 @@ config SERIAL_OFLOWCONTROL
bool
default n
config SERIAL_DMA
config SERIAL_TXDMA
bool
default n
config SERIAL_RXDMA
bool
default n
@@ -466,10 +470,17 @@ config UART_OFLOWCONTROL
---help---
Enable UART CTS flow control
config UART_DMA
bool "UART DMA support"
config UART_TXDMA
bool "UART Tx DMA support"
default n
select SERIAL_DMA
select SERIAL_TXDMA
---help---
Enable DMA transfers on UART
config UART_RXDMA
bool "UART Rx DMA support"
default n
select SERIAL_RXDMA
---help---
Enable DMA transfers on UART
+3 -1
View File
@@ -37,7 +37,9 @@
CSRCS += serial.c serial_io.c lowconsole.c
ifeq ($(CONFIG_SERIAL_DMA),y)
ifeq ($(CONFIG_SERIAL_RXDMA),y)
CSRCS += serial_dma.c
else ifeq ($(CONFIG_SERIAL_TXDMA),y)
CSRCS += serial_dma.c
endif
+9 -9
View File
@@ -302,7 +302,7 @@ static int uart_putxmitchar(FAR uart_dev_t *dev, int ch, bool oktoblock)
* the semaphore.
*/
#ifdef CONFIG_SERIAL_DMA
#ifdef CONFIG_SERIAL_TXDMA
uart_dmatxavail(dev);
#endif
uart_enabletxint(dev);
@@ -485,7 +485,7 @@ static int uart_tcdrain(FAR uart_dev_t *dev, clock_t timeout)
* the semaphore.
*/
#ifdef CONFIG_SERIAL_DMA
#ifdef CONFIG_SERIAL_TXDMA
uart_dmatxavail(dev);
#endif
uart_enabletxint(dev);
@@ -624,7 +624,7 @@ static int uart_open(FAR struct file *filep)
goto errout_with_sem;
}
#ifdef CONFIG_SERIAL_DMA
#ifdef CONFIG_SERIAL_RXDMA
/* Notify DMA that there is free space in the RX buffer */
uart_dmarxfree(dev);
@@ -887,7 +887,7 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen
else
{
#ifdef CONFIG_SERIAL_DMA
#ifdef CONFIG_SERIAL_RXDMA
/* Disable all interrupts and test again...
* uart_disablerxint() is insufficient for the check in DMA mode.
*/
@@ -910,7 +910,7 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen
* additional data to be received.
*/
#ifdef CONFIG_SERIAL_DMA
#ifdef CONFIG_SERIAL_RXDMA
/* Notify DMA that there is free space in the RX buffer */
uart_dmarxfree(dev);
@@ -991,7 +991,7 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen
* the loop.
*/
#ifdef CONFIG_SERIAL_DMA
#ifdef CONFIG_SERIAL_RXDMA
leave_critical_section(flags);
#else
uart_enablerxint(dev);
@@ -1000,7 +1000,7 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen
}
}
#ifdef CONFIG_SERIAL_DMA
#ifdef CONFIG_SERIAL_RXDMA
/* Notify DMA that there is free space in the RX buffer */
flags = enter_critical_section();
@@ -1008,7 +1008,7 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen
leave_critical_section(flags);
#endif
#ifndef CONFIG_SERIAL_DMA
#ifndef CONFIG_SERIAL_RXDMA
/* RX interrupt could be disabled by RX buffer overflow. Enable it now. */
uart_enablerxint(dev);
@@ -1224,7 +1224,7 @@ static ssize_t uart_write(FAR struct file *filep, FAR const char *buffer,
if (dev->xmit.head != dev->xmit.tail)
{
#ifdef CONFIG_SERIAL_DMA
#ifdef CONFIG_SERIAL_TXDMA
uart_dmatxavail(dev);
#endif
uart_enabletxint(dev);
+12 -3
View File
@@ -46,7 +46,7 @@
#include <nuttx/serial/serial.h>
#ifdef CONFIG_SERIAL_DMA
#if defined(CONFIG_SERIAL_TXDMA) || defined(CONFIG_SERIAL_RXDMA)
/************************************************************************************
* Private Functions
@@ -105,7 +105,8 @@ static int uart_check_signo(const char *buf, size_t size)
*
************************************************************************************/
#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGSTP)
#if defined(CONFIG_SERIAL_RXDMA) && \
(defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGSTP))
static int uart_recvchars_signo(FAR uart_dev_t *dev)
{
FAR struct uart_dmaxfer_s *xfer = &dev->dmarx;
@@ -144,6 +145,7 @@ static int uart_recvchars_signo(FAR uart_dev_t *dev)
*
************************************************************************************/
#ifdef CONFIG_SERIAL_TXDMA
void uart_xmitchars_dma(FAR uart_dev_t *dev)
{
FAR struct uart_dmaxfer_s *xfer = &dev->dmatx;
@@ -172,6 +174,7 @@ void uart_xmitchars_dma(FAR uart_dev_t *dev)
uart_dmasend(dev);
}
#endif
/************************************************************************************
* Name: uart_xmitchars_done
@@ -183,6 +186,7 @@ void uart_xmitchars_dma(FAR uart_dev_t *dev)
*
************************************************************************************/
#ifdef CONFIG_SERIAL_TXDMA
void uart_xmitchars_done(FAR uart_dev_t *dev)
{
FAR struct uart_dmaxfer_s *xfer = &dev->dmatx;
@@ -204,6 +208,7 @@ void uart_xmitchars_done(FAR uart_dev_t *dev)
uart_datasent(dev);
}
}
#endif
/************************************************************************************
* Name: uart_recvchars_dma
@@ -213,6 +218,7 @@ void uart_xmitchars_done(FAR uart_dev_t *dev)
*
************************************************************************************/
#ifdef CONFIG_SERIAL_RXDMA
void uart_recvchars_dma(FAR uart_dev_t *dev)
{
FAR struct uart_dmaxfer_s *xfer = &dev->dmarx;
@@ -331,6 +337,7 @@ void uart_recvchars_dma(FAR uart_dev_t *dev)
uart_dmareceive(dev);
}
#endif
/************************************************************************************
* Name: uart_recvchars_done
@@ -342,6 +349,7 @@ void uart_recvchars_dma(FAR uart_dev_t *dev)
*
************************************************************************************/
#ifdef CONFIG_SERIAL_RXDMA
void uart_recvchars_done(FAR uart_dev_t *dev)
{
FAR struct uart_dmaxfer_s *xfer = &dev->dmarx;
@@ -383,5 +391,6 @@ void uart_recvchars_done(FAR uart_dev_t *dev)
}
#endif
}
#endif
#endif /* CONFIG_SERIAL_DMA */
#endif /* CONFIG_SERIAL_TXDMA || CONFIG_SERIAL_RXDMA */
+14 -4
View File
@@ -103,11 +103,13 @@ static bool u16550_rxavailable(FAR struct uart_dev_s *dev);
static bool u16550_rxflowcontrol(struct uart_dev_s *dev, unsigned int nbuffered,
bool upper);
#endif
#ifdef CONFIG_SERIAL_DMA
#ifdef CONFIG_SERIAL_TXDMA
static void u16550_dmasend(FAR struct uart_dev_s *dev);
static void u16550_dmatxavail(FAR struct uart_dev_s *dev);
#endif
#ifdef CONFIG_SERIAL_RXDMA
static void u16550_dmareceive(FAR struct uart_dev_s *dev);
static void u16550_dmarxfree(FAR struct uart_dev_s *dev);
static void u16550_dmatxavail(FAR struct uart_dev_s *dev);
#endif
static void u16550_send(FAR struct uart_dev_s *dev, int ch);
static void u16550_txint(FAR struct uart_dev_s *dev, bool enable);
@@ -131,10 +133,14 @@ static const struct uart_ops_s g_uart_ops =
#ifdef CONFIG_SERIAL_IFLOWCONTROL
.rxflowcontrol = u16550_rxflowcontrol,
#endif
#ifdef CONFIG_SERIAL_DMA
#ifdef CONFIG_SERIAL_TXDMA
.dmasend = u16550_dmasend,
#endif
#ifdef CONFIG_SERIAL_RXDMA
.dmareceive = u16550_dmareceive,
.dmarxfree = u16550_dmarxfree,
#endif
#ifdef CONFIG_SERIAL_TXDMA
.dmatxavail = u16550_dmatxavail,
#endif
.send = u16550_send,
@@ -1164,11 +1170,13 @@ static bool u16550_rxflowcontrol(struct uart_dev_s *dev, unsigned int nbuffered,
*
****************************************************************************/
#ifdef CONFIG_SERIAL_DMA
#ifdef CONFIG_SERIAL_TXDMA
static void u16550_dmasend(FAR struct uart_dev_s *dev)
{
}
#endif
#ifdef CONFIG_SERIAL_RXDMA
static void u16550_dmareceive(FAR struct uart_dev_s *dev)
{
}
@@ -1176,7 +1184,9 @@ static void u16550_dmareceive(FAR struct uart_dev_s *dev)
static void u16550_dmarxfree(FAR struct uart_dev_s *dev)
{
}
#endif
#ifdef CONFIG_SERIAL_TXDMA
static void u16550_dmatxavail(FAR struct uart_dev_s *dev)
{
}