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