This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM6442: AM6442 RS485 Communication in linux

Part Number: AM6442

Tool/software:

Dear TI Support Team,

I am currently working on RS485 communication on the AM64x platform using UART6 in RS485 mode. I've enbaled the uart with CTS and RTS pin configuration, please find the below dts code snippet and I have enabled the RS485 bindings in the device tree and configured the direction control using a GPIO mapped via rts-gpios. However, I am encountering issues with consistent communication on the RS485 bus.

Key Configuration:

  • SoC: AM6442

  • Kernel Version: 6.6.58-rt45-ti-rt-01780-gc79d7ef3a56f-dirty

  • UART Driver: 8250_omap

  • Direction Control: GPIO pin configured using rts-gpios as well as UART RTS

  • DTS code snippet for UART configured with CTS and RTS, here the RTS pin will act as direction control for RS485:

    main_uart6_pins_default: main-uart6-pins-default {

            bootph-all;

            pinctrl-single,pins = <

                AM64X_IOPAD(0x0074, PIN_INPUT, 2) /* (Y21) GPMC0_AD14.UART6_RXD */

                AM64X_IOPAD(0x0078, PIN_OUTPUT, 2) /* (Y20) GPMC0_AD15.UART6_TXD */

                AM64X_IOPAD(0x006c, PIN_INPUT, 2)   /*(W21) GPMC0_AD12.UART6_CTSn */

                AM64X_IOPAD(0x0090, PIN_OUTPUT, 2)  /*(P17) GPMC0_BE0n_CLE.UART6_RTSn */

            >;

    &main_uart6 {

        status = "okay";

        pinctrl-names = "default";

        pinctrl-0 = <&main_uart6_pins_default>;

    };

  • RS485 DTS Binding, here RTS pin is configured as GPIO and RS485 binding properties have defined in the dts, please go through the following code snippet.            

    main_uart6_pins_default: main-uart6-pins-default {

            bootph-all;

            pinctrl-single,pins = <

                AM64X_IOPAD(0x0074, PIN_INPUT, 2) /* (Y21) GPMC0_AD14.UART6_RXD */

                AM64X_IOPAD(0x0078, PIN_OUTPUT, 2) /* (Y20) GPMC0_AD15.UART6_TXD */

            >;

        };

     

        /* RS485 Direction control pin */

            rs485_driver_receiver_enable_pin: rs485-DE-RE-pin-default {

                pinctrl-single,pins = <

                    AM64X_IOPAD(0x0090, PIN_OUTPUT, 7)  /* (P17) GPMC0_BE0n_CLE.UART6_RTSn as GPIO

                >;

            };

       &main_uart6 {

        status = "okay";

        pinctrl-names = "default";

        pinctrl-0 = <&main_uart6_pins_default &rs485_driver_receiver_enable_pin>;

     

        linux,rs485-enabled-at-boot-time;

        rs485-rts-active-high;

        rs485-rx-during-tx;

        rts-gpios = <&main_gpio0 35 GPIO_ACTIVE_LOW>;

    };

Issue Description:

  • The GPIO used for direction control is not toggling as expected during TX/RX cycles.

  • When using user-space applications with TIOCSRS485 ioctl, the direction seems to stay fixed.

  • Attempted loopback and external device testing fail intermittently.

Request:

  • Please confirm whether 8250_omap fully supports RS485 with rts-gpios on AM64x.

  • Are there known limitations or patches required for direction control to function reliably with GPIO?

  • Is there an example or recommended configuration for RS485 duplexing on this SoC?

Looking forward to your guidance or any reference materials you could share.

Regards,

Saranbabu KM

  • Hi, I am out of office for the next two weeks. Please expect delayed response.

  • Hi Saranbabu,

    AM64x supports hardware controlled RS-485 DE control through the RTS pin, please see the TRM 12.1.5.2.2 "RS-485 Functional Interfaces" for details.

    In Linux, please set the RTS pinmux the to native RTS mode, not GPIO mode, and remove rts-gpios property from the UART node in devicetree.

  • Hi Bin Liu,

    Thanks for your reply.

    I configured RTS pin for RTS mode, but it is working in opposite direction, due to that I can't transmit and receive data over RS485 full and half duplex modes.  According to my RS485 transceiver, RTS pin should go high during the data transmission and vice-versa for data reception.  I've read one of your post from the community, since the RTS pin belongs to RTSn or invert pin, so the functionality remains the same according to the pin nature.  Here my question is how to change RTS functionality require to my RS485 transceiver IC?, Is there any driver modification required?, if not, how to do in dts file.

    Connection remains same which is mentioned in TRM 12.1.5.2.2

    I looking your response to proceed further, please reply as soon as possible.

    Regards

    Saranbabu KM

  • Hi Saranbabu,

    The DE polarity should be controlled by register MDR3 bit3.

  • Hi Bin Liu,

    Thanks for your quick response.

    To change the polarity of the RTS pin, Does driver level modification is required in linux kernel?.  Is there any possible way to configure the polarity of RTS in dts file?.  Please let me know.

    Regards

    Saranbabu KM

  • The uart driver does not support it, so driver modification is needed.

    If you need help in the modification, please wait until next week. I am out of office this week.