diff options
Diffstat (limited to 'drivers/tty/serial/omap-serial.c')
-rw-r--r-- | drivers/tty/serial/omap-serial.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index d192dcbb82f5..f80904145fd4 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c | |||
@@ -46,6 +46,13 @@ | |||
46 | 46 | ||
47 | #define DEFAULT_CLK_SPEED 48000000 /* 48Mhz*/ | 47 | #define DEFAULT_CLK_SPEED 48000000 /* 48Mhz*/ |
48 | 48 | ||
49 | /* SCR register bitmasks */ | ||
50 | #define OMAP_UART_SCR_RX_TRIG_GRANU1_MASK (1 << 7) | ||
51 | |||
52 | /* FCR register bitmasks */ | ||
53 | #define OMAP_UART_FCR_RX_FIFO_TRIG_SHIFT 6 | ||
54 | #define OMAP_UART_FCR_RX_FIFO_TRIG_MASK (0x3 << 6) | ||
55 | |||
49 | static struct uart_omap_port *ui[OMAP_MAX_HSUART_PORTS]; | 56 | static struct uart_omap_port *ui[OMAP_MAX_HSUART_PORTS]; |
50 | 57 | ||
51 | /* Forward declaration of functions */ | 58 | /* Forward declaration of functions */ |
@@ -129,6 +136,7 @@ static void serial_omap_enable_ms(struct uart_port *port) | |||
129 | static void serial_omap_stop_tx(struct uart_port *port) | 136 | static void serial_omap_stop_tx(struct uart_port *port) |
130 | { | 137 | { |
131 | struct uart_omap_port *up = (struct uart_omap_port *)port; | 138 | struct uart_omap_port *up = (struct uart_omap_port *)port; |
139 | struct omap_uart_port_info *pdata = up->pdev->dev.platform_data; | ||
132 | 140 | ||
133 | if (up->use_dma && | 141 | if (up->use_dma && |
134 | up->uart_dma.tx_dma_channel != OMAP_UART_DMA_CH_FREE) { | 142 | up->uart_dma.tx_dma_channel != OMAP_UART_DMA_CH_FREE) { |
@@ -151,6 +159,9 @@ static void serial_omap_stop_tx(struct uart_port *port) | |||
151 | serial_out(up, UART_IER, up->ier); | 159 | serial_out(up, UART_IER, up->ier); |
152 | } | 160 | } |
153 | 161 | ||
162 | if (!up->use_dma && pdata->set_forceidle) | ||
163 | pdata->set_forceidle(up->pdev); | ||
164 | |||
154 | pm_runtime_mark_last_busy(&up->pdev->dev); | 165 | pm_runtime_mark_last_busy(&up->pdev->dev); |
155 | pm_runtime_put_autosuspend(&up->pdev->dev); | 166 | pm_runtime_put_autosuspend(&up->pdev->dev); |
156 | } | 167 | } |
@@ -279,6 +290,7 @@ static inline void serial_omap_enable_ier_thri(struct uart_omap_port *up) | |||
279 | static void serial_omap_start_tx(struct uart_port *port) | 290 | static void serial_omap_start_tx(struct uart_port *port) |
280 | { | 291 | { |
281 | struct uart_omap_port *up = (struct uart_omap_port *)port; | 292 | struct uart_omap_port *up = (struct uart_omap_port *)port; |
293 | struct omap_uart_port_info *pdata = up->pdev->dev.platform_data; | ||
282 | struct circ_buf *xmit; | 294 | struct circ_buf *xmit; |
283 | unsigned int start; | 295 | unsigned int start; |
284 | int ret = 0; | 296 | int ret = 0; |
@@ -286,6 +298,8 @@ static void serial_omap_start_tx(struct uart_port *port) | |||
286 | if (!up->use_dma) { | 298 | if (!up->use_dma) { |
287 | pm_runtime_get_sync(&up->pdev->dev); | 299 | pm_runtime_get_sync(&up->pdev->dev); |
288 | serial_omap_enable_ier_thri(up); | 300 | serial_omap_enable_ier_thri(up); |
301 | if (pdata->set_noidle) | ||
302 | pdata->set_noidle(up->pdev); | ||
289 | pm_runtime_mark_last_busy(&up->pdev->dev); | 303 | pm_runtime_mark_last_busy(&up->pdev->dev); |
290 | pm_runtime_put_autosuspend(&up->pdev->dev); | 304 | pm_runtime_put_autosuspend(&up->pdev->dev); |
291 | return; | 305 | return; |
@@ -726,8 +740,7 @@ serial_omap_set_termios(struct uart_port *port, struct ktermios *termios, | |||
726 | quot = serial_omap_get_divisor(port, baud); | 740 | quot = serial_omap_get_divisor(port, baud); |
727 | 741 | ||
728 | /* calculate wakeup latency constraint */ | 742 | /* calculate wakeup latency constraint */ |
729 | up->calc_latency = (1000000 * up->port.fifosize) / | 743 | up->calc_latency = (USEC_PER_SEC * up->port.fifosize) / (baud / 8); |
730 | (1000 * baud / 8); | ||
731 | up->latency = up->calc_latency; | 744 | up->latency = up->calc_latency; |
732 | schedule_work(&up->qos_work); | 745 | schedule_work(&up->qos_work); |
733 | 746 | ||
@@ -811,14 +824,21 @@ serial_omap_set_termios(struct uart_port *port, struct ktermios *termios, | |||
811 | up->mcr = serial_in(up, UART_MCR); | 824 | up->mcr = serial_in(up, UART_MCR); |
812 | serial_out(up, UART_MCR, up->mcr | UART_MCR_TCRTLR); | 825 | serial_out(up, UART_MCR, up->mcr | UART_MCR_TCRTLR); |
813 | /* FIFO ENABLE, DMA MODE */ | 826 | /* FIFO ENABLE, DMA MODE */ |
814 | serial_out(up, UART_FCR, up->fcr); | 827 | |
815 | serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); | 828 | up->scr |= OMAP_UART_SCR_RX_TRIG_GRANU1_MASK; |
816 | 829 | ||
817 | if (up->use_dma) { | 830 | if (up->use_dma) { |
818 | serial_out(up, UART_TI752_TLR, 0); | 831 | serial_out(up, UART_TI752_TLR, 0); |
819 | up->scr |= (UART_FCR_TRIGGER_4 | UART_FCR_TRIGGER_8); | 832 | up->scr |= UART_FCR_TRIGGER_4; |
833 | } else { | ||
834 | /* Set receive FIFO threshold to 1 byte */ | ||
835 | up->fcr &= ~OMAP_UART_FCR_RX_FIFO_TRIG_MASK; | ||
836 | up->fcr |= (0x1 << OMAP_UART_FCR_RX_FIFO_TRIG_SHIFT); | ||
820 | } | 837 | } |
821 | 838 | ||
839 | serial_out(up, UART_FCR, up->fcr); | ||
840 | serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); | ||
841 | |||
822 | serial_out(up, UART_OMAP_SCR, up->scr); | 842 | serial_out(up, UART_OMAP_SCR, up->scr); |
823 | 843 | ||
824 | serial_out(up, UART_EFR, up->efr); | 844 | serial_out(up, UART_EFR, up->efr); |
@@ -1160,7 +1180,7 @@ static struct uart_driver serial_omap_reg = { | |||
1160 | .cons = OMAP_CONSOLE, | 1180 | .cons = OMAP_CONSOLE, |
1161 | }; | 1181 | }; |
1162 | 1182 | ||
1163 | #ifdef CONFIG_SUSPEND | 1183 | #ifdef CONFIG_PM_SLEEP |
1164 | static int serial_omap_suspend(struct device *dev) | 1184 | static int serial_omap_suspend(struct device *dev) |
1165 | { | 1185 | { |
1166 | struct uart_omap_port *up = dev_get_drvdata(dev); | 1186 | struct uart_omap_port *up = dev_get_drvdata(dev); |
@@ -1521,6 +1541,7 @@ static void serial_omap_mdr1_errataset(struct uart_omap_port *up, u8 mdr1) | |||
1521 | } | 1541 | } |
1522 | } | 1542 | } |
1523 | 1543 | ||
1544 | #ifdef CONFIG_PM_RUNTIME | ||
1524 | static void serial_omap_restore_context(struct uart_omap_port *up) | 1545 | static void serial_omap_restore_context(struct uart_omap_port *up) |
1525 | { | 1546 | { |
1526 | if (up->errata & UART_ERRATA_i202_MDR1_ACCESS) | 1547 | if (up->errata & UART_ERRATA_i202_MDR1_ACCESS) |
@@ -1550,7 +1571,6 @@ static void serial_omap_restore_context(struct uart_omap_port *up) | |||
1550 | serial_out(up, UART_OMAP_MDR1, up->mdr1); | 1571 | serial_out(up, UART_OMAP_MDR1, up->mdr1); |
1551 | } | 1572 | } |
1552 | 1573 | ||
1553 | #ifdef CONFIG_PM_RUNTIME | ||
1554 | static int serial_omap_runtime_suspend(struct device *dev) | 1574 | static int serial_omap_runtime_suspend(struct device *dev) |
1555 | { | 1575 | { |
1556 | struct uart_omap_port *up = dev_get_drvdata(dev); | 1576 | struct uart_omap_port *up = dev_get_drvdata(dev); |