110-serial-imx-repair-and-complete-handshaking.patch 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. From 90ebc4838666d148eac5bbac6f4044e5b25cd2d6 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>
  3. Date: Sun, 18 Oct 2015 21:34:46 +0200
  4. Subject: [PATCH] serial: imx: repair and complete handshaking
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. The .get_mctrl callback should not report the status of RTS or LOOP, so
  9. drop this. Instead implement reporting the state of CAR (aka DCD) and
  10. RI.
  11. For .set_mctrl implement setting the DTR line.
  12. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
  13. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  14. Signed-off-by: Petr Štetiar <ynezz@true.cz>
  15. ---
  16. drivers/tty/serial/imx.c | 23 +++++++++++++++++------
  17. 1 file changed, 17 insertions(+), 6 deletions(-)
  18. --- a/drivers/tty/serial/imx.c
  19. +++ b/drivers/tty/serial/imx.c
  20. @@ -148,8 +148,11 @@
  21. #define USR2_TXFE (1<<14) /* Transmit buffer FIFO empty */
  22. #define USR2_DTRF (1<<13) /* DTR edge interrupt flag */
  23. #define USR2_IDLE (1<<12) /* Idle condition */
  24. +#define USR2_RIDELT (1<<10) /* Ring Interrupt Delta */
  25. +#define USR2_RIIN (1<<9) /* Ring Indicator Input */
  26. #define USR2_IRINT (1<<8) /* Serial infrared interrupt flag */
  27. #define USR2_WAKE (1<<7) /* Wake */
  28. +#define USR2_DCDIN (1<<5) /* Data Carrier Detect Input */
  29. #define USR2_RTSF (1<<4) /* RTS edge interrupt flag */
  30. #define USR2_TXDC (1<<3) /* Transmitter complete */
  31. #define USR2_BRCD (1<<2) /* Break condition */
  32. @@ -804,16 +807,19 @@ static unsigned int imx_tx_empty(struct
  33. static unsigned int imx_get_mctrl(struct uart_port *port)
  34. {
  35. struct imx_port *sport = (struct imx_port *)port;
  36. - unsigned int tmp = TIOCM_DSR | TIOCM_CAR;
  37. + unsigned int tmp = TIOCM_DSR;
  38. + unsigned usr1 = readl(sport->port.membase + USR1);
  39. - if (readl(sport->port.membase + USR1) & USR1_RTSS)
  40. + if (usr1 & USR1_RTSS)
  41. tmp |= TIOCM_CTS;
  42. - if (readl(sport->port.membase + UCR2) & UCR2_CTS)
  43. - tmp |= TIOCM_RTS;
  44. -
  45. - if (readl(sport->port.membase + uts_reg(sport)) & UTS_LOOP)
  46. - tmp |= TIOCM_LOOP;
  47. + /* in DCE mode DCDIN is always 0 */
  48. + if (!(usr1 & USR2_DCDIN))
  49. + tmp |= TIOCM_CAR;
  50. +
  51. + /* in DCE mode RIIN is always 0 */
  52. + if (readl(sport->port.membase + USR2) & USR2_RIIN)
  53. + tmp |= TIOCM_RI;
  54. return tmp;
  55. }
  56. @@ -831,6 +837,11 @@ static void imx_set_mctrl(struct uart_po
  57. writel(temp, sport->port.membase + UCR2);
  58. }
  59. + temp = readl(sport->port.membase + UCR3) & ~UCR3_DSR;
  60. + if (!(mctrl & TIOCM_DTR))
  61. + temp |= UCR3_DSR;
  62. + writel(temp, sport->port.membase + UCR3);
  63. +
  64. temp = readl(sport->port.membase + uts_reg(sport)) & ~UTS_LOOP;
  65. if (mctrl & TIOCM_LOOP)
  66. temp |= UTS_LOOP;