tty:serial:imx: fix uart latency for rs485 on mx6ull
This is an another version of fix for https://secogroup.atlassian.net/browse/YT-136 Nallino: RS485 turn around time problem
Original MR: !312 (closed)
Our current understanding is as follows:
- from time to time, UART transmission fails to complete in time (delay is up to 3ms). And when other side starts to reply to our transmission during this delay, this message is not received because signals are still pulled up/down;
- rx interrupt is not generated after all bytes from internal buffers are transmitted as switching into receive mode takes a lot of time because of latency on mx6ull and because of driver logic, which makes driver vulnerable to the latency;
- it happens because of 3 sequential iterations of calling stop_tx (2 from irq thread and 1 from hrtimer). And on the slow mx6ull in guf kernel, the irq thread has a greater latency and RS485 and is sensitive to timings for some unknown reason. So, device fails to handle input data over RS485, as it still trying to accomplish outgoing transmission.
The patch involves an additional hrtimer to call stop_tx when hardware is waiting or FIFO to be empty. This significantly speed up the process of switching to RX mode.
To make new code apply only for specific devices and not to affect other boards, a "rs485-has-rts-latency" property for UART device tree node was added.
Note: this MR is for guf kernel only, as kuk is not affected by the issue.
Edited by Mikhail Vanyulin