4.2.4. Porting UART¶
AM62x has multiple UART instances integrated. This section explains how to enable a UART in the kernel.
4.2.4.1. UART Kernel Config Options¶
The UART IP on AM62x is 16C750 compatible. The kernel uses the 8250 UART drivers in the TTY framework to operate the UART IP. In order to enable the relevant UART drivers, the following kernel config options should be enabled in kernel menuconfig:
Device Drivers --->
Character devices --->
[*] Enable TTY
Serial drivers --->
<M> 8250/16550 and compatible serial support
[*] DMA support for 16550 compatible UART controllers
<M> Support for OMAP internal UART (8250 based driver)
4.2.4.2. UART DT Bindings¶
There are two areas in the UART devicetree (DT) bindings: pinmux, and devicetree properties. UART pinmux defines which UART pins to use. The UART DT properties provide information to the UART platform driver for how to configure the UART IP (clocking, interrupts, etc.).
4.2.4.2.1. UART Pinmux¶
Use the SysConfig tool or the AM62x Datasheet and TRM to determine the UART pinmux settings.
Here is an example of pinmux setting for MAIN UART0 on AM62x defined in k3-am625-sk.dts:
&main_pmx0 {
main_uart0_pins_default: main-uart0-pins-default {
pinctrl-single,pins = <
AM62X_IOPAD(0x1c8, PIN_INPUT, 0) /* (D14) UART0_RXD */
AM62X_IOPAD(0x1cc, PIN_OUTPUT, 0) /* (E14) UART0_TXD */
>;
};
};
Note
If hardware flow control is not required in the board design, the pinmux of CTS and RTS pins can be omitted.
For details of pinmux DT bindings, please refer to the following kernel documentation:
4.2.4.2.2. UART DT Properties¶
The UART DT properties are defined in the SoC DTSI files k3-am62-main.dtsi and k3-am62-mcu.dtsi. In general, if DT properties need to be customized, they can be modified in the board DTS file. However, the UART DT properties are not board specific, so they do not need to be modified.
To enable a UART, add the pinmux defined in the previous section to the UART DT node and add the uart node name to aliases node in the board DT file.
aliases {
...
serial2 = &main_uart0;
...
};
...
&main_uart0 {
pinctrl-names = "default";
pinctrl-0 = <&main_uart0_pins_default>;
};
Note
status = “okay”; can be added in a DT node if desired. However, UART is enabled even if status is not explicitly set to “okay”. That is because all DT nodes defined in the SoC DTSI files are enabled by default.
For details of UART DT bindings, please refer to the following kernel documentation.