aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2011-06-14 11:46:56 -0700
committerColin Cross <ccross@android.com>2011-06-14 11:46:56 -0700
commitad1f9adb36d07438bd38270744f190b49d094ad8 (patch)
treebf155f7af98e1702abc1b7aa3c87226323606367 /drivers/tty
parent4a968e99063abdd6cf118d85bab68e8f0d8b717c (diff)
parentb26b13a08ed71b2db6152774e4adb5c93e0636e5 (diff)
downloadkernel_samsung_espresso10-ad1f9adb36d07438bd38270744f190b49d094ad8.zip
kernel_samsung_espresso10-ad1f9adb36d07438bd38270744f190b49d094ad8.tar.gz
kernel_samsung_espresso10-ad1f9adb36d07438bd38270744f190b49d094ad8.tar.bz2
Merge branch 'linux-omap-pm-3.0' into linux-omap-3.0
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/omap-serial.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 47cadf4..0275c28 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -1335,6 +1335,55 @@ static struct platform_driver serial_omap_driver = {
},
};
+int omap_uart_active(int num, u32 timeout)
+{
+ struct uart_omap_port *up = ui[num];
+ struct circ_buf *xmit;
+ unsigned int status;
+
+ if(num >= OMAP_MAX_HSUART_PORTS)
+ return 0;
+
+ /* Though when UART's initialised this can never happen,
+ * but during initialisation, it can happen the "ui"
+ * structure is not initialized and the timer kicks
+ * in. This would result in a NULL value, resulting
+ * in crash.
+ */
+ up = ui[num];
+ if (up == NULL)
+ return 0;
+
+ if (!up->port_activity)
+ return 1;
+
+ /* Check for recent driver activity. If time delta from now
+ * to last activty < "uart idle timeout" second keep clocks on.
+ */
+ if (((jiffies - up->port_activity) < timeout))
+ return 1;
+
+ xmit = &up->port.state->xmit;
+ if (!(uart_circ_empty(xmit) || uart_tx_stopped(&up->port)))
+ return 1;
+
+ status = serial_in(up, UART_LSR);
+ /* TX hardware not empty */
+ if (!(status & (UART_LSR_TEMT | UART_LSR_THRE)))
+ return 1;
+
+ /* Any rx activity? */
+ if (status & UART_LSR_DR)
+ return 1;
+
+ /* Check if DMA channels are active */
+ if (up->use_dma && (up->uart_dma.rx_dma_channel != OMAP_UART_DMA_CH_FREE ||
+ up->uart_dma.tx_dma_channel != OMAP_UART_DMA_CH_FREE))
+ return 1;
+ return 0;
+}
+EXPORT_SYMBOL(omap_uart_active);
+
static int __init serial_omap_init(void)
{
int ret;