[PATCH] serial: imx: support an enable-gpio

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

 



A part of my machine looks as follows:

,------------------------.
| ,---------.            |
| |  imx25  o--RX----◁---o---
| |         o--GPIO--'   |
| `---------'            |
`------------------------'

that is, there is a driver on the RX line that must be enabled before
the UART can be used. (That is necessary because the default mux of the
RX pad after reset is an output.)

To represent this in the device tree I do:

	pinctrl_uart5: uart5 {
		fsl,pins = <
			...
			MX25_PAD_LBA__UART5_RXD		0x00000000
			MX25_PAD_CS5__GPIO_3_21		0x00002001
			...
	};

	&uart5 {
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_uart5>;

		enable-gpio = <&gpio3 21 GPIO_ACTIVE_LOW>;
		...
	};

This way it's ensured that the gpio is only enabled when the LBA pad is
muxed as RX (together with the bootloader that sets the GPIO high).

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
Forwarded: id:1468400495-10471-1-git-send-email-u.kleine-koenig@xxxxxxxxxxxxxx
---
 drivers/tty/serial/imx.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 246a1fd409d4..40d7f42c0a9e 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -31,6 +31,8 @@
 #include <linux/of_device.h>
 #include <linux/io.h>
 #include <linux/dma-mapping.h>
+#include <linux/leds.h>
+#include <linux/gpio/consumer.h>
 
 #include <asm/irq.h>
 #include <linux/platform_data/serial-imx.h>
@@ -2223,7 +2225,9 @@ static int imx_uart_probe_dt(struct imx_port *sport,
 	if (of_get_property(np, "rts-gpios", NULL))
 		sport->have_rtsgpio = 1;
 
-	return 0;
+	ret = PTR_ERR_OR_ZERO(devm_gpiod_get_optional(&pdev->dev, "enable",
+						      GPIOD_OUT_HIGH));
+	return ret;
 }
 #else
 static inline int imx_uart_probe_dt(struct imx_port *sport,
-- 
2.20.1




[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