From patchwork Mon Aug 7 21:45:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 132456 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1765193vqr; Mon, 7 Aug 2023 16:15:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5rQMsF7Je729Tzu1+c933FGYWqduiWFxJaZsQGVkRoE7GSaYLC4UYs4PDhLloZiCaqXd5 X-Received: by 2002:a17:906:3286:b0:99b:c1af:17ea with SMTP id 6-20020a170906328600b0099bc1af17eamr10087573ejw.15.1691450141182; Mon, 07 Aug 2023 16:15:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691450141; cv=none; d=google.com; s=arc-20160816; b=Y4qIftkXN095nizqRKfmHBrWRTFEJ9dqbheKtfoJVgNYgPO4v0JQAMlbkoVrC8AhSZ r2pVEI5M94S/+kp9Ak2x50tu+LHab60nW6IEP++mcvamKnIe24nJwRlK/V/Ns1J2mHCq eiL344na5C5ZrL7esm5Hx1smk8DHBlifIU9IuG54LKW3Dgv6ZPY1pQZEyF5CrxymOWvn eQKCymnxgOZJsq9aqaQZr1uLC0cHw5NTdXiwzFKN/ltWJxxNVSH4TMwkYzO3SqR9fnyf AEHvTNVN9up/7HhEfMLi6v609lSrv/BaOyL9CTpCjLY3EtE1C9jphYhfVFdpSDg5TqBi RSwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from:dkim-signature; bh=GoDQfDkJ+cbhbljlT8yvH1LI+rTJZfA1Q3+3WKSspk0=; fh=rA5ZL3pE2Nx+AQMYlYgPGmEcJAxlI2Jmd7haO+z+CXk=; b=naxFv8nwpMWHRvjsU+yCyTTq4fMtXrHsfcaPc+k6gGelPO/w3FWUYlUy8IX8sUsK7z bNg3RBwKr6mENL7iNMA54zDqHwQvrsodM0uMFRy+/i7CYlMPF6y3Lc8oOo0EYZi1rjJR 9M49mFiibz5WTIzHJlxjfNd+C0y5fCxNvq0zX1vfJ047lu1hDrAesZNK02kGiLIUZXFN msrGQVClueYAYeB3HPUej51hLgkTvSOvrtPyuxbYGb0AtiaLtJYDIG8mIAuhdJ1lsOcU CKtYNhAFbxBtdFOrgQhHSxukQ2483lUMYXygdg/+Clp0VCkeKe4BLiRNxidG8BpA8aE1 Vo1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=KC9CGPIk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id la15-20020a170906ad8f00b009889cad765dsi4999024ejb.352.2023.08.07.16.15.15; Mon, 07 Aug 2023 16:15:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=KC9CGPIk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230142AbjHGVqX (ORCPT + 99 others); Mon, 7 Aug 2023 17:46:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbjHGVqQ (ORCPT ); Mon, 7 Aug 2023 17:46:16 -0400 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FE2B10DE; Mon, 7 Aug 2023 14:46:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Cc:To :From:subject:date:message-id:reply-to; bh=GoDQfDkJ+cbhbljlT8yvH1LI+rTJZfA1Q3+3WKSspk0=; b=KC9CGPIkwT2wAQfn1E+rHnTdmI VEydOVp2Cy6KSoy1nKw23Ql29LiaGW96iw/BRjK7BFvLuiSt32aHFC0fsLcAU08jb63m05DPVCOaO aAgtaV6SB635nqMRDYyQPp/oamN03u0VUNfEjMmLuSL6zIPmQrfBTeM1ha89ay8ejhsU=; Received: from modemcable061.19-161-184.mc.videotron.ca ([184.161.19.61]:47088 helo=localhost.localdomain) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1qT83E-0000hD-Av; Mon, 07 Aug 2023 17:46:09 -0400 From: Hugo Villeneuve To: gregkh@linuxfoundation.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, jirislaby@kernel.org, jringle@gridpoint.com, tomasz.mon@camlingroup.com, l.perczak@camlintechnologies.com Cc: linux-serial@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, hugo@hugovil.com, linux-gpio@vger.kernel.org, Hugo Villeneuve , stable@vger.kernel.org, =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Lech Perczak Date: Mon, 7 Aug 2023 17:45:51 -0400 Message-Id: <20230807214556.540627-2-hugo@hugovil.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230807214556.540627-1-hugo@hugovil.com> References: <20230807214556.540627-1-hugo@hugovil.com> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 184.161.19.61 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v10 1/6] serial: sc16is7xx: fix broken port 0 uart init X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773614023044726736 X-GMAIL-MSGID: 1773614023044726736 From: Hugo Villeneuve The sc16is7xx_config_rs485() function is called only for the second port (index 1, channel B), causing initialization problems for the first port. For the sc16is7xx driver, port->membase and port->mapbase are not set, and their default values are 0. And we set port->iobase to the device index. This means that when the first device is registered using the uart_add_one_port() function, the following values will be in the port structure: port->membase = 0 port->mapbase = 0 port->iobase = 0 Therefore, the function uart_configure_port() in serial_core.c will exit early because of the following check: /* * If there isn't a port here, don't do anything further. */ if (!port->iobase && !port->mapbase && !port->membase) return; Typically, I2C and SPI drivers do not set port->membase and port->mapbase. The max310x driver sets port->membase to ~0 (all ones). By implementing the same change in this driver, uart_configure_port() is now correctly executed for all ports. Fixes: dfeae619d781 ("serial: sc16is7xx") Cc: Signed-off-by: Hugo Villeneuve Reviewed-by: Ilpo Järvinen Reviewed-by: Lech Perczak Tested-by: Lech Perczak --- drivers/tty/serial/sc16is7xx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 18a48ce052c2..ffe817309413 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1438,6 +1438,12 @@ static int sc16is7xx_probe(struct device *dev, s->p[i].port.fifosize = SC16IS7XX_FIFO_SIZE; s->p[i].port.flags = UPF_FIXED_TYPE | UPF_LOW_LATENCY; s->p[i].port.iobase = i; + /* + * Use all ones as membase to make sure uart_configure_port() in + * serial_core.c does not abort for SPI/I2C devices where the + * membase address is not applicable. + */ + s->p[i].port.membase = (void __iomem *)~0; s->p[i].port.iotype = UPIO_PORT; s->p[i].port.uartclk = freq; s->p[i].port.rs485_config = sc16is7xx_config_rs485; From patchwork Mon Aug 7 21:45:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 132441 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1757062vqr; Mon, 7 Aug 2023 15:58:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEzfjzCK+eUAfHnIYc92DPZqYwO9GVFVoTUUodZcjPxf1h0afjALD5SJzHrQcMmYGIw+4Wh X-Received: by 2002:a17:906:29e:b0:994:522f:3f4a with SMTP id 30-20020a170906029e00b00994522f3f4amr9387193ejf.29.1691449081419; Mon, 07 Aug 2023 15:58:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691449081; cv=none; d=google.com; s=arc-20160816; b=yaTbofb5GsLAgTMmN6qF2R4cV9C/G8go9nNk+5GW07tFc3zDPQz+loyHz5wa7s2Hmh VLkiyS9hu05OeoUrGpUpFFaLCHG39hk4wCroCoOV/91Nh1c44ehizNpHA5k1X4bkRESz XZzFI7IVC08muxonYo5cwj/pB3KL2U0hYcQvY/Z7KBvrk+GhrvZTfk2kfNBr7mX5gJdZ kwvCQ8tC5b0X8YoaJ3U6Et0axFi4pLGMZiK7sL2PQXdwVyBbXyq1HpydBYRdnTJpiURj y890IhpOcovQH2AR6PN1AQ5ynYSW2TD5k8E0hARkJmj5mfozF5vbH2Y01ApTKDD7o+Y4 kCxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from:dkim-signature; bh=+SkF24oHb3YmlPyMPv3TlnmkvSQneN6qudtpivOU/9g=; fh=JR5rg6PU5AqB6xx4WdoFcCPqRiPpCtYWqVucpZcu++Y=; b=uLgj6Ix763iESASDyLrTH5+pvhQTdgks9MqJuAoqzo72IL3bI2fDabp9bKvN+2eS+W lBVQRBG8SWXGI8K1eEbUSzIeFm2qXGOXmxqP3FY/XbUKrSZZuIDx5XelbzPRzdcprYAU DJEk1J6FR10RxQw5EEcG+Y5tTj9a+h4V2Z4zlL21xOYPbzF6/0fwXlGx4sgloDrwME3t 5CQR4+R+xxynUU8jJE7S0uqE4v7HzPT5lgl7tXYZSvUVMN3NMs+Nbs09x8IiquY3RpHF uH671Lm1JBgb9YqsG0XoiqYsZjbchhETd80r4jXbRkupFd/eSVSnAQuLCvRUsZmP88ZO VIFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=Wr94KMWm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lf20-20020a170906ae5400b0099cc030dc66si3781749ejb.19.2023.08.07.15.57.37; Mon, 07 Aug 2023 15:58:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=Wr94KMWm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229914AbjHGVqU (ORCPT + 99 others); Mon, 7 Aug 2023 17:46:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229613AbjHGVqQ (ORCPT ); Mon, 7 Aug 2023 17:46:16 -0400 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1C9010E0; Mon, 7 Aug 2023 14:46:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Cc:To :From:subject:date:message-id:reply-to; bh=+SkF24oHb3YmlPyMPv3TlnmkvSQneN6qudtpivOU/9g=; b=Wr94KMWmTSMZyYL2IkIOd6DnJv 1RsdrYs+FxGEZYFAgkzQP59QgCr54n22hjtIYYKNBFNMAbQxbN0fHTJA+xvPUVSCCYDz1VP/cYMan XS7g22WcVQbl6VukhNIYqpQSMrXR5fexSlBT0VzAuxeRuL/5QJKM3p1Sc4466h7NskGI=; Received: from modemcable061.19-161-184.mc.videotron.ca ([184.161.19.61]:47088 helo=localhost.localdomain) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1qT83G-0000hD-Br; Mon, 07 Aug 2023 17:46:10 -0400 From: Hugo Villeneuve To: gregkh@linuxfoundation.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, jirislaby@kernel.org, jringle@gridpoint.com, tomasz.mon@camlingroup.com, l.perczak@camlintechnologies.com Cc: linux-serial@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, hugo@hugovil.com, linux-gpio@vger.kernel.org, Hugo Villeneuve , Lech Perczak , Andy Shevchenko Date: Mon, 7 Aug 2023 17:45:52 -0400 Message-Id: <20230807214556.540627-3-hugo@hugovil.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230807214556.540627-1-hugo@hugovil.com> References: <20230807214556.540627-1-hugo@hugovil.com> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 184.161.19.61 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v10 2/6] serial: sc16is7xx: remove obsolete out_thread label X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773612912191101660 X-GMAIL-MSGID: 1773612912191101660 From: Hugo Villeneuve Commit c8f71b49ee4d ("serial: sc16is7xx: setup GPIO controller later in probe") moved GPIO setup code later in probe function. Doing so also required to move ports cleanup code (out_ports label) after the GPIO cleanup code. After these moves, the out_thread label becomes misplaced and makes part of the cleanup code illogical. This patch remove the now obsolete out_thread label and make GPIO setup code jump to out_ports label if it fails. Signed-off-by: Hugo Villeneuve Reviewed-by: Lech Perczak Tested-by: Lech Perczak Reviewed-by: Andy Shevchenko --- drivers/tty/serial/sc16is7xx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index ffe817309413..93b4137daa8b 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1522,7 +1522,7 @@ static int sc16is7xx_probe(struct device *dev, s->gpio.can_sleep = 1; ret = gpiochip_add_data(&s->gpio, s); if (ret) - goto out_thread; + goto out_ports; } #endif @@ -1548,8 +1548,6 @@ static int sc16is7xx_probe(struct device *dev, #ifdef CONFIG_GPIOLIB if (devtype->nr_gpio) gpiochip_remove(&s->gpio); - -out_thread: #endif out_ports: From patchwork Mon Aug 7 21:45:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 132461 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1776308vqr; Mon, 7 Aug 2023 16:47:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmk1ZROdMj3N+pJg1ln0zLRRbPIoCoZuJt88920EUbV4N7PGPjq8mKq7eNCN4QcPbkke0o X-Received: by 2002:a17:907:7f91:b0:99c:572:c0e4 with SMTP id qk17-20020a1709077f9100b0099c0572c0e4mr10455757ejc.7.1691452044545; Mon, 07 Aug 2023 16:47:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691452044; cv=none; d=google.com; s=arc-20160816; b=UEPSwE2ui9BoBEFosymmM55FxN++pZhFaY47zSDGvzmYJ8nnCGUvnS8RXMbn46M1+i oxYQPRQ5WmUBHu+HASPKLGZEo3tFHNrijGHrA4BRsXnk/ica7vulxCP8JNz1S2blcSFN K2whaWowEYlRpXEDjutWWALV2LQ5NAa0585058gI4nxr5UWdZXZEeaO9rVHVDiAVyqN1 EwM6BPdgy/ngI1LZmZYAL5oYJMQ6NOBwB/vp+zicBb59YK7QS+edbEq0hSe7yleiLG5x 78GdwEiW0ZYlEbuPeYmO4qCHTZtrwygrC1iUVMyHXrVGiTBqNShDLRljAUVyEqxECEgN IEbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from:dkim-signature; bh=SuJQI5JxUPzY+H5j7N6gL+Df0hCmvZbTgQvKUtpTEpg=; fh=FKfxJThgGPzumPwPikmUsmCHU8gtT7bkR8/gSgaRsHs=; b=F8J8+tXvsBAdlgwz86mVOzv8SAuNvHP2kRgHD5+z+SI+mPI9zEtvhP7iinCA2YPG5f spYgsJFTY9Ys4AjF5s4ni2/tPe0d538n7iXm7t+apTJh+r1rqWC47an6d6Av+BpnCi8e sIne7aIM9jdqR1eJPDDfvXAThHHgzo+PnDpNvaSMJp+Q72jupekTCXDYD67y/NP/wSwS xK0cWuNCo66rkhCW/ztlzj7StcbL6jVjuH7jpOO4+6TPVJUlMC1afOb2DOS4OzSP0p14 I8/hfym+5bcDfIfJjCN6QM4rHQ2a8KMhmJ/O6p04v4sGEPrdwDwTDg0cR67AjM1ZCfYu l83A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=HkTEwK5L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r16-20020a056402035000b0052337b7c6ddsi2262547edw.256.2023.08.07.16.47.01; Mon, 07 Aug 2023 16:47:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=HkTEwK5L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230414AbjHGVq1 (ORCPT + 99 others); Mon, 7 Aug 2023 17:46:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbjHGVqT (ORCPT ); Mon, 7 Aug 2023 17:46:19 -0400 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0589F10CF; Mon, 7 Aug 2023 14:46:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Cc:To :From:subject:date:message-id:reply-to; bh=SuJQI5JxUPzY+H5j7N6gL+Df0hCmvZbTgQvKUtpTEpg=; b=HkTEwK5L9OzC6zISEmxI4mSRza C3aR6425iHYbrjRxrjEadRK8GaGe9Mg1VU3Kt7xoTEEtPggqASpKjsqt1Umkk88+HnWmM5cWHco/A De8sGndp9dlFwoL2VUm5vpTKCOefRYbsHtTBF+/KDzcUpKWe1e75RS3n92VAPYo1ujtY=; Received: from modemcable061.19-161-184.mc.videotron.ca ([184.161.19.61]:47088 helo=localhost.localdomain) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1qT83H-0000hD-Ib; Mon, 07 Aug 2023 17:46:12 -0400 From: Hugo Villeneuve To: gregkh@linuxfoundation.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, jirislaby@kernel.org, jringle@gridpoint.com, tomasz.mon@camlingroup.com, l.perczak@camlintechnologies.com Cc: linux-serial@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, hugo@hugovil.com, linux-gpio@vger.kernel.org, Hugo Villeneuve , stable@vger.kernel.org, Conor Dooley , Lech Perczak Date: Mon, 7 Aug 2023 17:45:53 -0400 Message-Id: <20230807214556.540627-4-hugo@hugovil.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230807214556.540627-1-hugo@hugovil.com> References: <20230807214556.540627-1-hugo@hugovil.com> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 184.161.19.61 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v10 3/6] dt-bindings: sc16is7xx: Add property to change GPIO function X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773616019202869137 X-GMAIL-MSGID: 1773616019202869137 From: Hugo Villeneuve Some variants in this series of UART controllers have GPIO pins that are shared between GPIO and modem control lines. The pin mux mode (GPIO or modem control lines) can be set for each ports (channels) supported by the variant. This adds a property to the device tree to set the GPIO pin mux to modem control lines on selected ports if needed. Cc: # 6.1.x Signed-off-by: Hugo Villeneuve Acked-by: Conor Dooley Reviewed-by: Lech Perczak --- .../bindings/serial/nxp,sc16is7xx.txt | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/Documentation/devicetree/bindings/serial/nxp,sc16is7xx.txt b/Documentation/devicetree/bindings/serial/nxp,sc16is7xx.txt index 0fa8e3e43bf8..1a7e4bff0456 100644 --- a/Documentation/devicetree/bindings/serial/nxp,sc16is7xx.txt +++ b/Documentation/devicetree/bindings/serial/nxp,sc16is7xx.txt @@ -23,6 +23,9 @@ Optional properties: 1 = active low. - irda-mode-ports: An array that lists the indices of the port that should operate in IrDA mode. +- nxp,modem-control-line-ports: An array that lists the indices of the port that + should have shared GPIO lines configured as + modem control lines. Example: sc16is750: sc16is750@51 { @@ -35,6 +38,26 @@ Example: #gpio-cells = <2>; }; + sc16is752: sc16is752@53 { + compatible = "nxp,sc16is752"; + reg = <0x53>; + clocks = <&clk20m>; + interrupt-parent = <&gpio3>; + interrupts = <7 IRQ_TYPE_EDGE_FALLING>; + nxp,modem-control-line-ports = <1>; /* Port 1 as modem control lines */ + gpio-controller; /* Port 0 as GPIOs */ + #gpio-cells = <2>; + }; + + sc16is752: sc16is752@54 { + compatible = "nxp,sc16is752"; + reg = <0x54>; + clocks = <&clk20m>; + interrupt-parent = <&gpio3>; + interrupts = <7 IRQ_TYPE_EDGE_FALLING>; + nxp,modem-control-line-ports = <0 1>; /* Ports 0 and 1 as modem control lines */ + }; + * spi as bus Required properties: @@ -59,6 +82,9 @@ Optional properties: 1 = active low. - irda-mode-ports: An array that lists the indices of the port that should operate in IrDA mode. +- nxp,modem-control-line-ports: An array that lists the indices of the port that + should have shared GPIO lines configured as + modem control lines. Example: sc16is750: sc16is750@0 { @@ -70,3 +96,23 @@ Example: gpio-controller; #gpio-cells = <2>; }; + + sc16is752: sc16is752@1 { + compatible = "nxp,sc16is752"; + reg = <1>; + clocks = <&clk20m>; + interrupt-parent = <&gpio3>; + interrupts = <7 IRQ_TYPE_EDGE_FALLING>; + nxp,modem-control-line-ports = <1>; /* Port 1 as modem control lines */ + gpio-controller; /* Port 0 as GPIOs */ + #gpio-cells = <2>; + }; + + sc16is752: sc16is752@2 { + compatible = "nxp,sc16is752"; + reg = <2>; + clocks = <&clk20m>; + interrupt-parent = <&gpio3>; + interrupts = <7 IRQ_TYPE_EDGE_FALLING>; + nxp,modem-control-line-ports = <0 1>; /* Ports 0 and 1 as modem control lines */ + }; From patchwork Mon Aug 7 21:45:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 132460 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1775409vqr; Mon, 7 Aug 2023 16:44:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6k7L/6Mt0lNytkmcoGcn0J3ufn0I9sSQinu8SXPmkYEl88Diwo++FMjnawKPcVavfW6kM X-Received: by 2002:a05:6a00:3996:b0:687:1603:b2e7 with SMTP id fi22-20020a056a00399600b006871603b2e7mr13336807pfb.8.1691451874427; Mon, 07 Aug 2023 16:44:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691451874; cv=none; d=google.com; s=arc-20160816; b=sXrkwD/wLbzPawmm1ZRTysupBeWr1j5Etiytl0UasowLa7dSCMH56SqsaYAnB5haiY 2yOtk2ZIxC+PM1tJp/mXs7TRNGQbk/xB7kK/VJK6dNP2W4P/c5seRhPsWE+Ul+CbTlpg eEDoCY0IjiLH3Clbozk/I71rQc1dzdSEidFpISfMINefCyOW6SQhdHb/ikn+v6QMu0UJ +S+Q1uSbhnwRZdmtNx4zY1XqBw+EX0nxV2VI9LdY3/gcNpUHaXGWeUtFieR3AAYKkFmg PkNvhJuCHUvmO/MxeqzohTlrMO0GhCeZ3FTgqWEvWS5CyAi9+vRP23XU7ZUdYy7wh9yS wahA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from:dkim-signature; bh=iqLb88yRaBCK6UDZI8+p/gfjhfUhq04DQnHRgP7JEaw=; fh=IFXCJMieVRb8TuiaUJFmt5iX9DV0XQoT5blzGDdBo2M=; b=GtgOcfrnHP+Ly4zadYaXH808xlKoU6abdn/Fvg0S94gd33W5oTFGZGOBK8p4Qrv28g LNt/XRYmL/Qre9aPOrYg1zRLBZtw9Np403E9UppxwbNrJ+kSUM/Ur5d8e00UM7pHZq0t 6cAfxLcm7uXvR8fN5Yo0YmlACD0FHew7ExiC+AcKmgE5Yad+LwHr+uPMqFISSaqfbVlT 87E2RAcdDj4oiToTEa+TAETBil1QZX3/H8zzJhqJXbgKtaDBd/Gd/gkWA3ws8nnffaJV dS/9lrN1EhC3yRSZz5/68RnIoe0Wu/WzpSAo5AvikqNhajTHGO1siDX9YWwOM1AUkPCg beKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=Bnrfcdrz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s21-20020a63f055000000b0055ba8970e7asi6125353pgj.616.2023.08.07.16.44.21; Mon, 07 Aug 2023 16:44:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=Bnrfcdrz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230381AbjHGVq3 (ORCPT + 99 others); Mon, 7 Aug 2023 17:46:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229613AbjHGVqV (ORCPT ); Mon, 7 Aug 2023 17:46:21 -0400 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B9AC1711; Mon, 7 Aug 2023 14:46:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Cc:To :From:subject:date:message-id:reply-to; bh=iqLb88yRaBCK6UDZI8+p/gfjhfUhq04DQnHRgP7JEaw=; b=Bnrfcdrz0dUXVP8teE4h2Z7XzS 9AAD2UN5owIuxD38uiDTSB6KuMRfbcTs3MyVXa4R3Jaevg68WlO90UegAcB29EzTRyf4PCs3msX3Z TISfZJ7Vp9b9JSttlcO1sFlYqq7gwzQqPq1RkNEpLw8Ayl4T3paH9qa05lJmvF3HlEK4=; Received: from modemcable061.19-161-184.mc.videotron.ca ([184.161.19.61]:47088 helo=localhost.localdomain) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1qT83J-0000hD-Nz; Mon, 07 Aug 2023 17:46:14 -0400 From: Hugo Villeneuve To: gregkh@linuxfoundation.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, jirislaby@kernel.org, jringle@gridpoint.com, tomasz.mon@camlingroup.com, l.perczak@camlintechnologies.com Cc: linux-serial@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, hugo@hugovil.com, linux-gpio@vger.kernel.org, Hugo Villeneuve , stable@vger.kernel.org, Andy Shevchenko , Lech Perczak Date: Mon, 7 Aug 2023 17:45:54 -0400 Message-Id: <20230807214556.540627-5-hugo@hugovil.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230807214556.540627-1-hugo@hugovil.com> References: <20230807214556.540627-1-hugo@hugovil.com> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 184.161.19.61 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v10 4/6] serial: sc16is7xx: fix regression with GPIO configuration X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773615840826533224 X-GMAIL-MSGID: 1773615840826533224 From: Hugo Villeneuve Commit 679875d1d880 ("sc16is7xx: Separate GPIOs from modem control lines") and commit 21144bab4f11 ("sc16is7xx: Handle modem status lines") changed the function of the GPIOs pins to act as modem control lines without any possibility of selecting GPIO function. As a consequence, applications that depends on GPIO lines configured by default as GPIO pins no longer work as expected. Also, the change to select modem control lines function was done only for channel A of dual UART variants (752/762). This was not documented in the log message. Allow to specify GPIO or modem control line function in the device tree, and for each of the ports (A or B). Do so by using the new device-tree property named "nxp,modem-control-line-ports" (property added in separate patch). When registering GPIO chip controller, mask-out GPIO pins declared as modem control lines according to this new DT property. Fixes: 679875d1d880 ("sc16is7xx: Separate GPIOs from modem control lines") Fixes: 21144bab4f11 ("sc16is7xx: Handle modem status lines") Cc: Signed-off-by: Hugo Villeneuve Reviewed-by: Andy Shevchenko Reviewed-by: Lech Perczak Tested-by: Lech Perczak Acked-by: Rob Herring --- drivers/tty/serial/sc16is7xx.c | 143 +++++++++++++++++++++++++-------- 1 file changed, 108 insertions(+), 35 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 93b4137daa8b..b45e34e3910d 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -236,7 +236,8 @@ /* IOControl register bits (Only 750/760) */ #define SC16IS7XX_IOCONTROL_LATCH_BIT (1 << 0) /* Enable input latching */ -#define SC16IS7XX_IOCONTROL_MODEM_BIT (1 << 1) /* Enable GPIO[7:4] as modem pins */ +#define SC16IS7XX_IOCONTROL_MODEM_A_BIT (1 << 1) /* Enable GPIO[7:4] as modem A pins */ +#define SC16IS7XX_IOCONTROL_MODEM_B_BIT (1 << 2) /* Enable GPIO[3:0] as modem B pins */ #define SC16IS7XX_IOCONTROL_SRESET_BIT (1 << 3) /* Software Reset */ /* EFCR register bits */ @@ -301,12 +302,12 @@ /* Misc definitions */ #define SC16IS7XX_FIFO_SIZE (64) #define SC16IS7XX_REG_SHIFT 2 +#define SC16IS7XX_GPIOS_PER_BANK 4 struct sc16is7xx_devtype { char name[10]; int nr_gpio; int nr_uart; - int has_mctrl; }; #define SC16IS7XX_RECONF_MD (1 << 0) @@ -336,7 +337,9 @@ struct sc16is7xx_port { struct clk *clk; #ifdef CONFIG_GPIOLIB struct gpio_chip gpio; + unsigned long gpio_valid_mask; #endif + u8 mctrl_mask; unsigned char buf[SC16IS7XX_FIFO_SIZE]; struct kthread_worker kworker; struct task_struct *kworker_task; @@ -447,35 +450,30 @@ static const struct sc16is7xx_devtype sc16is74x_devtype = { .name = "SC16IS74X", .nr_gpio = 0, .nr_uart = 1, - .has_mctrl = 0, }; static const struct sc16is7xx_devtype sc16is750_devtype = { .name = "SC16IS750", - .nr_gpio = 4, + .nr_gpio = 8, .nr_uart = 1, - .has_mctrl = 1, }; static const struct sc16is7xx_devtype sc16is752_devtype = { .name = "SC16IS752", - .nr_gpio = 0, + .nr_gpio = 8, .nr_uart = 2, - .has_mctrl = 1, }; static const struct sc16is7xx_devtype sc16is760_devtype = { .name = "SC16IS760", - .nr_gpio = 4, + .nr_gpio = 8, .nr_uart = 1, - .has_mctrl = 1, }; static const struct sc16is7xx_devtype sc16is762_devtype = { .name = "SC16IS762", - .nr_gpio = 0, + .nr_gpio = 8, .nr_uart = 2, - .has_mctrl = 1, }; static bool sc16is7xx_regmap_volatile(struct device *dev, unsigned int reg) @@ -1350,8 +1348,98 @@ static int sc16is7xx_gpio_direction_output(struct gpio_chip *chip, return 0; } + +static int sc16is7xx_gpio_init_valid_mask(struct gpio_chip *chip, + unsigned long *valid_mask, + unsigned int ngpios) +{ + struct sc16is7xx_port *s = gpiochip_get_data(chip); + + *valid_mask = s->gpio_valid_mask; + + return 0; +} + +static int sc16is7xx_setup_gpio_chip(struct sc16is7xx_port *s) +{ + struct device *dev = s->p[0].port.dev; + + if (!s->devtype->nr_gpio) + return 0; + + switch (s->mctrl_mask) { + case 0: + s->gpio_valid_mask = GENMASK(7, 0); + break; + case SC16IS7XX_IOCONTROL_MODEM_A_BIT: + s->gpio_valid_mask = GENMASK(3, 0); + break; + case SC16IS7XX_IOCONTROL_MODEM_B_BIT: + s->gpio_valid_mask = GENMASK(7, 4); + break; + default: + break; + } + + if (s->gpio_valid_mask == 0) + return 0; + + s->gpio.owner = THIS_MODULE; + s->gpio.parent = dev; + s->gpio.label = dev_name(dev); + s->gpio.init_valid_mask = sc16is7xx_gpio_init_valid_mask; + s->gpio.direction_input = sc16is7xx_gpio_direction_input; + s->gpio.get = sc16is7xx_gpio_get; + s->gpio.direction_output = sc16is7xx_gpio_direction_output; + s->gpio.set = sc16is7xx_gpio_set; + s->gpio.base = -1; + s->gpio.ngpio = s->devtype->nr_gpio; + s->gpio.can_sleep = 1; + + return gpiochip_add_data(&s->gpio, s); +} #endif +/* + * Configure ports designated to operate as modem control lines. + */ +static int sc16is7xx_setup_mctrl_ports(struct sc16is7xx_port *s) +{ + int i; + int ret; + int count; + u32 mctrl_port[2]; + struct device *dev = s->p[0].port.dev; + + count = device_property_count_u32(dev, "nxp,modem-control-line-ports"); + if (count < 0 || count > ARRAY_SIZE(mctrl_port)) + return 0; + + ret = device_property_read_u32_array(dev, "nxp,modem-control-line-ports", + mctrl_port, count); + if (ret) + return ret; + + s->mctrl_mask = 0; + + for (i = 0; i < count; i++) { + /* Use GPIO lines as modem control lines */ + if (mctrl_port[i] == 0) + s->mctrl_mask |= SC16IS7XX_IOCONTROL_MODEM_A_BIT; + else if (mctrl_port[i] == 1) + s->mctrl_mask |= SC16IS7XX_IOCONTROL_MODEM_B_BIT; + } + + if (s->mctrl_mask) + regmap_update_bits( + s->regmap, + SC16IS7XX_IOCONTROL_REG << SC16IS7XX_REG_SHIFT, + SC16IS7XX_IOCONTROL_MODEM_A_BIT | + SC16IS7XX_IOCONTROL_MODEM_B_BIT, s->mctrl_mask); + + return 0; +} + static const struct serial_rs485 sc16is7xx_rs485_supported = { .flags = SER_RS485_ENABLED | SER_RS485_RTS_AFTER_SEND, .delay_rts_before_send = 1, @@ -1464,12 +1552,6 @@ static int sc16is7xx_probe(struct device *dev, SC16IS7XX_EFCR_RXDISABLE_BIT | SC16IS7XX_EFCR_TXDISABLE_BIT); - /* Use GPIO lines as modem status registers */ - if (devtype->has_mctrl) - sc16is7xx_port_write(&s->p[i].port, - SC16IS7XX_IOCONTROL_REG, - SC16IS7XX_IOCONTROL_MODEM_BIT); - /* Initialize kthread work structs */ kthread_init_work(&s->p[i].tx_work, sc16is7xx_tx_proc); kthread_init_work(&s->p[i].reg_work, sc16is7xx_reg_proc); @@ -1507,23 +1589,14 @@ static int sc16is7xx_probe(struct device *dev, s->p[u].irda_mode = true; } + ret = sc16is7xx_setup_mctrl_ports(s); + if (ret) + goto out_ports; + #ifdef CONFIG_GPIOLIB - if (devtype->nr_gpio) { - /* Setup GPIO cotroller */ - s->gpio.owner = THIS_MODULE; - s->gpio.parent = dev; - s->gpio.label = dev_name(dev); - s->gpio.direction_input = sc16is7xx_gpio_direction_input; - s->gpio.get = sc16is7xx_gpio_get; - s->gpio.direction_output = sc16is7xx_gpio_direction_output; - s->gpio.set = sc16is7xx_gpio_set; - s->gpio.base = -1; - s->gpio.ngpio = devtype->nr_gpio; - s->gpio.can_sleep = 1; - ret = gpiochip_add_data(&s->gpio, s); - if (ret) - goto out_ports; - } + ret = sc16is7xx_setup_gpio_chip(s); + if (ret) + goto out_ports; #endif /* @@ -1546,7 +1619,7 @@ static int sc16is7xx_probe(struct device *dev, return 0; #ifdef CONFIG_GPIOLIB - if (devtype->nr_gpio) + if (s->gpio_valid_mask) gpiochip_remove(&s->gpio); #endif @@ -1570,7 +1643,7 @@ static void sc16is7xx_remove(struct device *dev) int i; #ifdef CONFIG_GPIOLIB - if (s->devtype->nr_gpio) + if (s->gpio_valid_mask) gpiochip_remove(&s->gpio); #endif From patchwork Mon Aug 7 21:45:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 132469 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1804801vqr; Mon, 7 Aug 2023 18:04:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqkzV98iQA7QlsxYbT3aDuy2ponMvfbI9wzM61gfYPek7H2I1P1VhSh4QML7nqD02Y2V0p X-Received: by 2002:a17:90a:2acf:b0:267:f2f6:586b with SMTP id i15-20020a17090a2acf00b00267f2f6586bmr7756901pjg.21.1691456651175; Mon, 07 Aug 2023 18:04:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691456651; cv=none; d=google.com; s=arc-20160816; b=GHVkwqOiSaTh9uWKg3vx0+BjBHxWrkIQL/Mkh646KayXJBfD2NbHPO160RO/JKLQN2 eX8RlNLr7yqrTQmkjKMghq67P9Ri/7rTvQUV7j2sSi5cQqS7LOCqMxIHFQrYFNJdfdCK J5alqTXFPA/NeciUu7InUcBZQWq/SdEhV0JhZmtcV9dZM9yLBX59aHwcHZJWZ8gZOp3l yLG0rh0tv67DhaBUtG1XIqekcaC5NWB1iMO6jnHgScIhrPd3W7cW+7TdEGVdVjtrDNGq 7N7A2m6Y8wfOpHeVDFKUe8LsS2T83y9LgSPY83Wx5C5YGiHgNjUpscWPQrHd1LzRWg5B WNVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from:dkim-signature; bh=enU4NC1XhRMNQEPd0as2RRvEtsGncqBf+Slh5pDF7Rg=; fh=PqVA25MojkD3iyV4re9eIpwsmkNlda90DITt1ZFDJKo=; b=Iqia3b1gu4vIk8A2VK7GpTwcXotdxxQLbLw5qdDN3xEw8VLBTFaQ4Yp11dFkB1ljO7 u6zKWCdlSlxzKuGr4RX3ESe8Hh9z1jNHz4QLLoPT/1Nk0tbMVaf5eAtfSTuauYvdE/CY 3AjaiCZv7t5hOXG5OdYa0oKTVcCWBQGYDpTRgOWPnPmwK0s98PLbqmnaBkotK+Iao6W4 T+/W15bH2pTTDF8r0SgJB+UfeGcnBnokdDpi+7g3JBLfBGb7nyq84WZENPN6oO49ZWz9 mWhrwPJ7Az2HbIzAd76VN0GwBB4WfDb5gxuee5+ZkOtZZqgpeaDC4LQ4grWlocXYmEFj lbkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b="iBJ/WxPR"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ot6-20020a17090b3b4600b00267d70fe0f7si6673312pjb.23.2023.08.07.18.03.57; Mon, 07 Aug 2023 18:04:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b="iBJ/WxPR"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230395AbjHGVqb (ORCPT + 99 others); Mon, 7 Aug 2023 17:46:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230021AbjHGVqW (ORCPT ); Mon, 7 Aug 2023 17:46:22 -0400 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E5911722; Mon, 7 Aug 2023 14:46:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Cc:To :From:subject:date:message-id:reply-to; bh=enU4NC1XhRMNQEPd0as2RRvEtsGncqBf+Slh5pDF7Rg=; b=iBJ/WxPRm9CXh18Q97WivGhLfR uU3l7LuTesZ64AKYxIQ2NZywC4Hz39jvk8Av9gWzeVUbXkT892fk5ytiwE5VXvrcxqrBgrNQFS6Fo 5PJw/cZqqEro6ZoG/kROGWhZKehydCoNINnMoNKlmR/nb66xlNp3uISbVeZn3zS/WOGA=; Received: from modemcable061.19-161-184.mc.videotron.ca ([184.161.19.61]:47088 helo=localhost.localdomain) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1qT83L-0000hD-JU; Mon, 07 Aug 2023 17:46:16 -0400 From: Hugo Villeneuve To: gregkh@linuxfoundation.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, jirislaby@kernel.org, jringle@gridpoint.com, tomasz.mon@camlingroup.com, l.perczak@camlintechnologies.com Cc: linux-serial@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, hugo@hugovil.com, linux-gpio@vger.kernel.org, Hugo Villeneuve , stable@vger.kernel.org, Lech Perczak Date: Mon, 7 Aug 2023 17:45:55 -0400 Message-Id: <20230807214556.540627-6-hugo@hugovil.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230807214556.540627-1-hugo@hugovil.com> References: <20230807214556.540627-1-hugo@hugovil.com> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 184.161.19.61 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v10 5/6] serial: sc16is7xx: fix bug when first setting GPIO direction X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773620849430920230 X-GMAIL-MSGID: 1773620849430920230 From: Hugo Villeneuve When configuring a pin as an output pin with a value of logic 0, we end up as having a value of logic 1 on the output pin. Setting a logic 0 a second time (or more) after that will correctly output a logic 0 on the output pin. By default, all GPIO pins are configured as inputs. When we enter sc16is7xx_gpio_direction_output() for the first time, we first set the desired value in IOSTATE, and then we configure the pin as an output. The datasheet states that writing to IOSTATE register will trigger a transfer of the value to the I/O pin configured as output, so if the pin is configured as an input, nothing will be transferred. Therefore, set the direction first in IODIR, and then set the desired value in IOSTATE. This is what is done in NXP application note AN10587. Fixes: dfeae619d781 ("serial: sc16is7xx") Cc: Signed-off-by: Hugo Villeneuve Reviewed-by: Lech Perczak Tested-by: Lech Perczak --- drivers/tty/serial/sc16is7xx.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index b45e34e3910d..cfc88959b2f7 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1342,9 +1342,18 @@ static int sc16is7xx_gpio_direction_output(struct gpio_chip *chip, state |= BIT(offset); else state &= ~BIT(offset); - sc16is7xx_port_write(port, SC16IS7XX_IOSTATE_REG, state); + + /* + * If we write IOSTATE first, and then IODIR, the output value is not + * transferred to the corresponding I/O pin. + * The datasheet states that each register bit will be transferred to + * the corresponding I/O pin programmed as output when writing to + * IOSTATE. Therefore, configure direction first with IODIR, and then + * set value after with IOSTATE. + */ sc16is7xx_port_update(port, SC16IS7XX_IODIR_REG, BIT(offset), BIT(offset)); + sc16is7xx_port_write(port, SC16IS7XX_IOSTATE_REG, state); return 0; } From patchwork Mon Aug 7 21:45:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 132457 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1771143vqr; Mon, 7 Aug 2023 16:32:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH/8b6YlAte1DHgDUYBqEjeLf6X8oCahYq0nKvAe+rQt9XOIMe3yRLSYJo2RrTDiE6NDnch X-Received: by 2002:aa7:c556:0:b0:523:47b0:9077 with SMTP id s22-20020aa7c556000000b0052347b09077mr153403edr.38.1691451123900; Mon, 07 Aug 2023 16:32:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691451123; cv=none; d=google.com; s=arc-20160816; b=ozw29egnLWQVSzSmRXtSNSQj70PQlW+kSUwXkZfqUNsfNkSlrECm/sjVdOKS4JGg7z mOPEslHZUA3PJ0hwUjNz1ifOBZe4ABzlspBZEY6dCkVvwKBDAs0U573VhlC4XKFcrJwV fnNxFDR2JkAogQZHTqgE/+HRPkgRgTUoB4x9+2ht0hglaf/4lY5IB/Z+pZFXkTBqLfMX Uk+cZ5oggZfMjKhAbCw/a7Xo0qk8yIFhtPxHzAguHgPiSLOlqT1IU9KnNGIks4KXEU3R joA1AoqpgqZfwIwl3A0fizgVUKcPDmdBD7cpU/uxrpgFXa53IInZLm/bazg78KzrcWfE 3Zpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from:dkim-signature; bh=ec1Zk637eDWVn64eclVyppNTtCvrXv42fcayZ6Lfi9Y=; fh=BgpvEVgJGj34BIZzOiHxP3hFF9kEMYMub/2dVXyosI0=; b=GRRI/baT9r5sD/2pX9QIu//7CpWKHp5mTQ+8HXk/kS/IdZZNwbO4xic8scpFjtnUD1 i712kpJYKvPGgvLRYWSpJkuFuswMXfSBHaT2e+b0dvKdhxJRyKurk9TKe/fMJPY4Rc6w KPg2i4zWWUr/RuTZqIIaqE34NEmgkSAbX4oiSz54WbsQEdwGwUQz6wSNoxEiCcpe+MVD BrcPzwBCJAXWcOZHkysTNdGLllz7pL3SbYVCRYV1JufgDuBe3OHniIzlejMsZq/9YQwE tTR+/3M0gkvOef+Oy5XqSFdgyA1ukSpX303AoVQFj/VmLPTO2R2zUjCv8WqCoT1+neI3 wpEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=tTfplzTb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f23-20020aa7d857000000b005222b60fc67si6140861eds.303.2023.08.07.16.31.40; Mon, 07 Aug 2023 16:32:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=tTfplzTb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230503AbjHGVqf (ORCPT + 99 others); Mon, 7 Aug 2023 17:46:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230423AbjHGVq2 (ORCPT ); Mon, 7 Aug 2023 17:46:28 -0400 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 965FF1711; Mon, 7 Aug 2023 14:46:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Cc:To :From:subject:date:message-id:reply-to; bh=ec1Zk637eDWVn64eclVyppNTtCvrXv42fcayZ6Lfi9Y=; b=tTfplzTb1uVvw0pB7IziW/RgS7 kh6UihZgHwGCj1AtHDh5E/HLu3J07XgHfvUuEHirzfE+l3QWwO8q/L0y5z3hcxxEqak9tGYHAZXTD mM2/5FItTd/0LLxuiVeS4xvRwI4hXYxqLSjO+iFQCwvUH7flt469zgY0l5Nf9P/HWWZM=; Received: from modemcable061.19-161-184.mc.videotron.ca ([184.161.19.61]:47088 helo=localhost.localdomain) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1qT83N-0000hD-74; Mon, 07 Aug 2023 17:46:17 -0400 From: Hugo Villeneuve To: gregkh@linuxfoundation.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, jirislaby@kernel.org, jringle@gridpoint.com, tomasz.mon@camlingroup.com, l.perczak@camlintechnologies.com Cc: linux-serial@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, hugo@hugovil.com, linux-gpio@vger.kernel.org, Hugo Villeneuve , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Lech Perczak Date: Mon, 7 Aug 2023 17:45:56 -0400 Message-Id: <20230807214556.540627-7-hugo@hugovil.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230807214556.540627-1-hugo@hugovil.com> References: <20230807214556.540627-1-hugo@hugovil.com> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 184.161.19.61 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v10 6/6] serial: sc16is7xx: add missing support for rs485 devicetree properties X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773615053611633430 X-GMAIL-MSGID: 1773615053611633430 From: Hugo Villeneuve Retrieve rs485 devicetree properties on registration of sc16is7xx ports in case they are attached to an rs485 transceiver. Signed-off-by: Hugo Villeneuve Reviewed-by: Ilpo Järvinen Reviewed-by: Lech Perczak Tested-by: Lech Perczak --- drivers/tty/serial/sc16is7xx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index cfc88959b2f7..f61d98e09dc3 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1554,6 +1554,10 @@ static int sc16is7xx_probe(struct device *dev, goto out_ports; } + ret = uart_get_rs485_mode(&s->p[i].port); + if (ret) + goto out_ports; + /* Disable all interrupts */ sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_IER_REG, 0); /* Disable TX/RX */