821-serial-core-add-support-for-boot-console-with-arbitr.patch 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. The Arduino Yun uses a baud rate of 250000 by default. The serial is
  7. going over the Atmel ATmega and is used to connect to this chip.
  8. Without this patch Linux wants to switch the console to 230400 Baud.
  9. With this patch Linux will use the configured baud rate and not some
  10. standard one which is near by.
  11. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
  12. ---
  13. drivers/tty/serial/serial_core.c | 13 ++++++++++---
  14. include/linux/console.h | 1 +
  15. 2 files changed, 11 insertions(+), 3 deletions(-)
  16. --- a/drivers/tty/serial/serial_core.c
  17. +++ b/drivers/tty/serial/serial_core.c
  18. @@ -164,6 +164,8 @@ static int uart_port_startup(struct tty_
  19. if (retval == 0) {
  20. if (uart_console(uport) && uport->cons->cflag) {
  21. tty->termios.c_cflag = uport->cons->cflag;
  22. + tty->termios.c_ospeed = uport->cons->baud;
  23. + tty->termios.c_ispeed = uport->cons->baud;
  24. uport->cons->cflag = 0;
  25. }
  26. /*
  27. @@ -1901,7 +1903,7 @@ static const struct baud_rates baud_rate
  28. { 4800, B4800 },
  29. { 2400, B2400 },
  30. { 1200, B1200 },
  31. - { 0, B38400 }
  32. + { 0, BOTHER }
  33. };
  34. /**
  35. @@ -1940,10 +1942,13 @@ uart_set_options(struct uart_port *port,
  36. * Construct a cflag setting.
  37. */
  38. for (i = 0; baud_rates[i].rate; i++)
  39. - if (baud_rates[i].rate <= baud)
  40. + if (baud_rates[i].rate == baud)
  41. break;
  42. termios.c_cflag |= baud_rates[i].cflag;
  43. + if (!baud_rates[i].rate) {
  44. + termios.c_ospeed = baud;
  45. + }
  46. if (bits == 7)
  47. termios.c_cflag |= CS7;
  48. @@ -1973,8 +1978,10 @@ uart_set_options(struct uart_port *port,
  49. * Allow the setting of the UART parameters with a NULL console
  50. * too:
  51. */
  52. - if (co)
  53. + if (co) {
  54. co->cflag = termios.c_cflag;
  55. + co->baud = baud;
  56. + }
  57. return 0;
  58. }
  59. --- a/include/linux/console.h
  60. +++ b/include/linux/console.h
  61. @@ -127,6 +127,7 @@ struct console {
  62. short flags;
  63. short index;
  64. int cflag;
  65. + int baud;
  66. void *data;
  67. struct console *next;
  68. };