mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2] serial: imx: set CTS if DT property "linux, rs485-enabled-at-boot-time" is present
@ 2020-08-20  7:30 Oleksij Rempel
  2020-08-24  7:03 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Oleksij Rempel @ 2020-08-20  7:30 UTC (permalink / raw)
  To: barebox, david; +Cc: Oleksij Rempel

If we have a "linux,rs485-enabled-at-boot-time" DT property, we should
set CTS flag as soon as possible to the active state. This will set an
RS485 transmitter to receive-enable mode. Otherwise the RS485 bus will
be blocked for entire system boot time and other bus participants will
not be able to communicate.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/serial/serial_imx.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/serial/serial_imx.c b/drivers/serial/serial_imx.c
index c0265fc2d7..056fa14c2a 100644
--- a/drivers/serial/serial_imx.c
+++ b/drivers/serial/serial_imx.c
@@ -60,6 +60,7 @@ struct imx_serial_priv {
 	void __iomem *regs;
 	struct clk *clk;
 	struct imx_serial_devtype_data *devtype;
+	bool rs485_mode;
 };
 
 static int imx_serial_reffreq(struct imx_serial_priv *priv)
@@ -107,6 +108,9 @@ static int imx_serial_init_port(struct console_device *cdev)
 
 	/* Enable FIFOs */
 	val = readl(regs + UCR2);
+	/* set CTS to not block RS485 bus */
+	if (priv->rs485_mode)
+		val |= UCR2_CTS;
 	val |= UCR2_SRST | UCR2_RXEN | UCR2_TXEN;
 	writel(val, regs + UCR2);
 
@@ -252,6 +256,10 @@ static int imx_serial_probe(struct device_d *dev)
 	if (of_property_read_bool(dev->device_node, "fsl,dte-mode"))
 		priv->dte_mode = 1;
 
+	if (of_property_read_bool(dev->device_node, "linux,rs485-enabled-at-boot-time") &&
+	    !of_property_read_bool(dev->device_node, "rs485-rts-active-low"))
+		priv->rs485_mode = 1;
+
 	imx_serial_init_port(cdev);
 
 	/* Enable UART */
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] serial: imx: set CTS if DT property "linux, rs485-enabled-at-boot-time" is present
  2020-08-20  7:30 [PATCH v2] serial: imx: set CTS if DT property "linux, rs485-enabled-at-boot-time" is present Oleksij Rempel
@ 2020-08-24  7:03 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2020-08-24  7:03 UTC (permalink / raw)
  To: Oleksij Rempel; +Cc: barebox, david

On Thu, Aug 20, 2020 at 09:30:39AM +0200, Oleksij Rempel wrote:
> If we have a "linux,rs485-enabled-at-boot-time" DT property, we should
> set CTS flag as soon as possible to the active state. This will set an
> RS485 transmitter to receive-enable mode. Otherwise the RS485 bus will
> be blocked for entire system boot time and other bus participants will
> not be able to communicate.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>  drivers/serial/serial_imx.c | 8 ++++++++
>  1 file changed, 8 insertions(+)

Applied, thanks

Sascha


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-24  7:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-20  7:30 [PATCH v2] serial: imx: set CTS if DT property "linux, rs485-enabled-at-boot-time" is present Oleksij Rempel
2020-08-24  7:03 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox