From patchwork Fri Feb 3 10:23:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 93160 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp525093qgi; Fri, 3 Feb 2017 02:23:41 -0800 (PST) X-Received: by 10.99.170.5 with SMTP id e5mr17005683pgf.89.1486117421088; Fri, 03 Feb 2017 02:23:41 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r39si25101876pld.320.2017.02.03.02.23.40; Fri, 03 Feb 2017 02:23:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753201AbdBCKXd (ORCPT + 25 others); Fri, 3 Feb 2017 05:23:33 -0500 Received: from mail-wm0-f54.google.com ([74.125.82.54]:37036 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753139AbdBCKX2 (ORCPT ); Fri, 3 Feb 2017 05:23:28 -0500 Received: by mail-wm0-f54.google.com with SMTP id v77so20723095wmv.0 for ; Fri, 03 Feb 2017 02:23:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3rKJDjiazAifNCA0s9XVwo+lbmW48W1bF6rYEABjCpg=; b=EmsiL03VRAw6n1IzlNZJrADchcrFKk6rIC9BWt8VbyWDKphdMsI/1NBcA0poLjIrAM Psn/kS879rOFjwvtcw4AzljJVSP8P4N9i2XrsyPGlLeLg8B3srZkmMSLxCVhfL0xMSFW G837xOKu/YYM4tBPkUqE11Ij9homU07Hw5zWI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3rKJDjiazAifNCA0s9XVwo+lbmW48W1bF6rYEABjCpg=; b=fl6U6vENCfvz257NNFMmwuCxYWSsMTe1hC73w0br3SXR9RPDnIh72QwGBWUr+0qOYd q6kihl3HjiIPMLJ68XXzDET9ukIHruMtyb41shJMWNfzvkj6J0azLDkXwWIVodfmj/hF uOiZ4e5JgWq24cbE6eIOTJvyv+Q9ip6JUEsGrlo+K3cpfewac891maSPRV7FRt/TUscj eTA2eytromLWb6lDv087Ii4t6QVkDPztiW1Iyh98v94h/QvpIswkEPBEE9r/aAEIRfqd 74QWS7FuAW3t+wxbxZPSlESIELKMNbp7MkubeM+2X1ZTYXmiPenu7jLEWrXh9MWx1pID BolA== X-Gm-Message-State: AMke39mKHLhgw4E1vCRfN65sAizXG7ZPdInPMhQd9wcfRcKyghErR8nvOCC8CEF6Ypqva3t6 X-Received: by 10.28.144.66 with SMTP id s63mr731494wmd.134.1486117406905; Fri, 03 Feb 2017 02:23:26 -0800 (PST) Received: from dell.Home ([2a02:c7d:1faf:e900:a188:db10:388f:f973]) by smtp.gmail.com with ESMTPSA id z90sm44668100wrc.24.2017.02.03.02.23.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Feb 2017 02:23:26 -0800 (PST) From: Lee Jones To: gregkh@linuxfoundation.org, jslaby@suse.com, linux-serial@vger.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 Subject: [PATCH v4 03/10] serial: st-asc: Read in all Pinctrl states Date: Fri, 3 Feb 2017 10:23:12 +0000 Message-Id: <20170203102319.23489-4-lee.jones@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170203102319.23489-1-lee.jones@linaro.org> References: <20170203102319.23489-1-lee.jones@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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`). Acked-by: Peter Griffin Signed-off-by: Lee Jones --- drivers/tty/serial/st-asc.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) -- 2.9.3 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 #include #include +#include #include #include #include @@ -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; }