1b98958af4b64fc3cdc9e560fbb20b717ab30001
[openwrt/staging/blocktrron.git] /
1 From 814453adea7d081ad8917aa0f32d6a14165a3563 Mon Sep 17 00:00:00 2001
2 From: Michal Simek <michal.simek@xilinx.com>
3 Date: Tue, 10 Apr 2018 15:32:28 +0200
4 Subject: earlycon: Initialize port->uartclk based on clock-frequency property
5
6 From: Michal Simek <michal.simek@xilinx.com>
7
8 commit 814453adea7d081ad8917aa0f32d6a14165a3563 upstream.
9
10 On DT based platforms when current-speed property is present baudrate
11 is setup. Also port->uartclk is initialized to bogus BASE_BAUD * 16
12 value. Drivers like uartps/ns16550 contain logic when baudrate and
13 uartclk is used for baudrate calculation.
14
15 The patch is reading optional clock-frequency property to replace bogus
16 BASE_BAUD * 16 calculation to have proper baudrate calculation.
17
18 [-stable comment: commit 31cb9a8575ca ("earlycon: initialise baud field
19 of earlycon device structure") has changed 8250_early.c behavior which
20 now tries to setup UART speed. Ignoring clock-frequency results in
21 wrong value of calculated divisor & malformed early console output.]
22
23 Fixes: 31cb9a8575ca ("earlycon: initialise baud field of earlycon device structure")
24 Signed-off-by: Michal Simek <michal.simek@xilinx.com>
25 [rmilecki: add -stable comment and Fixes tag]
26 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
27 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
28
29 ---
30 drivers/tty/serial/earlycon.c | 4 ++++
31 1 file changed, 4 insertions(+)
32
33 --- a/drivers/tty/serial/earlycon.c
34 +++ b/drivers/tty/serial/earlycon.c
35 @@ -289,6 +289,10 @@ int __init of_setup_earlycon(const struc
36 if (val)
37 early_console_dev.baud = be32_to_cpu(*val);
38
39 + val = of_get_flat_dt_prop(node, "clock-frequency", NULL);
40 + if (val)
41 + port->uartclk = be32_to_cpu(*val);
42 +
43 if (options) {
44 early_console_dev.baud = simple_strtoul(options, NULL, 0);
45 strlcpy(early_console_dev.options, options,