blob: f8768d0e1bc013014d15b90f83bc99c92d578455 [file] [log] [blame]
Algapally Santosh Sagarbd9ff682023-09-21 16:50:43 +05301Fetch serial baudrate from DT
2-----------------------------
3
4To support fetching of baudrate from DT, the following is done:-
5
6The baudrate configured in Kconfig symbol CONFIG_BAUDRATE is taken by default by serial.
7If change of baudrate is required then the Kconfig symbol CONFIG_BAUDRATE needs to
8changed and U-Boot recompilation is required or the U-Boot environment needs to be updated.
9
10To avoid this, add support to fetch the baudrate directly from the device tree file and
11update the environment.
12
13The default environment stores the default baudrate value. When default baudrate and dtb
14baudrate are not same glitches are seen on the serial.
15So, the environment also needs to be updated with the dtb baudrate to avoid the glitches on
16the serial which is enabled by OF_SERIAL_BAUD.
17
18The Kconfig SPL_ENV_SUPPORT needs to be enabled to allow patching in SPL.
19
20The Kconfig DEFAULT_ENV_IS_RW which is enabled by OF_SERIAL_BAUD with making the environment
21writable.
22
23The ofnode_read_baud() function parses and fetches the baudrate value from the DT. This value
24is validated and updated to baudrate during serial init. Padding is added at the end of the
25default environment and the dt baudrate is updated with the latest value.
26
27Example:-
28
29The serial port options are of the form "bbbbpnf", where "bbbb" is the baud rate, "p" is parity ("n", "o", or "e"),
30"n" is number of bits, and "f" is flow control ("r" for RTS or omit it). Default is "115200n8".
31
32chosen {
33 bootargs = "earlycon console=ttyPS0,115200 clk_ignore_unused root=/dev/ram0 rw init_fatal_sh=1";
34 stdout-path = "serial0:115200n8";
35 };
36
37From the chosen node, stdout-path property is obtained as string.
38
39 stdout-path = "serial0:115200n8";
40
41The string is parsed to get the baudrate 115200. This string is converted to integer and updated to the environment.