]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ARM: OMAP2+: UART: Make the RX_TIMEOUT for DMA configurable for each UART
authorJon Hunter <jon-hunter@ti.com>
Wed, 9 Nov 2011 12:04:49 +0000 (17:34 +0530)
committerKevin Hilman <khilman@ti.com>
Thu, 15 Dec 2011 00:05:24 +0000 (16:05 -0800)
When using DMA there are two timeouts defined. The first timeout,
rx_timeout, is really a polling rate in which software polls the
DMA status to see if the DMA has finished. This is necessary for
the RX side because we do not know how much data we will receive.
The secound timeout, RX_TIMEOUT, is a timeout after which the
DMA will be stopped if no more data is received. To make this
clearer, rename rx_timeout as rx_poll_rate and rename the
function serial_omap_rx_timeout() to serial_omap_rxdma_poll().

The OMAP-Serial driver defines an RX_TIMEOUT of 3 seconds that is
used to indicate when the DMA for UART can be stopped if no more
data is received. The value is a global definition that is applied
to all instances of the UART.

Each UART may be used for a different purpose and so the timeout
required may differ. Make this value configurable for each UART so
that this value can be optimised for power savings.

Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Signed-off-by: Govindraj.R <govindraj.raja@ti.com>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de> (for drivers/tty changes)
Signed-off-by: Kevin Hilman <khilman@ti.com>
arch/arm/mach-omap2/serial.c
arch/arm/plat-omap/include/plat/omap-serial.h
drivers/tty/serial/omap-serial.c

index 5b1b36a45e9c82a0f25038d6dcfc81dc806a5b01..5dd9289450333a32b0091dbe5d58ecde835fd985 100644 (file)
@@ -64,13 +64,15 @@ struct omap_uart_state {
 static LIST_HEAD(uart_list);
 static u8 num_uarts;
 
-#define DEFAULT_RXDMA_TIMEOUT          1       /* RX DMA polling rate (us) */
+#define DEFAULT_RXDMA_POLLRATE         1       /* RX DMA polling rate (us) */
 #define DEFAULT_RXDMA_BUFSIZE          4096    /* RX DMA buffer size */
+#define DEFAULT_RXDMA_TIMEOUT          (3 * HZ)/* RX DMA timeout (jiffies) */
 
 static struct omap_uart_port_info omap_serial_default_info[] __initdata = {
        {
                .dma_enabled    = false,
                .dma_rx_buf_size = DEFAULT_RXDMA_BUFSIZE,
+               .dma_rx_poll_rate = DEFAULT_RXDMA_POLLRATE,
                .dma_rx_timeout = DEFAULT_RXDMA_TIMEOUT,
                .autosuspend_timeout = DEFAULT_AUTOSUSPEND_DELAY,
        },
@@ -351,6 +353,7 @@ void __init omap_serial_init_port(struct omap_board_data *bdata,
        omap_up.enable_wakeup = omap_uart_enable_wakeup;
        omap_up.dma_rx_buf_size = info->dma_rx_buf_size;
        omap_up.dma_rx_timeout = info->dma_rx_timeout;
+       omap_up.dma_rx_poll_rate = info->dma_rx_poll_rate;
        omap_up.autosuspend_timeout = info->autosuspend_timeout;
 
        /* Enable the MDR1 Errata i202 for OMAP2430/3xxx/44xx */
index a740a6c0e104edd221fc8bdd6f13cf724bd883b5..ea63b2bc761c4014ca71ca75a1024e9cdd353388 100644 (file)
@@ -53,7 +53,6 @@
 
 #define OMAP_UART_DMA_CH_FREE  -1
 
-#define RX_TIMEOUT             (3 * HZ)
 #define OMAP_MAX_HSUART_PORTS  4
 
 #define MSR_SAVE_FLAGS         UART_MSR_ANY_DELTA
@@ -69,6 +68,7 @@ struct omap_uart_port_info {
        unsigned int            dma_rx_buf_size;
        unsigned int            dma_rx_timeout;
        unsigned int            autosuspend_timeout;
+       unsigned int            dma_rx_poll_rate;
 
        int (*get_context_loss_count)(struct device *);
        void (*set_forceidle)(struct platform_device *);
@@ -98,6 +98,7 @@ struct uart_omap_dma {
        /* timer to poll activity on rx dma */
        struct timer_list       rx_timer;
        unsigned int            rx_buf_size;
+       unsigned int            rx_poll_rate;
        unsigned int            rx_timeout;
 };
 
index d60e001cf60f98ec6ce99bcfa04db8e27f15568e..e1eaa66c047b9bea6f03c7b4ca156a4e7fe89137 100644 (file)
@@ -47,7 +47,7 @@ static struct uart_omap_port *ui[OMAP_MAX_HSUART_PORTS];
 
 /* Forward declaration of functions */
 static void uart_tx_dma_callback(int lch, u16 ch_status, void *data);
-static void serial_omap_rx_timeout(unsigned long uart_no);
+static void serial_omap_rxdma_poll(unsigned long uart_no);
 static int serial_omap_start_rxdma(struct uart_omap_port *up);
 static void serial_omap_mdr1_errataset(struct uart_omap_port *up, u8 mdr1);
 
@@ -542,7 +542,7 @@ static int serial_omap_startup(struct uart_port *port)
                        (dma_addr_t *)&(up->uart_dma.tx_buf_dma_phys),
                        0);
                init_timer(&(up->uart_dma.rx_timer));
-               up->uart_dma.rx_timer.function = serial_omap_rx_timeout;
+               up->uart_dma.rx_timer.function = serial_omap_rxdma_poll;
                up->uart_dma.rx_timer.data = up->pdev->id;
                /* Currently the buffer size is 4KB. Can increase it */
                up->uart_dma.rx_buf = dma_alloc_coherent(NULL,
@@ -1160,7 +1160,7 @@ static int serial_omap_resume(struct device *dev)
 }
 #endif
 
-static void serial_omap_rx_timeout(unsigned long uart_no)
+static void serial_omap_rxdma_poll(unsigned long uart_no)
 {
        struct uart_omap_port *up = ui[uart_no];
        unsigned int curr_dma_pos, curr_transmitted_size;
@@ -1170,9 +1170,9 @@ static void serial_omap_rx_timeout(unsigned long uart_no)
        if ((curr_dma_pos == up->uart_dma.prev_rx_dma_pos) ||
                             (curr_dma_pos == 0)) {
                if (jiffies_to_msecs(jiffies - up->port_activity) <
-                                                       RX_TIMEOUT) {
+                                               up->uart_dma.rx_timeout) {
                        mod_timer(&up->uart_dma.rx_timer, jiffies +
-                               usecs_to_jiffies(up->uart_dma.rx_timeout));
+                               usecs_to_jiffies(up->uart_dma.rx_poll_rate));
                } else {
                        serial_omap_stop_rxdma(up);
                        up->ier |= (UART_IER_RDI | UART_IER_RLSI);
@@ -1201,7 +1201,7 @@ static void serial_omap_rx_timeout(unsigned long uart_no)
                }
        } else  {
                mod_timer(&up->uart_dma.rx_timer, jiffies +
-                       usecs_to_jiffies(up->uart_dma.rx_timeout));
+                       usecs_to_jiffies(up->uart_dma.rx_poll_rate));
        }
        up->port_activity = jiffies;
 }
@@ -1240,7 +1240,7 @@ static int serial_omap_start_rxdma(struct uart_omap_port *up)
        /* FIXME: Cache maintenance needed here? */
        omap_start_dma(up->uart_dma.rx_dma_channel);
        mod_timer(&up->uart_dma.rx_timer, jiffies +
-                               usecs_to_jiffies(up->uart_dma.rx_timeout));
+                               usecs_to_jiffies(up->uart_dma.rx_poll_rate));
        up->uart_dma.rx_dma_used = true;
        return ret;
 }
@@ -1376,6 +1376,7 @@ static int serial_omap_probe(struct platform_device *pdev)
                up->use_dma = 1;
                up->uart_dma.rx_buf_size = omap_up_info->dma_rx_buf_size;
                up->uart_dma.rx_timeout = omap_up_info->dma_rx_timeout;
+               up->uart_dma.rx_poll_rate = omap_up_info->dma_rx_poll_rate;
                spin_lock_init(&(up->uart_dma.tx_lock));
                spin_lock_init(&(up->uart_dma.rx_lock));
                up->uart_dma.tx_dma_channel = OMAP_UART_DMA_CH_FREE;