Hi Zhiming @Zhiming_Liu
Yes please, I'd like to report this bug in lpuart32_setup_watermark plus a similar issue in lpuart32_shutdown.
What do we need to do to report these please?
Also need some advice re the lpuart32_shutdown side of this please.
Our transceiver, ST485B, needs RTS to be high when the the lpuart is sending, but low at all other times.
Using linux,rs485-enabled-at-boot-time in the device tree sets RTS low from boot.
The modem register fields, TXRTSE and TXRTSPOL are 1, which is what we need.
However, when anything calls open() on /dev/ttyLP1, the bug in lpuart32_setup_watermark clears those bits, which makes RTS permanently high instead of low...
And even if we workaround that bug on open(), on the close(), lpuart32_shutdown zeros the modem register again, making RTS permanently high again...
I've fixed my copy of lpuart32_setup_watermark, by adding the missing bit masking.
I guess that the author of lpuart32_setup_watermark forgot to add the masking, as the read is there, but the val that was read is overwritten?
Be good if this could be fixed in the official repo(s).
However for lpuart32_shutdown, the issue seems more intentional, and I'm less sure on the correct solution.
The issue in lpuart32_shutdown is:
https://github.com/nxp-imx/linux-imx/blob/lf-5.15.y/drivers/tty/serial/fsl_lpuart.c#L2026
lpuart32_write(port, 0, UARTMODIR)
We do not want this to zero TXRTSE and TXRTSPOL, so we could workaround this, quick and dirty by saving just those two bits.
But for a proper fix, which of all of the modem register fields should be zero'd and which should be preserved on close/shutdown?
Thank you
-- Peter