|
@@ -1827,7 +1827,7 @@ uart_get_console(struct uart_port *ports, int nr, struct console *co)
|
|
* options. The format of the string is <baud><parity><bits><flow>,
|
|
* options. The format of the string is <baud><parity><bits><flow>,
|
|
* eg: 115200n8r
|
|
* eg: 115200n8r
|
|
*/
|
|
*/
|
|
-void __init
|
|
|
|
|
|
+void
|
|
uart_parse_options(char *options, int *baud, int *parity, int *bits, int *flow)
|
|
uart_parse_options(char *options, int *baud, int *parity, int *bits, int *flow)
|
|
{
|
|
{
|
|
char *s = options;
|
|
char *s = options;
|
|
@@ -1842,6 +1842,7 @@ uart_parse_options(char *options, int *baud, int *parity, int *bits, int *flow)
|
|
if (*s)
|
|
if (*s)
|
|
*flow = *s;
|
|
*flow = *s;
|
|
}
|
|
}
|
|
|
|
+EXPORT_SYMBOL_GPL(uart_parse_options);
|
|
|
|
|
|
struct baud_rates {
|
|
struct baud_rates {
|
|
unsigned int rate;
|
|
unsigned int rate;
|
|
@@ -1872,7 +1873,7 @@ static const struct baud_rates baud_rates[] = {
|
|
* @bits: number of data bits
|
|
* @bits: number of data bits
|
|
* @flow: flow control character - 'r' (rts)
|
|
* @flow: flow control character - 'r' (rts)
|
|
*/
|
|
*/
|
|
-int __init
|
|
|
|
|
|
+int
|
|
uart_set_options(struct uart_port *port, struct console *co,
|
|
uart_set_options(struct uart_port *port, struct console *co,
|
|
int baud, int parity, int bits, int flow)
|
|
int baud, int parity, int bits, int flow)
|
|
{
|
|
{
|
|
@@ -1924,10 +1925,16 @@ uart_set_options(struct uart_port *port, struct console *co,
|
|
port->mctrl |= TIOCM_DTR;
|
|
port->mctrl |= TIOCM_DTR;
|
|
|
|
|
|
port->ops->set_termios(port, &termios, &dummy);
|
|
port->ops->set_termios(port, &termios, &dummy);
|
|
- co->cflag = termios.c_cflag;
|
|
|
|
|
|
+ /*
|
|
|
|
+ * Allow the setting of the UART parameters with a NULL console
|
|
|
|
+ * too:
|
|
|
|
+ */
|
|
|
|
+ if (co)
|
|
|
|
+ co->cflag = termios.c_cflag;
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
+EXPORT_SYMBOL_GPL(uart_set_options);
|
|
#endif /* CONFIG_SERIAL_CORE_CONSOLE */
|
|
#endif /* CONFIG_SERIAL_CORE_CONSOLE */
|
|
|
|
|
|
static void uart_change_pm(struct uart_state *state, int pm_state)
|
|
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,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#ifdef CONFIG_CONSOLE_POLL
|
|
|
|
+
|
|
|
|
+static int uart_poll_init(struct tty_driver *driver, int line, char *options)
|
|
|
|
+{
|
|
|
|
+ struct uart_driver *drv = driver->driver_state;
|
|
|
|
+ struct uart_state *state = drv->state + line;
|
|
|
|
+ struct uart_port *port;
|
|
|
|
+ int baud = 9600;
|
|
|
|
+ int bits = 8;
|
|
|
|
+ int parity = 'n';
|
|
|
|
+ int flow = 'n';
|
|
|
|
+
|
|
|
|
+ if (!state || !state->port)
|
|
|
|
+ return -1;
|
|
|
|
+
|
|
|
|
+ port = state->port;
|
|
|
|
+ if (!(port->ops->poll_get_char && port->ops->poll_put_char))
|
|
|
|
+ return -1;
|
|
|
|
+
|
|
|
|
+ if (options) {
|
|
|
|
+ uart_parse_options(options, &baud, &parity, &bits, &flow);
|
|
|
|
+ return uart_set_options(port, NULL, baud, parity, bits, flow);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int uart_poll_get_char(struct tty_driver *driver, int line)
|
|
|
|
+{
|
|
|
|
+ struct uart_driver *drv = driver->driver_state;
|
|
|
|
+ struct uart_state *state = drv->state + line;
|
|
|
|
+ struct uart_port *port;
|
|
|
|
+
|
|
|
|
+ if (!state || !state->port)
|
|
|
|
+ return -1;
|
|
|
|
+
|
|
|
|
+ port = state->port;
|
|
|
|
+ return port->ops->poll_get_char(port);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void uart_poll_put_char(struct tty_driver *driver, int line, char ch)
|
|
|
|
+{
|
|
|
|
+ struct uart_driver *drv = driver->driver_state;
|
|
|
|
+ struct uart_state *state = drv->state + line;
|
|
|
|
+ struct uart_port *port;
|
|
|
|
+
|
|
|
|
+ if (!state || !state->port)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ port = state->port;
|
|
|
|
+ port->ops->poll_put_char(port, ch);
|
|
|
|
+}
|
|
|
|
+#endif
|
|
|
|
+
|
|
static const struct tty_operations uart_ops = {
|
|
static const struct tty_operations uart_ops = {
|
|
.open = uart_open,
|
|
.open = uart_open,
|
|
.close = uart_close,
|
|
.close = uart_close,
|
|
@@ -2206,6 +2267,11 @@ static const struct tty_operations uart_ops = {
|
|
#endif
|
|
#endif
|
|
.tiocmget = uart_tiocmget,
|
|
.tiocmget = uart_tiocmget,
|
|
.tiocmset = uart_tiocmset,
|
|
.tiocmset = uart_tiocmset,
|
|
|
|
+#ifdef CONFIG_CONSOLE_POLL
|
|
|
|
+ .poll_init = uart_poll_init,
|
|
|
|
+ .poll_get_char = uart_poll_get_char,
|
|
|
|
+ .poll_put_char = uart_poll_put_char,
|
|
|
|
+#endif
|
|
};
|
|
};
|
|
|
|
|
|
/**
|
|
/**
|