From patchwork Tue Jan 24 13:43:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 92348 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1717612qgi; Tue, 24 Jan 2017 05:41:31 -0800 (PST) X-Received: by 10.98.112.134 with SMTP id l128mr38537409pfc.81.1485265291709; Tue, 24 Jan 2017 05:41:31 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z12si19215130pgz.5.2017.01.24.05.41.31; Tue, 24 Jan 2017 05:41:31 -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 S1751127AbdAXNlZ (ORCPT + 25 others); Tue, 24 Jan 2017 08:41:25 -0500 Received: from mail-wm0-f50.google.com ([74.125.82.50]:34035 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751075AbdAXNlV (ORCPT ); Tue, 24 Jan 2017 08:41:21 -0500 Received: by mail-wm0-f50.google.com with SMTP id f73so42847538wmf.1 for ; Tue, 24 Jan 2017 05:41:20 -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=CECPrWl8MVL1q3FgkGQAnhGVlG1YH6f+CxvFQCMWgqg=; b=DJ9Oloh9CNbr6VEfZblxTo+qmZhDSX7LfK/7BEebnMPAm+nMbXAhHsd9d3F8hShBkO y4X0i/l5fyKMJNy0kVMdiuo7LtXULM0wm6+abkqS2BGGm/4mLf0hlEA6GWelqGtAQTWy on2P0yNhKdl92fHRjt3PF/DgMH+xqJ71ENO+E= 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=CECPrWl8MVL1q3FgkGQAnhGVlG1YH6f+CxvFQCMWgqg=; b=LvK5eH0RvHeo8yvRjBEntaM2EUO2K+bCk3UHn50aaSogBy9yuSPcnAbuZZc7WjEJkY dcAi5SAoDZ3d0/g1ZgWQdaiVhgdWfVvlf6yYVbMksyuDZhcBT91q0UJtM5rXArB4hShz mjWWEH9Ju31Guaun8vRoZymZ6fcEaO+Eh6GQDbgnThjVpHc45/0x/1+l9rQq4rbQzi7m wbymhww2pq5EjZUxk54/9czLqEZhvFwUyUY+49Rg+ppYWPIOnussYcaNazXNUZFOMqBK A4zfzk7vysNYbVgDWE572ju0IQeNnSN31eKhe2pBt76GnIvKGce8QHkCZboX0e8Iq5Qz LzFg== X-Gm-Message-State: AIkVDXK3pR/MYsC3BzrLBG4JWQ4Xvm1OVe3QWSaWJePsOkt5G0MCLth6e0e0FAkpN8n+rznz X-Received: by 10.223.154.109 with SMTP id z100mr28246986wrb.145.1485265279699; Tue, 24 Jan 2017 05:41:19 -0800 (PST) Received: from localhost.localdomain (host81-129-172-30.range81-129.btcentralplus.com. [81.129.172.30]) by smtp.gmail.com with ESMTPSA id d42sm19966165wrd.7.2017.01.24.05.41.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 05:41:19 -0800 (PST) From: Lee Jones To: gregkh@linuxfoundation.org, jslaby@suse.com, linux-serial@vger.kernel.org, robh+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 4/8] serial: st-asc: (De)Register GPIOD and swap Pinctrl profiles Date: Tue, 24 Jan 2017 13:43:06 +0000 Message-Id: <20170124134310.27512-5-lee.jones@linaro.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170124134310.27512-1-lee.jones@linaro.org> References: <20170124134310.27512-1-lee.jones@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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. Signed-off-by: Lee Jones --- drivers/tty/serial/st-asc.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) -- 2.10.2 diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c index 03801ed..2c4b5f5 100644 --- a/drivers/tty/serial/st-asc.c +++ b/drivers/tty/serial/st-asc.c @@ -512,6 +512,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; @@ -555,9 +557,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[MANUAL_RTS]) { + pinctrl_select_state(ascport->pinctrl, + ascport->states[MANUAL_RTS]); + + 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 {