On Thu, Jan 13, 2022 at 10:19 PM Tomasz Moń <tomasz.mon@xxxxxxxxxxxxxxx> wrote: > > On 14.01.2022 04:08, Tim Harvey wrote: > > So I believe in order to support using gpios for rts/cts in the imx > > uart driver I must find the right place to call imx_uart_rts_active > > and imx_uart_rts_inactive when the FIFO is not full and full > > respectively. I'm not that familiar with the Linux uart driver > > framework - am I on the right track and if so any ideas where this is > > best done? > > It is not really the driver (and thus FIFO level), but rather the amount > of free space in tty buffer (checked by Line Discipline workqueue) that > determines when to throttle (set RTS inactive). This mostly works fine, > but fails [1] when the RX interrupt frequency is too high [2]. > > The throttle/unthrottle request, when termios CRTSCTS is set, is seen by > the driver as the call to .set_mctrl (imx_uart_set_mctrl) with TIOCM_RTS > bit cleared/set in mctrl parameter. Currently imx_uart_set_mctrl() only > controls the UCR2_CTS and UCR2_CTSC bits based on mctrl. > > To support your case you would most likely have to add the gpio handling > in imx_uart_set_mctrl(). However, I am unaware what other issues you > might encounter (i.e. if it is not done there yet simply because nobody > had that use case or if there is some deeper problem). > > [1] https://lore.kernel.org/linux-serial/10e723c0-a28b-de0d-0632-0bd250478313@xxxxxxxxxxxxxxx/ > [2] https://lore.kernel.org/linux-serial/20220104103203.2033673-1-tomasz.mon@xxxxxxxxxxxxxxx/ > > Best Regards, > Tomasz Mon > Tomasz, Thanks for the info. Currently imx_uart_set_mctrl calls mctrl_gpio_set which does toggle the rts-gpio per mctrl & TIOCM_RTS. Also, there's something in Documentation/devicetree/bindings/serial/serial.yaml that puzzles me: if: required: - uart-has-rtscts then: properties: cts-gpios: false rts-gpios: false That would seem to indicate to me that if you define 'uart-has-rtscts' you should not be defining 'cts-gpios' or 'rts-gpios' but I found that when I omitted 'uart-has-rtscts' I could no longer enable hardware flow control. Is my understanding of the yaml wrong or is this just not accurate? Best regards, Tim