ar71xx: complete support for RB wAP 2nD
[openwrt/openwrt.git] / target / linux / ar71xx / patches-4.4 / 821-serial-core-add-support-for-boot-console-with-arbitr.patch
1 From 4d3c17975c7814884a721fe693b3adf5c426d759 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Tue, 10 Nov 2015 22:18:39 +0100
4 Subject: [RFC] serial: core: add support for boot console with arbitrary
5 baud rates
6
7 The Arduino Yun uses a baud rate of 250000 by default. The serial is
8 going over the Atmel ATmega and is used to connect to this chip.
9 Without this patch Linux wants to switch the console to 230400 Baud.
10
11 With this patch Linux will use the configured baud rate and not some
12 standard one which is near by.
13
14 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
15 ---
16 drivers/tty/serial/serial_core.c | 13 ++++++++++---
17 include/linux/console.h | 1 +
18 2 files changed, 11 insertions(+), 3 deletions(-)
19
20 --- a/drivers/tty/serial/serial_core.c
21 +++ b/drivers/tty/serial/serial_core.c
22 @@ -164,6 +164,8 @@ static int uart_port_startup(struct tty_
23 if (retval == 0) {
24 if (uart_console(uport) && uport->cons->cflag) {
25 tty->termios.c_cflag = uport->cons->cflag;
26 + tty->termios.c_ospeed = uport->cons->baud;
27 + tty->termios.c_ispeed = uport->cons->baud;
28 uport->cons->cflag = 0;
29 }
30 /*
31 @@ -1909,7 +1911,7 @@ static const struct baud_rates baud_rate
32 { 4800, B4800 },
33 { 2400, B2400 },
34 { 1200, B1200 },
35 - { 0, B38400 }
36 + { 0, BOTHER }
37 };
38
39 /**
40 @@ -1948,10 +1950,13 @@ uart_set_options(struct uart_port *port,
41 * Construct a cflag setting.
42 */
43 for (i = 0; baud_rates[i].rate; i++)
44 - if (baud_rates[i].rate <= baud)
45 + if (baud_rates[i].rate == baud)
46 break;
47
48 termios.c_cflag |= baud_rates[i].cflag;
49 + if (!baud_rates[i].rate) {
50 + termios.c_ospeed = baud;
51 + }
52
53 if (bits == 7)
54 termios.c_cflag |= CS7;
55 @@ -1981,8 +1986,10 @@ uart_set_options(struct uart_port *port,
56 * Allow the setting of the UART parameters with a NULL console
57 * too:
58 */
59 - if (co)
60 + if (co) {
61 co->cflag = termios.c_cflag;
62 + co->baud = baud;
63 + }
64
65 return 0;
66 }
67 --- a/include/linux/console.h
68 +++ b/include/linux/console.h
69 @@ -128,6 +128,7 @@ struct console {
70 short flags;
71 short index;
72 int cflag;
73 + int baud;
74 void *data;
75 struct console *next;
76 };