4.2.2. Porting UART

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

4.2.2.1. UART Kernel Config Options

The UART IP on AM64x is 16C750 compatible. Kernel uses the 8250 UART drivers in TTY framework to operate the UART IP. To enable the relevant UART drivers, the following kernel config options should be enabled in kernel menuconfig which is detailed in Build Kernel.

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 UART devicetree (DT) bindings, Pinmux and devicetree properties. Pinmux defines which UART pins to use, while the UART DT properties provide information to the UART platform driver for how to configure the UART IP, such as clock, interrupt, etc.

4.2.2.2.1. UART Pinmux

Using SysConfig tool or AM64x Datasheet and TRM to determine the pinmux settings for the UART pins to use.

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 SoC DTSI file k3-am64-main.dts and k3-am64-mcu.dts. Those properties are not board specific, so it is unnecessary to make any change.

To enable an UART, only add the pinmux defined in the previous section to the UART DT node in the board DT file.

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

It is optional to specifically add status = “okay”; in a DT node to enable the module, because all the DT nodes defined in SoC DTSI files are enabled by default.

For details of UART DT bindings, please refer to the following kernel documentation.