From patchwork Wed Feb 1 14:31:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 93038 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2443632qgi; Wed, 1 Feb 2017 06:32:23 -0800 (PST) X-Received: by 10.99.51.76 with SMTP id z73mr4031414pgz.137.1485959543454; Wed, 01 Feb 2017 06:32:23 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m32si19326794pld.31.2017.02.01.06.32.23; Wed, 01 Feb 2017 06:32:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751873AbdBAOcR (ORCPT + 2 others); Wed, 1 Feb 2017 09:32:17 -0500 Received: from mail-wj0-f178.google.com ([209.85.210.178]:36835 "EHLO mail-wj0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751847AbdBAOcN (ORCPT ); Wed, 1 Feb 2017 09:32:13 -0500 Received: by mail-wj0-f178.google.com with SMTP id n2so20730215wjq.3 for ; Wed, 01 Feb 2017 06:32:02 -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=Nz6EcBz3574CcrlMAxjV2FdHcsra/7R+6yMcnHO9ZTA=; b=QZqEtxbJaAwjhluOCHRbfBz0Vzpu3RRdbwtfDDHXKNMHVPVW+83XObO56Eoc1krOAW /KkEqYpj9i1oVhFBogx3qY52vskgORWpduzjWuU//4salyxLkpnCk7SO//fdihxBkpSV QSEuL/iDO1ooX7UKYlsLD4AFH7WmP6Euc/cz4= 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=Nz6EcBz3574CcrlMAxjV2FdHcsra/7R+6yMcnHO9ZTA=; b=WBAY4tb/l+TnAMwZClpqIOj3UrwwYM62mvgJTxhxq72wrQJ7DzdyTmqVr8LvpFrdl2 kKtCRycRKbUJ9s3BeqcMQ95uLkpd0JkKZl64ubJxJKJ4IIjCrCQdK8vAURLr48NoDBkm yyWCmn9GedGlZk6CVq+TWJhvCVIUISavqS/8C3yTjMW5q+KvnF9WAGLZ3t9HIrfZlPh1 MTmkGkXcPi0FrXXcgkxMC5aMsin7sUFL+pnWDcl2kqRq5KYCT53M0oqgIsxSTZZdlIES laP3KBHY7gupyeL7TMYOmaHhYTxc3siIdJEwnvpSyQ6ZWqtdQ6YKWMh+QLs5j1bAv4fH Oi2A== X-Gm-Message-State: AIkVDXKiz0Kb04ALVwle9siqAwBdFvJNFv4y9ZeDB1hWiZDpIj8SrQ+1E8N8n6LVVPJs9XoD X-Received: by 10.223.150.34 with SMTP id b31mr2969464wra.196.1485959516900; Wed, 01 Feb 2017 06:31:56 -0800 (PST) Received: from localhost.localdomain (host81-158-165-111.range81-158.btcentralplus.com. [81.158.165.111]) by smtp.gmail.com with ESMTPSA id l37sm34420245wrc.41.2017.02.01.06.31.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Feb 2017 06:31:56 -0800 (PST) From: Lee Jones 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 Subject: [PATCH v2 04/10] serial: st-asc: (De)Register GPIOD and swap Pinctrl profiles Date: Wed, 1 Feb 2017 14:31:39 +0000 Message-Id: <20170201143145.31962-5-lee.jones@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170201143145.31962-1-lee.jones@linaro.org> References: <20170201143145.31962-1-lee.jones@linaro.org> Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org When hardware flow-control is disabled, manual toggling of the UART's reset line (RTS) using userland applications (e.g. stty) is not possible, since the ASC IP does not provide this functionality in the same was as some other IPs do. Thus, we have to do this manually. This patch ensures that when HW flow-control is disabled the RTS/CTS lines are free to be registered via the GPIO API. It also ensures any registered GPIO lines are unregistered when HW flow-control is requested, allowing the IP to control them automatically. Acked-by: Peter Griffin Signed-off-by: Lee Jones --- drivers/tty/serial/st-asc.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c index 1058020..e521078 100644 --- a/drivers/tty/serial/st-asc.c +++ b/drivers/tty/serial/st-asc.c @@ -513,6 +513,8 @@ static void asc_set_termios(struct uart_port *port, struct ktermios *termios, struct ktermios *old) { struct asc_port *ascport = to_asc_port(port); + struct device_node *np = port->dev->of_node; + struct gpio_desc *gpiod; unsigned int baud; u32 ctrl_val; tcflag_t cflag; @@ -556,9 +558,32 @@ static void asc_set_termios(struct uart_port *port, struct ktermios *termios, ctrl_val |= ASC_CTL_PARITYODD; /* hardware flow control */ - if ((cflag & CRTSCTS)) + if ((cflag & CRTSCTS)) { ctrl_val |= ASC_CTL_CTSENABLE; + /* If flow-control selected, stop handling RTS manually */ + if (ascport->rts) { + devm_gpiod_put(port->dev, ascport->rts); + ascport->rts = NULL; + + pinctrl_select_state(ascport->pinctrl, + ascport->states[DEFAULT]); + } + } else { + /* If flow-control disabled, it's safe to handle RTS manually */ + if (!ascport->rts && ascport->states[NO_HW_FLOWCTRL]) { + pinctrl_select_state(ascport->pinctrl, + ascport->states[NO_HW_FLOWCTRL]); + + gpiod = devm_get_gpiod_from_child(port->dev, "rts", + &np->fwnode); + if (!IS_ERR(gpiod)) { + gpiod_direction_output(gpiod, 0); + ascport->rts = gpiod; + } + } + } + if ((baud < 19200) && !ascport->force_m1) { asc_out(port, ASC_BAUDRATE, (port->uartclk / (16 * baud))); } else {