aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/sh-sci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/tty/serial/sh-sci.c')
-rw-r--r--drivers/tty/serial/sh-sci.c72
1 files changed, 61 insertions, 11 deletions
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 2ec57b2fb278..5ea6ec3442e6 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -47,6 +47,7 @@
47#include <linux/ctype.h> 47#include <linux/ctype.h>
48#include <linux/err.h> 48#include <linux/err.h>
49#include <linux/dmaengine.h> 49#include <linux/dmaengine.h>
50#include <linux/dma-mapping.h>
50#include <linux/scatterlist.h> 51#include <linux/scatterlist.h>
51#include <linux/slab.h> 52#include <linux/slab.h>
52 53
@@ -95,6 +96,12 @@ struct sci_port {
95#endif 96#endif
96 97
97 struct notifier_block freq_transition; 98 struct notifier_block freq_transition;
99
100#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
101 unsigned short saved_smr;
102 unsigned short saved_fcr;
103 unsigned char saved_brr;
104#endif
98}; 105};
99 106
100/* Function prototypes */ 107/* Function prototypes */
@@ -1076,7 +1083,7 @@ static unsigned int sci_get_mctrl(struct uart_port *port)
1076 /* This routine is used for getting signals of: DTR, DCD, DSR, RI, 1083 /* This routine is used for getting signals of: DTR, DCD, DSR, RI,
1077 and CTS/RTS */ 1084 and CTS/RTS */
1078 1085
1079 return TIOCM_DTR | TIOCM_RTS | TIOCM_DSR; 1086 return TIOCM_DTR | TIOCM_RTS | TIOCM_CTS | TIOCM_DSR;
1080} 1087}
1081 1088
1082#ifdef CONFIG_SERIAL_SH_SCI_DMA 1089#ifdef CONFIG_SERIAL_SH_SCI_DMA
@@ -1633,11 +1640,25 @@ static unsigned int sci_scbrr_calc(unsigned int algo_id, unsigned int bps,
1633 return ((freq + 16 * bps) / (32 * bps) - 1); 1640 return ((freq + 16 * bps) / (32 * bps) - 1);
1634} 1641}
1635 1642
1643static void sci_reset(struct uart_port *port)
1644{
1645 unsigned int status;
1646
1647 do {
1648 status = sci_in(port, SCxSR);
1649 } while (!(status & SCxSR_TEND(port)));
1650
1651 sci_out(port, SCSCR, 0x00); /* TE=0, RE=0, CKE1=0 */
1652
1653 if (port->type != PORT_SCI)
1654 sci_out(port, SCFCR, SCFCR_RFRST | SCFCR_TFRST);
1655}
1656
1636static void sci_set_termios(struct uart_port *port, struct ktermios *termios, 1657static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
1637 struct ktermios *old) 1658 struct ktermios *old)
1638{ 1659{
1639 struct sci_port *s = to_sci_port(port); 1660 struct sci_port *s = to_sci_port(port);
1640 unsigned int status, baud, smr_val, max_baud; 1661 unsigned int baud, smr_val, max_baud;
1641 int t = -1; 1662 int t = -1;
1642 u16 scfcr = 0; 1663 u16 scfcr = 0;
1643 1664
@@ -1657,14 +1678,7 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
1657 1678
1658 sci_port_enable(s); 1679 sci_port_enable(s);
1659 1680
1660 do { 1681 sci_reset(port);
1661 status = sci_in(port, SCxSR);
1662 } while (!(status & SCxSR_TEND(port)));
1663
1664 sci_out(port, SCSCR, 0x00); /* TE=0, RE=0, CKE1=0 */
1665
1666 if (port->type != PORT_SCI)
1667 sci_out(port, SCFCR, scfcr | SCFCR_RFRST | SCFCR_TFRST);
1668 1682
1669 smr_val = sci_in(port, SCSMR) & 3; 1683 smr_val = sci_in(port, SCSMR) & 3;
1670 1684
@@ -1913,6 +1927,7 @@ static int __devinit sci_init_single(struct platform_device *dev,
1913 1927
1914 port->dev = &dev->dev; 1928 port->dev = &dev->dev;
1915 1929
1930 pm_runtime_irq_safe(&dev->dev);
1916 pm_runtime_enable(&dev->dev); 1931 pm_runtime_enable(&dev->dev);
1917 } 1932 }
1918 1933
@@ -2036,7 +2051,8 @@ static int __devinit serial_console_setup(struct console *co, char *options)
2036 if (options) 2051 if (options)
2037 uart_parse_options(options, &baud, &parity, &bits, &flow); 2052 uart_parse_options(options, &baud, &parity, &bits, &flow);
2038 2053
2039 /* TODO: disable clock */ 2054 sci_port_disable(sci_port);
2055
2040 return uart_set_options(port, co, baud, parity, bits, flow); 2056 return uart_set_options(port, co, baud, parity, bits, flow);
2041} 2057}
2042 2058
@@ -2079,6 +2095,36 @@ static int __devinit sci_probe_earlyprintk(struct platform_device *pdev)
2079 return 0; 2095 return 0;
2080} 2096}
2081 2097
2098#define uart_console(port) ((port)->cons->index == (port)->line)
2099
2100static int sci_runtime_suspend(struct device *dev)
2101{
2102 struct sci_port *sci_port = dev_get_drvdata(dev);
2103 struct uart_port *port = &sci_port->port;
2104
2105 if (uart_console(port)) {
2106 sci_port->saved_smr = sci_in(port, SCSMR);
2107 sci_port->saved_brr = sci_in(port, SCBRR);
2108 sci_port->saved_fcr = sci_in(port, SCFCR);
2109 }
2110 return 0;
2111}
2112
2113static int sci_runtime_resume(struct device *dev)
2114{
2115 struct sci_port *sci_port = dev_get_drvdata(dev);
2116 struct uart_port *port = &sci_port->port;
2117
2118 if (uart_console(port)) {
2119 sci_reset(port);
2120 sci_out(port, SCSMR, sci_port->saved_smr);
2121 sci_out(port, SCBRR, sci_port->saved_brr);
2122 sci_out(port, SCFCR, sci_port->saved_fcr);
2123 sci_out(port, SCSCR, sci_port->cfg->scscr);
2124 }
2125 return 0;
2126}
2127
2082#define SCI_CONSOLE (&serial_console) 2128#define SCI_CONSOLE (&serial_console)
2083 2129
2084#else 2130#else
@@ -2088,6 +2134,8 @@ static inline int __devinit sci_probe_earlyprintk(struct platform_device *pdev)
2088} 2134}
2089 2135
2090#define SCI_CONSOLE NULL 2136#define SCI_CONSOLE NULL
2137#define sci_runtime_suspend NULL
2138#define sci_runtime_resume NULL
2091 2139
2092#endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */ 2140#endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */
2093 2141
@@ -2203,6 +2251,8 @@ static int sci_resume(struct device *dev)
2203} 2251}
2204 2252
2205static const struct dev_pm_ops sci_dev_pm_ops = { 2253static const struct dev_pm_ops sci_dev_pm_ops = {
2254 .runtime_suspend = sci_runtime_suspend,
2255 .runtime_resume = sci_runtime_resume,
2206 .suspend = sci_suspend, 2256 .suspend = sci_suspend,
2207 .resume = sci_resume, 2257 .resume = sci_resume,
2208}; 2258};