aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Hunter <jon-hunter@ti.com>2011-11-09 07:04:49 -0500
committerKevin Hilman <khilman@ti.com>2011-12-14 19:05:24 -0500
commita9e210e0b7a344c0e44aa6bf6888176bbc635c42 (patch)
treee24466ff2fd9c2f10979d5fce32a870c451448ff
parentc86845db77ce220f77e6645b18800744684946ac (diff)
ARM: OMAP2+: UART: Make the RX_TIMEOUT for DMA configurable for each UART
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>
-rw-r--r--arch/arm/mach-omap2/serial.c5
-rw-r--r--arch/arm/plat-omap/include/plat/omap-serial.h3
-rw-r--r--drivers/tty/serial/omap-serial.c15
3 files changed, 14 insertions, 9 deletions
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 5b1b36a45e9c..5dd928945033 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -64,13 +64,15 @@ struct omap_uart_state {
64static LIST_HEAD(uart_list); 64static LIST_HEAD(uart_list);
65static u8 num_uarts; 65static u8 num_uarts;
66 66
67#define DEFAULT_RXDMA_TIMEOUT 1 /* RX DMA polling rate (us) */ 67#define DEFAULT_RXDMA_POLLRATE 1 /* RX DMA polling rate (us) */
68#define DEFAULT_RXDMA_BUFSIZE 4096 /* RX DMA buffer size */ 68#define DEFAULT_RXDMA_BUFSIZE 4096 /* RX DMA buffer size */
69#define DEFAULT_RXDMA_TIMEOUT (3 * HZ)/* RX DMA timeout (jiffies) */
69 70
70static struct omap_uart_port_info omap_serial_default_info[] __initdata = { 71static struct omap_uart_port_info omap_serial_default_info[] __initdata = {
71 { 72 {
72 .dma_enabled = false, 73 .dma_enabled = false,
73 .dma_rx_buf_size = DEFAULT_RXDMA_BUFSIZE, 74 .dma_rx_buf_size = DEFAULT_RXDMA_BUFSIZE,
75 .dma_rx_poll_rate = DEFAULT_RXDMA_POLLRATE,
74 .dma_rx_timeout = DEFAULT_RXDMA_TIMEOUT, 76 .dma_rx_timeout = DEFAULT_RXDMA_TIMEOUT,
75 .autosuspend_timeout = DEFAULT_AUTOSUSPEND_DELAY, 77 .autosuspend_timeout = DEFAULT_AUTOSUSPEND_DELAY,
76 }, 78 },
@@ -351,6 +353,7 @@ void __init omap_serial_init_port(struct omap_board_data *bdata,
351 omap_up.enable_wakeup = omap_uart_enable_wakeup; 353 omap_up.enable_wakeup = omap_uart_enable_wakeup;
352 omap_up.dma_rx_buf_size = info->dma_rx_buf_size; 354 omap_up.dma_rx_buf_size = info->dma_rx_buf_size;
353 omap_up.dma_rx_timeout = info->dma_rx_timeout; 355 omap_up.dma_rx_timeout = info->dma_rx_timeout;
356 omap_up.dma_rx_poll_rate = info->dma_rx_poll_rate;
354 omap_up.autosuspend_timeout = info->autosuspend_timeout; 357 omap_up.autosuspend_timeout = info->autosuspend_timeout;
355 358
356 /* Enable the MDR1 Errata i202 for OMAP2430/3xxx/44xx */ 359 /* Enable the MDR1 Errata i202 for OMAP2430/3xxx/44xx */
diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h b/arch/arm/plat-omap/include/plat/omap-serial.h
index a740a6c0e104..ea63b2bc761c 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -53,7 +53,6 @@
53 53
54#define OMAP_UART_DMA_CH_FREE -1 54#define OMAP_UART_DMA_CH_FREE -1
55 55
56#define RX_TIMEOUT (3 * HZ)
57#define OMAP_MAX_HSUART_PORTS 4 56#define OMAP_MAX_HSUART_PORTS 4
58 57
59#define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA 58#define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA
@@ -69,6 +68,7 @@ struct omap_uart_port_info {
69 unsigned int dma_rx_buf_size; 68 unsigned int dma_rx_buf_size;
70 unsigned int dma_rx_timeout; 69 unsigned int dma_rx_timeout;
71 unsigned int autosuspend_timeout; 70 unsigned int autosuspend_timeout;
71 unsigned int dma_rx_poll_rate;
72 72
73 int (*get_context_loss_count)(struct device *); 73 int (*get_context_loss_count)(struct device *);
74 void (*set_forceidle)(struct platform_device *); 74 void (*set_forceidle)(struct platform_device *);
@@ -98,6 +98,7 @@ struct uart_omap_dma {
98 /* timer to poll activity on rx dma */ 98 /* timer to poll activity on rx dma */
99 struct timer_list rx_timer; 99 struct timer_list rx_timer;
100 unsigned int rx_buf_size; 100 unsigned int rx_buf_size;
101 unsigned int rx_poll_rate;
101 unsigned int rx_timeout; 102 unsigned int rx_timeout;
102}; 103};
103 104
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index d60e001cf60f..e1eaa66c047b 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -47,7 +47,7 @@ static struct uart_omap_port *ui[OMAP_MAX_HSUART_PORTS];
47 47
48/* Forward declaration of functions */ 48/* Forward declaration of functions */
49static void uart_tx_dma_callback(int lch, u16 ch_status, void *data); 49static void uart_tx_dma_callback(int lch, u16 ch_status, void *data);
50static void serial_omap_rx_timeout(unsigned long uart_no); 50static void serial_omap_rxdma_poll(unsigned long uart_no);
51static int serial_omap_start_rxdma(struct uart_omap_port *up); 51static int serial_omap_start_rxdma(struct uart_omap_port *up);
52static void serial_omap_mdr1_errataset(struct uart_omap_port *up, u8 mdr1); 52static void serial_omap_mdr1_errataset(struct uart_omap_port *up, u8 mdr1);
53 53
@@ -542,7 +542,7 @@ static int serial_omap_startup(struct uart_port *port)
542 (dma_addr_t *)&(up->uart_dma.tx_buf_dma_phys), 542 (dma_addr_t *)&(up->uart_dma.tx_buf_dma_phys),
543 0); 543 0);
544 init_timer(&(up->uart_dma.rx_timer)); 544 init_timer(&(up->uart_dma.rx_timer));
545 up->uart_dma.rx_timer.function = serial_omap_rx_timeout; 545 up->uart_dma.rx_timer.function = serial_omap_rxdma_poll;
546 up->uart_dma.rx_timer.data = up->pdev->id; 546 up->uart_dma.rx_timer.data = up->pdev->id;
547 /* Currently the buffer size is 4KB. Can increase it */ 547 /* Currently the buffer size is 4KB. Can increase it */
548 up->uart_dma.rx_buf = dma_alloc_coherent(NULL, 548 up->uart_dma.rx_buf = dma_alloc_coherent(NULL,
@@ -1160,7 +1160,7 @@ static int serial_omap_resume(struct device *dev)
1160} 1160}
1161#endif 1161#endif
1162 1162
1163static void serial_omap_rx_timeout(unsigned long uart_no) 1163static void serial_omap_rxdma_poll(unsigned long uart_no)
1164{ 1164{
1165 struct uart_omap_port *up = ui[uart_no]; 1165 struct uart_omap_port *up = ui[uart_no];
1166 unsigned int curr_dma_pos, curr_transmitted_size; 1166 unsigned int curr_dma_pos, curr_transmitted_size;
@@ -1170,9 +1170,9 @@ static void serial_omap_rx_timeout(unsigned long uart_no)
1170 if ((curr_dma_pos == up->uart_dma.prev_rx_dma_pos) || 1170 if ((curr_dma_pos == up->uart_dma.prev_rx_dma_pos) ||
1171 (curr_dma_pos == 0)) { 1171 (curr_dma_pos == 0)) {
1172 if (jiffies_to_msecs(jiffies - up->port_activity) < 1172 if (jiffies_to_msecs(jiffies - up->port_activity) <
1173 RX_TIMEOUT) { 1173 up->uart_dma.rx_timeout) {
1174 mod_timer(&up->uart_dma.rx_timer, jiffies + 1174 mod_timer(&up->uart_dma.rx_timer, jiffies +
1175 usecs_to_jiffies(up->uart_dma.rx_timeout)); 1175 usecs_to_jiffies(up->uart_dma.rx_poll_rate));
1176 } else { 1176 } else {
1177 serial_omap_stop_rxdma(up); 1177 serial_omap_stop_rxdma(up);
1178 up->ier |= (UART_IER_RDI | UART_IER_RLSI); 1178 up->ier |= (UART_IER_RDI | UART_IER_RLSI);
@@ -1201,7 +1201,7 @@ static void serial_omap_rx_timeout(unsigned long uart_no)
1201 } 1201 }
1202 } else { 1202 } else {
1203 mod_timer(&up->uart_dma.rx_timer, jiffies + 1203 mod_timer(&up->uart_dma.rx_timer, jiffies +
1204 usecs_to_jiffies(up->uart_dma.rx_timeout)); 1204 usecs_to_jiffies(up->uart_dma.rx_poll_rate));
1205 } 1205 }
1206 up->port_activity = jiffies; 1206 up->port_activity = jiffies;
1207} 1207}
@@ -1240,7 +1240,7 @@ static int serial_omap_start_rxdma(struct uart_omap_port *up)
1240 /* FIXME: Cache maintenance needed here? */ 1240 /* FIXME: Cache maintenance needed here? */
1241 omap_start_dma(up->uart_dma.rx_dma_channel); 1241 omap_start_dma(up->uart_dma.rx_dma_channel);
1242 mod_timer(&up->uart_dma.rx_timer, jiffies + 1242 mod_timer(&up->uart_dma.rx_timer, jiffies +
1243 usecs_to_jiffies(up->uart_dma.rx_timeout)); 1243 usecs_to_jiffies(up->uart_dma.rx_poll_rate));
1244 up->uart_dma.rx_dma_used = true; 1244 up->uart_dma.rx_dma_used = true;
1245 return ret; 1245 return ret;
1246} 1246}
@@ -1376,6 +1376,7 @@ static int serial_omap_probe(struct platform_device *pdev)
1376 up->use_dma = 1; 1376 up->use_dma = 1;
1377 up->uart_dma.rx_buf_size = omap_up_info->dma_rx_buf_size; 1377 up->uart_dma.rx_buf_size = omap_up_info->dma_rx_buf_size;
1378 up->uart_dma.rx_timeout = omap_up_info->dma_rx_timeout; 1378 up->uart_dma.rx_timeout = omap_up_info->dma_rx_timeout;
1379 up->uart_dma.rx_poll_rate = omap_up_info->dma_rx_poll_rate;
1379 spin_lock_init(&(up->uart_dma.tx_lock)); 1380 spin_lock_init(&(up->uart_dma.tx_lock));
1380 spin_lock_init(&(up->uart_dma.rx_lock)); 1381 spin_lock_init(&(up->uart_dma.rx_lock));
1381 up->uart_dma.tx_dma_channel = OMAP_UART_DMA_CH_FREE; 1382 up->uart_dma.tx_dma_channel = OMAP_UART_DMA_CH_FREE;