linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: lee.jones@linaro.org (Lee Jones)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 03/10] serial: st-asc: Read in all Pinctrl states
Date: Fri, 27 Jan 2017 17:27:57 +0000	[thread overview]
Message-ID: <20170127172804.23881-4-lee.jones@linaro.org> (raw)
In-Reply-To: <20170127172804.23881-1-lee.jones@linaro.org>

There are now 2 possible separate/different Pinctrl states which can
be provided from platform data.  One which encompasses the lines
required for HW flow-control (CTS/RTS) and another which does not
specify these lines, such that they can be used via GPIO mechanisms
for manually toggling (i.e. from a request by `stty`).

Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/tty/serial/st-asc.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c
index 397df50..82f5714 100644
--- a/drivers/tty/serial/st-asc.c
+++ b/drivers/tty/serial/st-asc.c
@@ -18,6 +18,7 @@
 #include <linux/serial.h>
 #include <linux/console.h>
 #include <linux/sysrq.h>
+#include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <linux/irq.h>
@@ -37,10 +38,16 @@
 #define ASC_FIFO_SIZE 16
 #define ASC_MAX_PORTS 8
 
+/* Pinctrl states */
+#define DEFAULT		0
+#define MANUAL_RTS	1
+
 struct asc_port {
 	struct uart_port port;
 	struct gpio_desc *rts;
 	struct clk *clk;
+	struct pinctrl *pinctrl;
+	struct pinctrl_state *states[2];
 	unsigned int hw_flow_control:1;
 	unsigned int force_m1:1;
 };
@@ -694,6 +701,7 @@ static int asc_init_port(struct asc_port *ascport,
 {
 	struct uart_port *port = &ascport->port;
 	struct resource *res;
+	int ret;
 
 	port->iotype	= UPIO_MEM;
 	port->flags	= UPF_BOOT_AUTOCONF;
@@ -720,6 +728,27 @@ static int asc_init_port(struct asc_port *ascport,
 	WARN_ON(ascport->port.uartclk == 0);
 	clk_disable_unprepare(ascport->clk);
 
+	ascport->pinctrl = devm_pinctrl_get(&pdev->dev);
+	if (IS_ERR(ascport->pinctrl)) {
+		ret = PTR_ERR(ascport->pinctrl);
+		dev_err(&pdev->dev, "Failed to get Pinctrl: %d\n", ret);
+	}
+
+	ascport->states[DEFAULT] =
+		pinctrl_lookup_state(ascport->pinctrl, "default");
+	if (IS_ERR(ascport->states[DEFAULT])) {
+		ret = PTR_ERR(ascport->states[DEFAULT]);
+		dev_err(&pdev->dev,
+			"Failed to look up Pinctrl state 'default': %d\n", ret);
+		return ret;
+	}
+
+	/* "manual-rts" state is optional */
+	ascport->states[MANUAL_RTS] =
+		pinctrl_lookup_state(ascport->pinctrl, "manual-rts");
+	if (IS_ERR(ascport->states[MANUAL_RTS]))
+		ascport->states[MANUAL_RTS] = NULL;
+
 	return 0;
 }
 
-- 
2.9.3

  parent reply	other threads:[~2017-01-27 17:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-27 17:27 [PATCH v2 00/10] serial: st-asc: Allow handling of RTS line Lee Jones
2017-01-27 17:27 ` [PATCH v2 01/10] serial: st-asc: Ignore the parity error bit if 8-bit mode is enabled Lee Jones
2017-01-27 17:27 ` [PATCH v2 02/10] serial: st-asc: Provide RTS functionality Lee Jones
2017-01-27 17:27 ` Lee Jones [this message]
2017-01-27 17:27 ` [PATCH v2 04/10] serial: st-asc: (De)Register GPIOD and swap Pinctrl profiles Lee Jones
2017-01-27 17:27 ` [PATCH v2 05/10] serial: st-asc: Use generic DT binding for announcing RTS/CTS lines Lee Jones
2017-01-27 17:28 ` [PATCH v2 06/10] dt-bindings: serial: Update 'uart-has-rtscts' description Lee Jones
2017-02-01 15:41   ` Rob Herring
2017-01-27 17:28 ` [PATCH v2 07/10] ARM: dts: STiH410-b2260: Identify the UART RTS line Lee Jones
2017-01-27 17:28 ` [PATCH v2 08/10] ARM: dts: STiH407-pinctrl: Add Pinctrl group for HW flow-control Lee Jones
2017-01-27 17:28 ` [PATCH v2 09/10] ARM: dts: STiH407-family: Use new Pinctrl groups Lee Jones
2017-01-30 10:10   ` Patrice CHOTARD
2017-01-27 17:28 ` [PATCH v2 10/10] ARM: dts: STiH410-b2260: Enable HW flow-control Lee Jones
2017-02-02  7:42 ` [PATCH v2 00/10] serial: st-asc: Allow handling of RTS line Lee Jones
2017-02-02  9:55   ` Greg KH
2017-02-03  9:22     ` Lee Jones
  -- strict thread matches above, loose matches on Subject: below --
2017-02-01 14:31 Lee Jones
2017-02-01 14:31 ` [PATCH v2 03/10] serial: st-asc: Read in all Pinctrl states Lee Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170127172804.23881-4-lee.jones@linaro.org \
    --to=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).