4.2.2. Porting UART

AM64x has multiple UART instances integrated. This section explains how to enable a UART in the kernel.

4.2.2.1. UART Kernel Config Options

The UART IP on AM64x 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.2.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.2.2.1. UART Pinmux

Use the SysConfig tool or the AM64x Datasheet and TRM to determine the UART pinmux settings.

Here is an example of pinmux setting for MAIN UART0 on AM64x defined in k3-am642-evm.dts:

&main_pmx0 {
        main_uart0_pins_default: main-uart0-pins-default {
                pinctrl-single,pins = <
                        AM64X_IOPAD(0x0238, PIN_INPUT, 0) /* (B16) UART0_CTSn */
                        AM64X_IOPAD(0x023c, PIN_OUTPUT, 0) /* (A16) UART0_RTSn */
                        AM64X_IOPAD(0x0230, PIN_INPUT, 0) /* (D15) UART0_RXD */
                        AM64X_IOPAD(0x0234, PIN_OUTPUT, 0) /* (C16) 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.2.2.2. UART DT Properties

The UART DT properties are defined in the SoC DTSI files k3-am64-main.dtsi and k3-am64-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 in the board DT file.

The following is an example in k3-am642-evm.dts to enable MAIN UART0 for AM64x GPEVM:

&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.