devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: gregkh@linuxfoundation.org, jslaby@suse.com,
	linux-serial@vger.kernel.org, dt@kernel.org,
	devicetree@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, kernel@stlinux.com,
	patrice.chotard@st.com, Lee Jones <lee.jones@linaro.org>
Subject: [PATCH v2 03/10] serial: st-asc: Read in all Pinctrl states
Date: Wed,  1 Feb 2017 14:31:38 +0000	[thread overview]
Message-ID: <20170201143145.31962-4-lee.jones@linaro.org> (raw)
In-Reply-To: <20170201143145.31962-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..1058020 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 NO_HW_FLOWCTRL	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;
+	}
+
+	/* "no-hw-flowctrl" state is optional */
+	ascport->states[NO_HW_FLOWCTRL] =
+		pinctrl_lookup_state(ascport->pinctrl, "no-hw-flowctrl");
+	if (IS_ERR(ascport->states[NO_HW_FLOWCTRL]))
+		ascport->states[NO_HW_FLOWCTRL] = NULL;
+
 	return 0;
 }
 
-- 
2.9.3

  parent reply	other threads:[~2017-02-01 14:31 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-01 14:31 [PATCH v2 00/10] serial: st-asc: Allow handling of RTS line Lee Jones
2017-02-01 14:31 ` [PATCH v2 01/10] serial: st-asc: Ignore the parity error bit if 8-bit mode is enabled Lee Jones
     [not found] ` <20170201143145.31962-1-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-02-01 14:31   ` [PATCH v2 02/10] serial: st-asc: Provide RTS functionality Lee Jones
2017-02-01 14:31   ` [PATCH v2 04/10] serial: st-asc: (De)Register GPIOD and swap Pinctrl profiles Lee Jones
2017-02-01 14:31   ` [PATCH v2 05/10] serial: st-asc: Use generic DT binding for announcing RTS/CTS lines Lee Jones
2017-02-01 14:56     ` [STLinux Kernel] " Peter Griffin
2017-02-01 14:31   ` [PATCH v2 08/10] ARM: dts: STiH407-pinctrl: Add Pinctrl group for HW flow-control Lee Jones
2017-02-03  9:10   ` [PATCH v2 00/10] serial: st-asc: Allow handling of RTS line Greg KH
     [not found]     ` <20170203091043.GA10386-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2017-02-03 10:17       ` Lee Jones
2017-02-01 14:31 ` Lee Jones [this message]
2017-02-01 14:55   ` [STLinux Kernel] [PATCH v2 03/10] serial: st-asc: Read in all Pinctrl states Peter Griffin
2017-02-01 14:31 ` [PATCH v2 06/10] dt-bindings: serial: Update 'uart-has-rtscts' description Lee Jones
     [not found]   ` <20170201143145.31962-7-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-02-01 14:57     ` [STLinux Kernel] " Peter Griffin
2017-02-01 14:31 ` [PATCH v2 07/10] ARM: dts: STiH410-b2260: Identify the UART RTS line Lee Jones
     [not found]   ` <20170201143145.31962-8-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-02-01 14:55     ` [STLinux Kernel] " Peter Griffin
2017-02-01 14:31 ` [PATCH v2 09/10] ARM: dts: STiH407-family: Use new Pinctrl groups Lee Jones
     [not found]   ` <20170201143145.31962-10-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-02-01 15:02     ` [STLinux Kernel] " Peter Griffin
2017-02-01 14:31 ` [PATCH v2 10/10] ARM: dts: STiH410-b2260: Enable HW flow-control Lee Jones
2017-02-01 14:53   ` [STLinux Kernel] " Peter Griffin
  -- strict thread matches above, loose matches on Subject: below --
2017-01-27 17:27 [PATCH v2 00/10] serial: st-asc: Allow handling of RTS line Lee Jones
     [not found] ` <20170127172804.23881-1-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-01-27 17:27   ` [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=20170201143145.31962-4-lee.jones@linaro.org \
    --to=lee.jones@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dt@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=kernel@stlinux.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=patrice.chotard@st.com \
    /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).