diff options
author | Teppei Kamijou <teppei.kamijou.yb@renesas.com> | 2012-11-15 20:51:55 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-11-15 21:02:36 -0500 |
commit | 0174e5ca82ba6bd62ab870e5781b72bd5397f1c3 (patch) | |
tree | 1a57c3e61950d111952a20fcedd966d9713ed471 /drivers/tty | |
parent | 00cadbfd1e73fb9951da7d2358c39b561c017ea3 (diff) |
serial: sh-sci: console runtime PM support (revisit)
The commit 1ba7622094 (serial: sh-sci: console Runtime PM support,
from Magnus Damm <damm@opensource.se>, 2011-08-03), tried to support
console runtime PM, but unfortunately it didn't work for us for some
reason. We did not investigated further at that time, instead would
like to propose a different approach.
In Linux tty/serial world, to get console PM work properly, a serial
client driver does not have to maintain .runtime_suspend()/..resume()
calls itself, but can leave console power power management handling to
the serial core driver.
This patch moves the sh-sci driver in that direction.
Notes:
* There is room to optimize console runtime PM more aggressively by
maintaining additional local runtime PM calls, but as a first step
having .pm() operation would suffice.
* We still have a couple of direct calls to sci_port_enable/..disable
left in the driver. We have to live with them, because they're out
of serial core's help.
Signed-off-by: Teppei Kamijou <teppei.kamijou.yb@renesas.com>
Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/serial/sh-sci.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 602d0781c6c8..8aade611d1a8 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c | |||
@@ -1747,8 +1747,6 @@ static int sci_startup(struct uart_port *port) | |||
1747 | 1747 | ||
1748 | dev_dbg(port->dev, "%s(%d)\n", __func__, port->line); | 1748 | dev_dbg(port->dev, "%s(%d)\n", __func__, port->line); |
1749 | 1749 | ||
1750 | sci_port_enable(s); | ||
1751 | |||
1752 | ret = sci_request_irq(s); | 1750 | ret = sci_request_irq(s); |
1753 | if (unlikely(ret < 0)) | 1751 | if (unlikely(ret < 0)) |
1754 | return ret; | 1752 | return ret; |
@@ -1772,8 +1770,6 @@ static void sci_shutdown(struct uart_port *port) | |||
1772 | 1770 | ||
1773 | sci_free_dma(port); | 1771 | sci_free_dma(port); |
1774 | sci_free_irq(s); | 1772 | sci_free_irq(s); |
1775 | |||
1776 | sci_port_disable(s); | ||
1777 | } | 1773 | } |
1778 | 1774 | ||
1779 | static unsigned int sci_scbrr_calc(unsigned int algo_id, unsigned int bps, | 1775 | static unsigned int sci_scbrr_calc(unsigned int algo_id, unsigned int bps, |
@@ -1922,6 +1918,21 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios, | |||
1922 | sci_port_disable(s); | 1918 | sci_port_disable(s); |
1923 | } | 1919 | } |
1924 | 1920 | ||
1921 | static void sci_pm(struct uart_port *port, unsigned int state, | ||
1922 | unsigned int oldstate) | ||
1923 | { | ||
1924 | struct sci_port *sci_port = to_sci_port(port); | ||
1925 | |||
1926 | switch (state) { | ||
1927 | case 3: | ||
1928 | sci_port_disable(sci_port); | ||
1929 | break; | ||
1930 | default: | ||
1931 | sci_port_enable(sci_port); | ||
1932 | break; | ||
1933 | } | ||
1934 | } | ||
1935 | |||
1925 | static const char *sci_type(struct uart_port *port) | 1936 | static const char *sci_type(struct uart_port *port) |
1926 | { | 1937 | { |
1927 | switch (port->type) { | 1938 | switch (port->type) { |
@@ -2043,6 +2054,7 @@ static struct uart_ops sci_uart_ops = { | |||
2043 | .startup = sci_startup, | 2054 | .startup = sci_startup, |
2044 | .shutdown = sci_shutdown, | 2055 | .shutdown = sci_shutdown, |
2045 | .set_termios = sci_set_termios, | 2056 | .set_termios = sci_set_termios, |
2057 | .pm = sci_pm, | ||
2046 | .type = sci_type, | 2058 | .type = sci_type, |
2047 | .release_port = sci_release_port, | 2059 | .release_port = sci_release_port, |
2048 | .request_port = sci_request_port, | 2060 | .request_port = sci_request_port, |
@@ -2196,16 +2208,12 @@ static void serial_console_write(struct console *co, const char *s, | |||
2196 | struct uart_port *port = &sci_port->port; | 2208 | struct uart_port *port = &sci_port->port; |
2197 | unsigned short bits; | 2209 | unsigned short bits; |
2198 | 2210 | ||
2199 | sci_port_enable(sci_port); | ||
2200 | |||
2201 | uart_console_write(port, s, count, serial_console_putchar); | 2211 | uart_console_write(port, s, count, serial_console_putchar); |
2202 | 2212 | ||
2203 | /* wait until fifo is empty and last bit has been transmitted */ | 2213 | /* wait until fifo is empty and last bit has been transmitted */ |
2204 | bits = SCxSR_TDxE(port) | SCxSR_TEND(port); | 2214 | bits = SCxSR_TDxE(port) | SCxSR_TEND(port); |
2205 | while ((serial_port_in(port, SCxSR) & bits) != bits) | 2215 | while ((serial_port_in(port, SCxSR) & bits) != bits) |
2206 | cpu_relax(); | 2216 | cpu_relax(); |
2207 | |||
2208 | sci_port_disable(sci_port); | ||
2209 | } | 2217 | } |
2210 | 2218 | ||
2211 | static int __devinit serial_console_setup(struct console *co, char *options) | 2219 | static int __devinit serial_console_setup(struct console *co, char *options) |
@@ -2237,12 +2245,9 @@ static int __devinit serial_console_setup(struct console *co, char *options) | |||
2237 | if (unlikely(ret != 0)) | 2245 | if (unlikely(ret != 0)) |
2238 | return ret; | 2246 | return ret; |
2239 | 2247 | ||
2240 | sci_port_enable(sci_port); | ||
2241 | |||
2242 | if (options) | 2248 | if (options) |
2243 | uart_parse_options(options, &baud, &parity, &bits, &flow); | 2249 | uart_parse_options(options, &baud, &parity, &bits, &flow); |
2244 | 2250 | ||
2245 | /* TODO: disable clock */ | ||
2246 | return uart_set_options(port, co, baud, parity, bits, flow); | 2251 | return uart_set_options(port, co, baud, parity, bits, flow); |
2247 | } | 2252 | } |
2248 | 2253 | ||