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.

AM3354: UART RTS as RS485 Direction Control and RS232 RTS

Part Number: AM3354

Hi,

We want to use the 'UART1_RTSn’ pin of UART1 as RTS in RS232 Mode and Direction Control pin in RS485 Mode.

For that we set DTB as follows.

uart1_pins: pinmux_uart1_pins {
        pinctrl-single,pins = <
            0x178 (PIN_INPUT | MUX_MODE0)        /* uart1_ctsn.uart1_ctsn */
            0x17C (PIN_OUTPUT_PULLDOWN | MUX_MODE0)    /* uart1_rtsn.uart1_rtsn */
            0x180 (PIN_INPUT_PULLUP | MUX_MODE0)    /* uart1_rxd.uart1_rxd */
            0x184 (PIN_OUTPUT_PULLDOWN | MUX_MODE0)    /* uart1_txd.uart1_txd */  
            0xFC (PIN_INPUT | MUX_MODE4)        /* mmc0_dat0.uart1_ri */
            0xF8 (PIN_OUTPUT_PULLDOWN | MUX_MODE4)    /* mmc0_dat0.uart1_dtr */
            0xF4 (PIN_INPUT | MUX_MODE4)        /* mmc0_dat0.uart1_dsr */
            0xF0 (PIN_INPUT | MUX_MODE4)        /* mmc0_dat0.uart1_dcd */
        >;
    };

&uart1 {
    pinctrl-names = "default";
    pinctrl-0 = <&uart1_pins>;
    status = "okay";
    rts-gpio = <&gpio0 13 GPIO_ACTIVE_HIGH>;
    rs485-rts-active-high;
    rs485-rts-delay = <2 1>;
    linux,rs485-enabled-at-boot-time;    
};

When we set like this, in RS485 mode, Direction Control(gpio0 13 )  toggling will not take place as intended.

However, if uart1_rtsn.uart1_rtsn is configured in  ‘Mode7’(  0x17C (PIN_OUTPUT_PULLDOWN | MUX_MODE7)    /* uart1_rtsn.uart1_rtsn */), RS485 will work as intended. But, in this time RS232 RTS will not work.

Is there any way to switch RS232 and RS485 Modes from user space application without changing DTB?