diff options
author | Jason Wessel <jason.wessel@windriver.com> | 2008-04-17 14:05:37 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-04-17 14:05:37 -0400 |
commit | f2d937f3bf00665ccf048b3b6616ef95859b0945 (patch) | |
tree | 6136ded0706be0d39a09a0a912e8f79a4ab63322 /drivers/serial/serial_core.c | |
parent | dc7d552705215ac50a0617fcf51bb9c736255b8e (diff) |
consoles: polling support, kgdboc
polled console handling support, to access a console in an irq-less
way while in debug or irq context.
absolutely zero impact as long as CONFIG_CONSOLE_POLL is disabled.
(which is the default)
[ jan.kiszka@siemens.com: lots of cleanups ]
[ mingo@elte.hu: redesign, splitups, cleanups. ]
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/serial/serial_core.c')
-rw-r--r-- | drivers/serial/serial_core.c | 72 |
1 files changed, 69 insertions, 3 deletions
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index 0f5a17987cc..4d7eecbead9 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c | |||
@@ -1827,7 +1827,7 @@ uart_get_console(struct uart_port *ports, int nr, struct console *co) | |||
1827 | * options. The format of the string is <baud><parity><bits><flow>, | 1827 | * options. The format of the string is <baud><parity><bits><flow>, |
1828 | * eg: 115200n8r | 1828 | * eg: 115200n8r |
1829 | */ | 1829 | */ |
1830 | void __init | 1830 | void |
1831 | uart_parse_options(char *options, int *baud, int *parity, int *bits, int *flow) | 1831 | uart_parse_options(char *options, int *baud, int *parity, int *bits, int *flow) |
1832 | { | 1832 | { |
1833 | char *s = options; | 1833 | char *s = options; |
@@ -1842,6 +1842,7 @@ uart_parse_options(char *options, int *baud, int *parity, int *bits, int *flow) | |||
1842 | if (*s) | 1842 | if (*s) |
1843 | *flow = *s; | 1843 | *flow = *s; |
1844 | } | 1844 | } |
1845 | EXPORT_SYMBOL_GPL(uart_parse_options); | ||
1845 | 1846 | ||
1846 | struct baud_rates { | 1847 | struct baud_rates { |
1847 | unsigned int rate; | 1848 | unsigned int rate; |
@@ -1872,7 +1873,7 @@ static const struct baud_rates baud_rates[] = { | |||
1872 | * @bits: number of data bits | 1873 | * @bits: number of data bits |
1873 | * @flow: flow control character - 'r' (rts) | 1874 | * @flow: flow control character - 'r' (rts) |
1874 | */ | 1875 | */ |
1875 | int __init | 1876 | int |
1876 | uart_set_options(struct uart_port *port, struct console *co, | 1877 | uart_set_options(struct uart_port *port, struct console *co, |
1877 | int baud, int parity, int bits, int flow) | 1878 | int baud, int parity, int bits, int flow) |
1878 | { | 1879 | { |
@@ -1924,10 +1925,16 @@ uart_set_options(struct uart_port *port, struct console *co, | |||
1924 | port->mctrl |= TIOCM_DTR; | 1925 | port->mctrl |= TIOCM_DTR; |
1925 | 1926 | ||
1926 | port->ops->set_termios(port, &termios, &dummy); | 1927 | port->ops->set_termios(port, &termios, &dummy); |
1927 | co->cflag = termios.c_cflag; | 1928 | /* |
1929 | * Allow the setting of the UART parameters with a NULL console | ||
1930 | * too: | ||
1931 | */ | ||
1932 | if (co) | ||
1933 | co->cflag = termios.c_cflag; | ||
1928 | 1934 | ||
1929 | return 0; | 1935 | return 0; |
1930 | } | 1936 | } |
1937 | EXPORT_SYMBOL_GPL(uart_set_options); | ||
1931 | #endif /* CONFIG_SERIAL_CORE_CONSOLE */ | 1938 | #endif /* CONFIG_SERIAL_CORE_CONSOLE */ |
1932 | 1939 | ||
1933 | static void uart_change_pm(struct uart_state *state, int pm_state) | 1940 | static void uart_change_pm(struct uart_state *state, int pm_state) |
@@ -2182,6 +2189,60 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state, | |||
2182 | } | 2189 | } |
2183 | } | 2190 | } |
2184 | 2191 | ||
2192 | #ifdef CONFIG_CONSOLE_POLL | ||
2193 | |||
2194 | static int uart_poll_init(struct tty_driver *driver, int line, char *options) | ||
2195 | { | ||
2196 | struct uart_driver *drv = driver->driver_state; | ||
2197 | struct uart_state *state = drv->state + line; | ||
2198 | struct uart_port *port; | ||
2199 | int baud = 9600; | ||
2200 | int bits = 8; | ||
2201 | int parity = 'n'; | ||
2202 | int flow = 'n'; | ||
2203 | |||
2204 | if (!state || !state->port) | ||
2205 | return -1; | ||
2206 | |||
2207 | port = state->port; | ||
2208 | if (!(port->ops->poll_get_char && port->ops->poll_put_char)) | ||
2209 | return -1; | ||
2210 | |||
2211 | if (options) { | ||
2212 | uart_parse_options(options, &baud, &parity, &bits, &flow); | ||
2213 | return uart_set_options(port, NULL, baud, parity, bits, flow); | ||
2214 | } | ||
2215 | |||
2216 | return 0; | ||
2217 | } | ||
2218 | |||
2219 | static int uart_poll_get_char(struct tty_driver *driver, int line) | ||
2220 | { | ||
2221 | struct uart_driver *drv = driver->driver_state; | ||
2222 | struct uart_state *state = drv->state + line; | ||
2223 | struct uart_port *port; | ||
2224 | |||
2225 | if (!state || !state->port) | ||
2226 | return -1; | ||
2227 | |||
2228 | port = state->port; | ||
2229 | return port->ops->poll_get_char(port); | ||
2230 | } | ||
2231 | |||
2232 | static void uart_poll_put_char(struct tty_driver *driver, int line, char ch) | ||
2233 | { | ||
2234 | struct uart_driver *drv = driver->driver_state; | ||
2235 | struct uart_state *state = drv->state + line; | ||
2236 | struct uart_port *port; | ||
2237 | |||
2238 | if (!state || !state->port) | ||
2239 | return; | ||
2240 | |||
2241 | port = state->port; | ||
2242 | port->ops->poll_put_char(port, ch); | ||
2243 | } | ||
2244 | #endif | ||
2245 | |||
2185 | static const struct tty_operations uart_ops = { | 2246 | static const struct tty_operations uart_ops = { |
2186 | .open = uart_open, | 2247 | .open = uart_open, |
2187 | .close = uart_close, | 2248 | .close = uart_close, |
@@ -2206,6 +2267,11 @@ static const struct tty_operations uart_ops = { | |||
2206 | #endif | 2267 | #endif |
2207 | .tiocmget = uart_tiocmget, | 2268 | .tiocmget = uart_tiocmget, |
2208 | .tiocmset = uart_tiocmset, | 2269 | .tiocmset = uart_tiocmset, |
2270 | #ifdef CONFIG_CONSOLE_POLL | ||
2271 | .poll_init = uart_poll_init, | ||
2272 | .poll_get_char = uart_poll_get_char, | ||
2273 | .poll_put_char = uart_poll_put_char, | ||
2274 | #endif | ||
2209 | }; | 2275 | }; |
2210 | 2276 | ||
2211 | /** | 2277 | /** |