[PATCH] omap_serial: Fix rs485 initial RTS settings.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On rs485 probe the RTS GPIO is now set ASAP (when reading the device
tree), this is to fix hardware configurations that have this GPIO set
to high when booting, as having the RTS high hogs a rs485 bus. The
RTS GPIO was set as an input depending on the configuration of
SER_RS485_RTS_AFTER_SEND/SER_RS485_RTS_ON_SEND too.

On rs485 config (ioctl) the initial RTS value was wrong too.

Change-Id: Iaa9b43f26b8ac6b418c6c2206b5129bd1a81062c
---
 drivers/tty/serial/omap-serial.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 44e5b5b..b49e1e4 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -1367,11 +1367,9 @@ serial_omap_config_rs485(struct uart_port *port, struct serial_rs485 *rs485)
 	 * Just as a precaution, only allow rs485
 	 * to be enabled if the gpio pin is valid
 	 */
-	if (gpio_is_valid(up->rts_gpio)) {
-		/* enable / disable rts */
-		val = (port->rs485.flags & SER_RS485_ENABLED) ?
-			SER_RS485_RTS_AFTER_SEND : SER_RS485_RTS_ON_SEND;
-		val = (port->rs485.flags & val) ? 1 : 0;
+	if ((rs485->flags & SER_RS485_ENABLED) && gpio_is_valid(up->rts_gpio)) {
+		/* enable/disable RTS considering that we are not sending */
+		val = (rs485->flags & SER_RS485_RTS_AFTER_SEND) ? 1 : 0;
 		gpio_set_value(up->rts_gpio, val);
 	} else
 		port->rs485.flags &= ~SER_RS485_ENABLED;
@@ -1570,10 +1568,11 @@ static int serial_omap_probe_rs485(struct uart_omap_port *up,
 		ret = devm_gpio_request(up->dev, up->rts_gpio, "omap-serial");
 		if (ret < 0)
 			return ret;
-		ret = gpio_direction_output(up->rts_gpio,
-					    flags & SER_RS485_RTS_AFTER_SEND);
+		ret = gpio_direction_output(up->rts_gpio, 1);
 		if (ret < 0)
 			return ret;
+		ret = rs485conf->flags & SER_RS485_RTS_AFTER_SEND ? 1 : 0;
+		gpio_set_value(up->rts_gpio, ret);
 	} else if (up->rts_gpio == -EPROBE_DEFER) {
 		return -EPROBE_DEFER;
 	} else {
@@ -1623,6 +1622,7 @@ static int serial_omap_probe(struct platform_device *pdev)
 	if (!up)
 		return -ENOMEM;
 
+
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	base = devm_ioremap_resource(&pdev->dev, mem);
 	if (IS_ERR(base))
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux