From patchwork Tue Jul 25 14:23:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 125663 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2511438vqg; Tue, 25 Jul 2023 07:30:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlEzzHnu2Zrwy1gdsoobLHeYis/fbvnxFuxD+DQdNrflwrGEdQfJ8vl0blIbaU2ZcHf6Bm+Y X-Received: by 2002:a17:902:7404:b0:1bb:bbd4:aadf with SMTP id g4-20020a170902740400b001bbbbd4aadfmr2021339pll.61.1690295429052; Tue, 25 Jul 2023 07:30:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690295429; cv=none; d=google.com; s=arc-20160816; b=lqqUnMHxpB94OPWDnKmIYAN9/oN+eP2v++iZvioCfvZ+ggnlrbL9ytoSDZMbfqFYa9 /Z25Mw+KVkibcwBcxhbFzT5S83RxMzhJ9RjRk+lnmoWBXnrssiGI326wS1T+8tKAJCJY 0tDsoro9GmpQHEikmpeMtsV6yNoDubu18PfTT/pvewtqKoIMBXifICl5dn9BxLjJYNAH 2njJK52sB/AP0vq+shRDELK6KF+NADdhonGoHFWdjXpkAdmbyRkcdKzJD6nxFZjISqxj VLHDjTMpdR2ob9/YEZLoJJDvgThsw+wplNOtZb2n1rshpNhZqO8Fi6MwLVTAcGAU+oTs Ulow== 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=5nJGAa1uU81DK4gB/PIFJUn37k+YUGRc051pFa/OAlQ=; fh=HLAfhnw1WprbhugNEy0MHgtKacMiD1NxwsnN5n5U29I=; b=XYQSTfUbzg9zrcqbvlfze7gieMsKjTdB/3Zi1cHVYceimjT/Rq1CsL1h9EyLCriyTA YXpcFRxUX1sSObr4oJmUO9OJfkBbubmPmhrMZqrud82gQfEIKRcgliZVMRjtsmi14T4T 9Xj0KWBfF2EgGx/DfNvzC9BDOwM83mQLFreihnTrp9vrX2ALDT9qEZcmAwlPmXN7VHnt y0q9q3M503AdX998T+ayh+2ShwXNKV4H/mx6eEh+Jjx8xuNyyq4k2NjXT/RFXK/4ew5I O1eXHiMWcsH2b0I67QPtJboNj9eJnhr/7Eykh+mloEKva+nvgkB1uO9Dm3it6v6fjhY9 dNyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hugovil.com header.s=x header.b=xsFBO3i1; 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 b11-20020a170903228b00b001b9d2982362si12779162plh.36.2023.07.25.07.30.14; Tue, 25 Jul 2023 07:30:29 -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=fail header.i=@hugovil.com header.s=x header.b=xsFBO3i1; 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 S232754AbjGYOYN (ORCPT + 99 others); Tue, 25 Jul 2023 10:24:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232478AbjGYOYH (ORCPT ); Tue, 25 Jul 2023 10:24:07 -0400 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9310D2697; Tue, 25 Jul 2023 07:23:59 -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:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=5nJGAa1uU81DK4gB/PIFJUn37k+YUGRc051pFa/OAlQ=; b=xsFBO3i1TLHsOEqAFt17vLy3Ch LB0vgbhT6rKkFx0AZYV7s/uTCXXC3iUigoqqtaMyHHnV1B49aQ7rOPZnZxECfaej+AqImnN0rQDSq HIvnwa8s6ZU74SzHwbDe6I0lE7+YMPTQpgDA/ImGNAVCaj1nt5mx+0nuNqSh92sQqU0U=; Received: from modemcable061.19-161-184.mc.videotron.ca ([184.161.19.61]:34256 helo=localhost.localdomain) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1qOIx3-0003Kt-17; Tue, 25 Jul 2023 10:23:49 -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, isaac.true@canonical.com, jesse.sung@canonical.com, l.perczak@camlintechnologies.com, tomasz.mon@camlingroup.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: Tue, 25 Jul 2023 10:23:33 -0400 Message-Id: <20230725142343.1724130-2-hugo@hugovil.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230725142343.1724130-1-hugo@hugovil.com> References: <20230725142343.1724130-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,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v9 01/10] 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: 1772403219657916234 X-GMAIL-MSGID: 1772403219657916234 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: # 6.1.x Signed-off-by: Hugo Villeneuve Reviewed-by: Ilpo Järvinen Reviewed-by: Lech Perczak Tested-by: Lech Perczak Reviewed-by: Ilpo Järvinen --- drivers/tty/serial/sc16is7xx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 2e7e7c409cf2..8ae2afc76a9b 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1436,6 +1436,7 @@ 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; + 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 Tue Jul 25 14:23:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 125665 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2511736vqg; Tue, 25 Jul 2023 07:30:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlHeP8zqUSCKjJp35iGaBMAEOhkkUDIU/7JzMptJ2G7B5K62GeKWzYZVSuoESBgmKAQDLy+V X-Received: by 2002:a17:902:7488:b0:1bb:99d3:6a53 with SMTP id h8-20020a170902748800b001bb99d36a53mr6706303pll.20.1690295446533; Tue, 25 Jul 2023 07:30:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690295446; cv=none; d=google.com; s=arc-20160816; b=npibMIj6atL2xft8f6Z3PAlbWMr08uBq33Ob1ujKvqeSrdSfXyRNTnO/mqbG+gHjUQ 0jPndc5gvpSn3CQjnSiwD+H/hjCfw4QCusQlBk/52757/v2lq/W6Eut64ivs8ca+iSJg IQY95Uphzs++HTltzrJpzm5RtY+tzL1hxb7XjP9+NegPs3lWCA8WFTL7oOYKl5YNnI9T YVBApwwHvkZbwxtBzrulVeY/IwpXcv3+MsA/QQSkVGJLIaRnAnidoPhd51cS0dT9X1q8 bZrp60QEFGUR+y6UxUt/+TmVWNrtQ3tuSA1Pf+baC48PBne3sO+aaNUWiI2k9wPyCsBw 0PmQ== 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=P6gLA3cgegvRbC7LXs18deF6K32T+CIZJfA5vParMVw=; fh=6iQU/ZFDPB2EtbtrLPL1mq7BpEUKhm02utK8313rrOA=; b=gX8Tc6fWLCeYumPSKgO4K/VhOE3KFbrb7cLMq/IyAGWgxbmGyfH3cGg0UQqbLdfMcx 5TzlKVWa30+POdxMVHibBCfUbrpdrhSI9+5T+u1Ab1CtxpWN3OIuB8y1xQFP/aTDIr7I 2E4q+H0E7Mhgn30dKyuiKH4HXVYisWLuyKpCbPykGXpoKe1BuwOIM0Qiz2muEJNQLe9R liEmyvNm8rMW5Fnru/qlnpbzQg0a1M0oqw/IVT++DmQho8JtjxsfvGGsiW4RdHtuUWV0 2pR8WVA7hSsherdRPvTe3V5zdkBPxeBn+bbfdf2ny+v5P+HRh8qAhzMgW6IZm6zkQ5Sb l2xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hugovil.com header.s=x header.b=OQvZtsr4; 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 t3-20020a170902e84300b001b9fb1a0465si12002771plg.385.2023.07.25.07.30.32; Tue, 25 Jul 2023 07:30:46 -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=fail header.i=@hugovil.com header.s=x header.b=OQvZtsr4; 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 S232943AbjGYOYZ (ORCPT + 99 others); Tue, 25 Jul 2023 10:24:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232566AbjGYOYI (ORCPT ); Tue, 25 Jul 2023 10:24:08 -0400 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B651269F; Tue, 25 Jul 2023 07:24:00 -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:References: In-Reply-To:Message-Id:Date:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=P6gLA3cgegvRbC7LXs18deF6K32T+CIZJfA5vParMVw=; b=OQvZtsr4nL/FFGf88cw9gTlNvD 6V+ysGtUbLvw7wHqDJSm0ix1FVw11XvEJ0ZUZg4/dXfU1M2XBx+0vgRiusRJJDjhrZUgYBPQ6CZLB OiPLTXtANOBdFXA0iSZMkXWaZQ/ENinwvZamtYly4FHMgoPDgywULuYNU+ZvkWylsb3g=; Received: from modemcable061.19-161-184.mc.videotron.ca ([184.161.19.61]:34256 helo=localhost.localdomain) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1qOIx6-0003Kt-A4; Tue, 25 Jul 2023 10:23:52 -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, isaac.true@canonical.com, jesse.sung@canonical.com, l.perczak@camlintechnologies.com, tomasz.mon@camlingroup.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: Tue, 25 Jul 2023 10:23:34 -0400 Message-Id: <20230725142343.1724130-3-hugo@hugovil.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230725142343.1724130-1-hugo@hugovil.com> References: <20230725142343.1724130-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,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v9 02/10] serial: sc16is7xx: mark IOCONTROL register as volatile 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: 1772403237895646990 X-GMAIL-MSGID: 1772403237895646990 From: Hugo Villeneuve Bit SRESET (3) is cleared when a reset operation is completed. Having the IOCONTROL register as non-volatile will always read SRESET as 1, which is incorrect. Also, if IOCONTROL register is not a volatile register, the upcoming patch "serial: sc16is7xx: fix regression with GPIO configuration" doesn't work when setting some shared GPIO lines as modem control lines. Therefore mark IOCONTROL register as a volatile register. Cc: # 6.1.x Signed-off-by: Hugo Villeneuve Reviewed-by: Lech Perczak Tested-by: Lech Perczak --- drivers/tty/serial/sc16is7xx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 8ae2afc76a9b..306ae512b38a 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -488,6 +488,7 @@ static bool sc16is7xx_regmap_volatile(struct device *dev, unsigned int reg) case SC16IS7XX_TXLVL_REG: case SC16IS7XX_RXLVL_REG: case SC16IS7XX_IOSTATE_REG: + case SC16IS7XX_IOCONTROL_REG: return true; default: break; From patchwork Tue Jul 25 14:23:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 125681 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2525896vqg; Tue, 25 Jul 2023 07:54:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlEuD/NQ8gE6R7+jIuPSTA0nGlTaNyl/Bnq5M/JfYgd4IezWoxafUtSAewzgAfYgyN8mczFh X-Received: by 2002:a05:6a00:9a0:b0:686:baf2:35f4 with SMTP id u32-20020a056a0009a000b00686baf235f4mr334189pfg.29.1690296867688; Tue, 25 Jul 2023 07:54:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690296867; cv=none; d=google.com; s=arc-20160816; b=MtrTx2pC0BI7fAh/spoWi8zNQivxcf9870QmtIWE2n+jDuq8uyZdf5mPJjxtimGrMx +Ahv/uEsDrWc7XULH/ju8cDmRD/WiaIXSm5PkQH70ShqVzxmeEyBKq1Dt+7zIOFnC28G Oq3GJ/GLFRon7MdkX3MxjW9uwiVhYNIA2oUATaOa0uRPXQ4P26OEHRaL6hqfoMYv652A UOLQwcdvrKNMKXEStsj06hslXh6kT3uYkewFrYrsTNwcJx48DRJL3lYuqHhdUE51qsBY p++rGYfCyh0bYDohE9InTBF6dSJKC6JI5QTXVlWYZ9+oKdLRIiGHPlAeDKXH+vUTg5bx SsWw== 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=3cFxvmO7sr+2mXLVwLsYIFte9IVFO4PRYte249nYxi0=; fh=U7PnHjVqila0zZyl9FKG/x3N3NEQGX70rsyjAE/5OKU=; b=v0MtTuf6xZTNo1iOP9ln0xOGNfSgx8bAtE/zY50ZNkzteiADcZlSM9dVX2/EO7yJqJ 4hf9uhQrLHotOWAvtYxrLkLGf4qugZgqTuJaBF8xVsD1YqJjIHNZnRBEJnoGof0aLlhD HUbU3aAHiY0GBJqzhQ29MwgBGeIt56s1qqNs7/pTOzOSifN9U5AzuT0NlDb2iNEWHA9Z m0rsvmqsmXUB8LgVXfdHqRCpoaVT1Ts60YheDNcSKqkTy6IOioFHLzAywAw8bwx5xAKG row8Mqz2UmHWjSfFoVXqVlBk1neviQEvBGBp55ZDpyeFgrml+br9ylhg/f6K5VMox2Na dpvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hugovil.com header.s=x header.b=xXkDTr7D; 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 x10-20020a056a00188a00b0068231201456si12313355pfh.173.2023.07.25.07.54.14; Tue, 25 Jul 2023 07:54:27 -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=fail header.i=@hugovil.com header.s=x header.b=xXkDTr7D; 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 S229871AbjGYOYS (ORCPT + 99 others); Tue, 25 Jul 2023 10:24:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232040AbjGYOYI (ORCPT ); Tue, 25 Jul 2023 10:24:08 -0400 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62BB9136; Tue, 25 Jul 2023 07:24:00 -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:References: In-Reply-To:Message-Id:Date:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=3cFxvmO7sr+2mXLVwLsYIFte9IVFO4PRYte249nYxi0=; b=xXkDTr7Dl+mL1rrAzE1nbtT4V2 3IaRkderAgNLBt8DNoqgbZh2K/EsO1vfOgPJxad1j+d4B7Njqz2bfmoJermebm81vkSJcggDkfOST AllvGuolvFhziGIi9kPLVN9Q7uclLtonVK6LyOWxw+iHSiQeSqNdY5z6SbCQqGHnxFMU=; Received: from modemcable061.19-161-184.mc.videotron.ca ([184.161.19.61]:34256 helo=localhost.localdomain) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1qOIx8-0003Kt-IW; Tue, 25 Jul 2023 10:23:55 -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, isaac.true@canonical.com, jesse.sung@canonical.com, l.perczak@camlintechnologies.com, tomasz.mon@camlingroup.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: Tue, 25 Jul 2023 10:23:35 -0400 Message-Id: <20230725142343.1724130-4-hugo@hugovil.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230725142343.1724130-1-hugo@hugovil.com> References: <20230725142343.1724130-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,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v9 03/10] 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: 1772404728369205913 X-GMAIL-MSGID: 1772404728369205913 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. Fixes: c8f71b49ee4d ("serial: sc16is7xx: setup GPIO controller later in probe") 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 306ae512b38a..32d43d00a583 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1516,7 +1516,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 @@ -1542,8 +1542,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 Tue Jul 25 14:23:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 125677 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2522116vqg; Tue, 25 Jul 2023 07:47:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlE/xoIAsNm6WEcbpqTVrcLvXAFMZGhvmr5ldnXcIHbM/YWKbmDHHWB0bCo/oOFVADu3woku X-Received: by 2002:a05:6a20:734d:b0:134:a478:6061 with SMTP id v13-20020a056a20734d00b00134a4786061mr15010510pzc.26.1690296460353; Tue, 25 Jul 2023 07:47:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690296460; cv=none; d=google.com; s=arc-20160816; b=VxShX0aqnHO2Cv/qg95jZELo5//ri4VqzVrN+uuyl5IJnRj+8rxZgheuxFGEQqdltN QrYkDvbVZ1rdb3VfOU2E/eRI0Kbb2CygaDyk+ccrVfTjlLWS96ZPPV9T4O72VTho8OuS 2QebRJBLqYsXH6rfoiWvmjyXqjgpGeM/FwHxU+TtzTYqJPS7EzASN7/+1815GMatAF+P VS/TOz4cczjXF6WEThp0tSTFImlV7Dm5cVH8hQ7x1FE96ThIGOsSIeX1nbS7xhLyi3zB xJy/byWqSFJYeeGXGO6cNeKV6t1Q5YLirZa2go8vn8XUOkbk0ouT6s+xbOX0Jd2y+uRR zYTg== 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=eY2wZ9vhu1FfoaXy9aP9IFu/H9QUJ71zX/Q2ydr3vEg=; fh=6iQU/ZFDPB2EtbtrLPL1mq7BpEUKhm02utK8313rrOA=; b=EX+PFkxm8bXfgA6Pqngmr7SlPi8zEZ6tb3qOGXQKhJnptLvkp0iyx6lpsuSeLp+U7R eLMamMI8xSestA+YcXN5U2RFOoFXcGKz3DCfdl4DXyq7C5MIi8B1X93AguDJVEOdDcCV gCvJChyPDgOAVxzkSiZ3J70DmjGNTj88G2xvJQasnk3iO334bgXdbX3KTzrURLnTpMhn MvjhYAwj5J2rZenzZqWFV7tQ0tAX8aFzedGJk58pfN2A1O4PQ5ynqNnEcxADilpw4L0F QnHkXKP6zlVMw0i67nokL5DCQAi37QpKGE11Z/ExBmrPijBJppjsNNagphK9CRQDLRC5 eGbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hugovil.com header.s=x header.b=hsq9FVTc; 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 cw16-20020a056a00451000b00668230a86edsi11174767pfb.256.2023.07.25.07.47.26; Tue, 25 Jul 2023 07:47:40 -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=fail header.i=@hugovil.com header.s=x header.b=hsq9FVTc; 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 S233069AbjGYOYj (ORCPT + 99 others); Tue, 25 Jul 2023 10:24:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232741AbjGYOYN (ORCPT ); Tue, 25 Jul 2023 10:24:13 -0400 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FFDF2121; Tue, 25 Jul 2023 07:24:05 -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:References: In-Reply-To:Message-Id:Date:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=eY2wZ9vhu1FfoaXy9aP9IFu/H9QUJ71zX/Q2ydr3vEg=; b=hsq9FVTcFvgpQxJeXw5LBh9ePo Wi4J6mXqSi3fMiU7LxG/QwG6pQW08TEU+Icxo/KvQegvqaqA2RAL805Ub51j0SIXpTRUszmcL3zSY DZBwbrhKl56IBpFejo4nRc9Rxz2gv+m54KanjGWCjn9dJa5a1DZKK2eh5SMRBUcURhM8=; Received: from modemcable061.19-161-184.mc.videotron.ca ([184.161.19.61]:34256 helo=localhost.localdomain) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1qOIxA-0003Kt-Bb; Tue, 25 Jul 2023 10:23:56 -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, isaac.true@canonical.com, jesse.sung@canonical.com, l.perczak@camlintechnologies.com, tomasz.mon@camlingroup.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: Tue, 25 Jul 2023 10:23:36 -0400 Message-Id: <20230725142343.1724130-5-hugo@hugovil.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230725142343.1724130-1-hugo@hugovil.com> References: <20230725142343.1724130-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,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v9 04/10] serial: sc16is7xx: refactor GPIO controller registration 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: 1772404301182955014 X-GMAIL-MSGID: 1772404301182955014 From: Hugo Villeneuve In preparation for upcoming patch "fix regression with GPIO configuration". To facilitate review and make code more modular. Cc: # 6.1.x Signed-off-by: Hugo Villeneuve Reviewed-by: Lech Perczak Tested-by: Lech Perczak --- drivers/tty/serial/sc16is7xx.c | 40 ++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 32d43d00a583..5b0aeef9d534 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -332,6 +332,7 @@ struct sc16is7xx_one { struct sc16is7xx_port { const struct sc16is7xx_devtype *devtype; + struct device *dev; struct regmap *regmap; struct clk *clk; #ifdef CONFIG_GPIOLIB @@ -1349,6 +1350,25 @@ static int sc16is7xx_gpio_direction_output(struct gpio_chip *chip, return 0; } + +static int sc16is7xx_setup_gpio_chip(struct sc16is7xx_port *s) +{ + if (!s->devtype->nr_gpio) + return 0; + + s->gpio.owner = THIS_MODULE; + s->gpio.parent = s->dev; + s->gpio.label = dev_name(s->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 = s->devtype->nr_gpio; + s->gpio.can_sleep = 1; + + return gpiochip_add_data(&s->gpio, s); +} #endif static const struct serial_rs485 sc16is7xx_rs485_supported = { @@ -1412,6 +1432,7 @@ static int sc16is7xx_probe(struct device *dev, s->regmap = regmap; s->devtype = devtype; + s->dev = dev; dev_set_drvdata(dev, s); mutex_init(&s->efr_lock); @@ -1502,22 +1523,9 @@ static int sc16is7xx_probe(struct device *dev, } #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 /* From patchwork Tue Jul 25 14:23:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 125678 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2522762vqg; Tue, 25 Jul 2023 07:48:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlFiub67RZlouC0DF7YIj7G2xcSABZOrJAlFG9eXvtifkcdVX/E1USArHgacsjg2J5UiTnf3 X-Received: by 2002:a17:90b:374a:b0:267:a6c5:e60a with SMTP id ne10-20020a17090b374a00b00267a6c5e60amr8331625pjb.0.1690296532048; Tue, 25 Jul 2023 07:48:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690296532; cv=none; d=google.com; s=arc-20160816; b=y4Qbxnt1tjefrkDQoM0J9VS/BO0tf40QIrgps0cggtXVOW2tNR0sa/gipmU5rpkdM0 MNq6MJTuz3T7F7rpxtgX0u9tlPBAWRhvkMOSjz5OHq9zx9agzBcn1rh0/yHgegbCouFi HW54MQFy2kPTHjck+OxvjrDEopAZTHspukDySo7oinreFM/eokEs10chXGjg4rIhB4oB MtIFDxGGAzZi05d7eZqOekmR6OdLHQ41jnqqO4P1SD2+EspuRopoGGOTX+32W0aXegTw Z1cARV9Mq1XRb3QX1R3cKJ1sX4CeH5zkC3nISvqXdcDBgp1m3xcVL23zX3rXGwCjD6Ra LR+w== 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=88bALE9d0bOqGcbfrD4VTi+tiKURCEdOO8Uqldj+I/4=; b=m4m22Zgmc+aMeIjvSiZdCgu9/z14uXJNyST/Wi6+wdhUwbTQ3SHU/a48QB5V/s0SAY 6bDmjfGj9c3xO7TMsOTOuW+3cBdNK0EXe9vhRnOVC+TJHqvqVXrWLfqYp/N1ymm6q2pK +63LtNqR+jmnwqc5TgKlIIovyQajzRnmHQ6iufbDZFwTP3Qi0sQVBcwZNYWDNrcWRWVl 72xr/txgk9/k2k4mcvxGTsp631zUiUWISszSCISEzkXrLkIf69uOpJOLEelNJVmWNfb7 5cv0yI1xSdtbCKH/32Azfw1gazBozB9iAFTXTG0rzFWODBaQXbtlJa8Qci5SUuJToTvz UdsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hugovil.com header.s=x header.b=wFVtBv+h; 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 qe4-20020a17090b4f8400b00263ad259d9esi12752201pjb.0.2023.07.25.07.48.38; Tue, 25 Jul 2023 07:48:52 -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=fail header.i=@hugovil.com header.s=x header.b=wFVtBv+h; 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 S233129AbjGYOYl (ORCPT + 99 others); Tue, 25 Jul 2023 10:24:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232434AbjGYOYN (ORCPT ); Tue, 25 Jul 2023 10:24:13 -0400 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1262E26A2; Tue, 25 Jul 2023 07:24:05 -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:References: In-Reply-To:Message-Id:Date:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=SuJQI5JxUPzY+H5j7N6gL+Df0hCmvZbTgQvKUtpTEpg=; b=wFVtBv+hn8BNR5Xvw1O0BcIusj BmUhUEALl0odI4YnMG8edK+EvS3gWS9QB2bH4Scz7jCtEdoKX0P0Wb0i11f1+LYKCYkQTk56JDiOj SDsHInDR3d2AGH9P/6YnvRZGaFonQkKLhj19YG+7ejrXx92jCagIWWpfCLmWRd0fPXX4=; Received: from modemcable061.19-161-184.mc.videotron.ca ([184.161.19.61]:34256 helo=localhost.localdomain) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1qOIxB-0003Kt-TO; Tue, 25 Jul 2023 10:23:58 -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, isaac.true@canonical.com, jesse.sung@canonical.com, l.perczak@camlintechnologies.com, tomasz.mon@camlingroup.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: Tue, 25 Jul 2023 10:23:37 -0400 Message-Id: <20230725142343.1724130-6-hugo@hugovil.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230725142343.1724130-1-hugo@hugovil.com> References: <20230725142343.1724130-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,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v9 05/10] 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: 1772404376587706576 X-GMAIL-MSGID: 1772404376587706576 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 Tue Jul 25 14:23:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 125691 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2529871vqg; Tue, 25 Jul 2023 08:01:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlGBehtcF6jqYAszcmhXn9i7Xkc65ZgRtKJYXXz94s15fgtrZgiCL2iMmWkv0pBLGpL3KmlR X-Received: by 2002:a17:903:1c5:b0:1bb:bbda:70d9 with SMTP id e5-20020a17090301c500b001bbbbda70d9mr1886240plh.63.1690297276813; Tue, 25 Jul 2023 08:01:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690297276; cv=none; d=google.com; s=arc-20160816; b=SonzDwNEpZ14bdCLaGJjDQEU2kaSTGdBEHJMyEQqmrbp3zTDkvhbZ2CbPBDC/KEdDo qb4zN1W7KLTwYkBVDteV+SKO0sqvLr1VcBZLn7NulLGSAJhWdNkNm30sfi+6PyBkLAiS QrOQHRMe1P0lFnoRcZxPPxyNRfdpzxV18sClxuh14qCIHsPxpRiloFx7eySA9zNOCP/V M2bI1rC4Gt4RKOJxZ8gF7dRnhOe0lTy4okXgdylTjNQ8USUc5jyJ/OrFi5VTDr/7p9nL T2XmVvIia42a4Ejo7Ttm1pX6jeznANg4/Vf91H0TRben+xw1hHdPjn+4zzDzEkVgW523 1Q7w== 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=UeVhJ2XRP+zh00CrtzGgW2f/dBwi3qaORDlgNW3muqo=; fh=ImLjwwVEKRMnxM9gPMVDgUdsQW3IxBEjVWECr1ud2MU=; b=GWaLwVNwOekzOGxX8WicPkixmWWzQ3sO2NerzGidQnPgC+KEEWDE5zUr/mGmKv9556 BbU19RJIGAp9vqC7Cz7LiLQtdtRF45VA3g0NckS3LPnLYNLJkUh/FEoNVBuozU56y4N5 +b5wFqEpsgLNhAPcdT4Gzc0I+2Ul8xIwUROW9ogKmfV90bM+sevNiSnPztTHN8uEPh1q KRMqvgKtDokAMOpLElZ3tFm42s+90pPu68KgIW1PFbaWM5UBKL3y7lCGcyFNyt3Ketpp 9BRcvuUZZ5TjOa+E/PrBfie0PbdmGfzbmyMnXhojLwSn3jxvTS/cYXP+eeakYIob8Zqa 8cwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hugovil.com header.s=x header.b=uTqTCfZR; 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 ik12-20020a170902ab0c00b001bb6d74e6dasi1469879plb.321.2023.07.25.08.00.59; Tue, 25 Jul 2023 08:01:16 -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=fail header.i=@hugovil.com header.s=x header.b=uTqTCfZR; 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 S232620AbjGYOYw (ORCPT + 99 others); Tue, 25 Jul 2023 10:24:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232782AbjGYOYN (ORCPT ); Tue, 25 Jul 2023 10:24:13 -0400 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D9CC194; Tue, 25 Jul 2023 07:24:08 -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:References: In-Reply-To:Message-Id:Date:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=UeVhJ2XRP+zh00CrtzGgW2f/dBwi3qaORDlgNW3muqo=; b=uTqTCfZRXKU9ENEhUonRUdKfE9 wvl2lsqakD5wyjQJ+TuxyMTy2LJ1fcAXmIAIAsSylDE83mC80xrzed4xcZpBkt1BGGnmIoSKIKWME /fgsDI5J9CpZF2BeVRx44xk2Cqo6y2it/DNPTe9avuvFhugJWFT071aLddKGl7UgW94A=; Received: from modemcable061.19-161-184.mc.videotron.ca ([184.161.19.61]:34256 helo=localhost.localdomain) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1qOIxD-0003Kt-OV; Tue, 25 Jul 2023 10:24:01 -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, isaac.true@canonical.com, jesse.sung@canonical.com, l.perczak@camlintechnologies.com, tomasz.mon@camlingroup.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: Tue, 25 Jul 2023 10:23:38 -0400 Message-Id: <20230725142343.1724130-7-hugo@hugovil.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230725142343.1724130-1-hugo@hugovil.com> References: <20230725142343.1724130-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,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v9 06/10] 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: 1772405156980755655 X-GMAIL-MSGID: 1772405156980755655 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: # 6.1.x: 95982fad dt-bindings: sc16is7xx: Add property to change GPIO function Cc: # 6.1.x: 1584d572 serial: sc16is7xx: refactor GPIO controller registration Cc: # 6.1.x: ac2caa5a serial: sc16is7xx: remove obsolete out_thread label Cc: # 6.1.x: d90961ad serial: sc16is7xx: mark IOCONTROL register as volatile Cc: # 6.1.x: 6dae3bad serial: sc16is7xx: fix broken port 0 uart init Cc: # 6.1.x Signed-off-by: Hugo Villeneuve Reviewed-by: Andy Shevchenko Reviewed-by: Lech Perczak Tested-by: Lech Perczak --- drivers/tty/serial/sc16is7xx.c | 104 +++++++++++++++++++++++++++------ 1 file changed, 85 insertions(+), 19 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 5b0aeef9d534..bc0a288f258d 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) @@ -337,7 +338,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; @@ -448,35 +451,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) @@ -1351,14 +1349,43 @@ 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) { 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 = s->dev; s->gpio.label = dev_name(s->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; @@ -1371,6 +1398,47 @@ static int sc16is7xx_setup_gpio_chip(struct sc16is7xx_port *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]; + + count = device_property_count_u32(s->dev, + "nxp,modem-control-line-ports"); + if (count < 0 || count > ARRAY_SIZE(mctrl_port)) + return 0; + + ret = device_property_read_u32_array(s->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, @@ -1479,12 +1547,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); @@ -1522,6 +1584,10 @@ 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 ret = sc16is7xx_setup_gpio_chip(s); if (ret) @@ -1548,7 +1614,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 @@ -1572,7 +1638,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 Tue Jul 25 14:23:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 125666 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2511930vqg; Tue, 25 Jul 2023 07:31:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlFy/eBU7QoVCAT5J7HgGzTzb3U5ggrCzvESWVM1oXsvygqnzsYlfGdQlfGtkxHEjiCRKym7 X-Received: by 2002:a05:6358:7e04:b0:134:d282:92e9 with SMTP id o4-20020a0563587e0400b00134d28292e9mr9702730rwm.29.1690295461626; Tue, 25 Jul 2023 07:31:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690295461; cv=none; d=google.com; s=arc-20160816; b=P0K3/v5luML/y9twNDLnYNe2idQaQRDqDeg9LSELIp+dVe48tUmQduiR3dAGhoxrQb +ZVop6cF3KBDU5OrXmg4QZuulG+2UFQ+hlA1sZuPTGY1+U5D9AiieMvgL5Fhzx2UuM4H XYtM6cFBVxhYe8IBP9oB+nSv6CXVqc7rXU8MP/wMI9uQrD1OeNLbyZ7UztcJzt1MIIrQ fFXqGu6+D3EGtTkC2GNGJSmahhK9V9nkiYonyUJ+YjUz4xfIXfbhuKK15c5KaP/UtxUk JMyqC4X24V1yyPwKxiujmtDH0O7YnP7n4eokBqYUbURrx15wpfJCW7FmsPD/+94X/Td8 0USQ== 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=g0IqX97ybKTf/1b9IfX3fw+nZZPbUPYVvGhnzhAVJ8Y=; fh=6iQU/ZFDPB2EtbtrLPL1mq7BpEUKhm02utK8313rrOA=; b=JA0Twv/FrYy+nMs6UVj0ILEsfXsOmtlIyALqpR/i7gc6xlwG16Qye/O8n8kn7CLgXk fn/C2Hj5+ddGFuSrGInNvWOGVukoUVP09JZaU0WJS3MeE40w5baV+O67kAnOuEEo8+33 xiX621T7bxLMQSCfwkD7WQHKu1TI8CHa7TWvmJHUc6BcMNTceRZhv3C/rB5RH9gH57Is rfqq6klD/5xfLC9zautQ7SH2gD2Cnehgjuckzr3i1LM4DkoTWhNCyIMqKJ6vP64hQdSf VTbwzE1yaYj9laplD2DEszVdkR71tTbJf9aEX+Ob7KFAMyn1Qfki0HBLxVaecAhlwuYT RZmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hugovil.com header.s=x header.b=pVcCfG1A; 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 l19-20020a639853000000b0055aeedd94d3si11792774pgo.58.2023.07.25.07.30.47; Tue, 25 Jul 2023 07:31: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=fail header.i=@hugovil.com header.s=x header.b=pVcCfG1A; 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 S233168AbjGYOYp (ORCPT + 99 others); Tue, 25 Jul 2023 10:24:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232756AbjGYOYN (ORCPT ); Tue, 25 Jul 2023 10:24:13 -0400 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 584D31FD0; Tue, 25 Jul 2023 07:24:08 -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:References: In-Reply-To:Message-Id:Date:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=g0IqX97ybKTf/1b9IfX3fw+nZZPbUPYVvGhnzhAVJ8Y=; b=pVcCfG1AwTomWwXVPD7r4jxRGU B/5S7VPHwaXRCk/ZVjqQ2SNREx5scDcbFadla50G56j3/2qnYuN4di0p1Xd2QR/Gmmssgu2hN4+nQ TfhxAkQeRMdwp61/l82tavR3r5rve126tdTSxdeXh5aKK5vuVSIPcyRMYehKF1IFqDLw=; Received: from modemcable061.19-161-184.mc.videotron.ca ([184.161.19.61]:34256 helo=localhost.localdomain) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1qOIxF-0003Kt-VE; Tue, 25 Jul 2023 10:24:02 -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, isaac.true@canonical.com, jesse.sung@canonical.com, l.perczak@camlintechnologies.com, tomasz.mon@camlingroup.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: Tue, 25 Jul 2023 10:23:39 -0400 Message-Id: <20230725142343.1724130-8-hugo@hugovil.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230725142343.1724130-1-hugo@hugovil.com> References: <20230725142343.1724130-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,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v9 07/10] 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: 1772403254157253097 X-GMAIL-MSGID: 1772403254157253097 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 bc0a288f258d..07ae889db296 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 Tue Jul 25 14:23:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 125671 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2512220vqg; Tue, 25 Jul 2023 07:31:26 -0700 (PDT) X-Google-Smtp-Source: APBJJlE/rWscDoKxkKYOzjBjCIW2qeF6ok00L6vNX8fhXZImkkwg0k7KvG5o6VdME/ZlfIyw4ftp X-Received: by 2002:a05:6402:10cb:b0:51e:eaf:4fea with SMTP id p11-20020a05640210cb00b0051e0eaf4feamr9749869edu.35.1690295486486; Tue, 25 Jul 2023 07:31:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690295486; cv=none; d=google.com; s=arc-20160816; b=hQTOjsCKZz4P6Z+RguijeVw0M8l5QYfCG0bnbH658xAmyqisnrChK+bBAQUjJMo3YR kZzW6NpMADKSnRRb4vuJsrKYTUe7NTMQFn9W1NuMVZaGMZv6VO8h5WdSXr8FUghr5r8L jnmJtm+PNItIms5w1L43YpPbOLvhZ7JtBzw4mD1GFA00wSFjrWkNpNZd3JfEurQ/4P88 h9fAdfGpt9JAfQ/CpfNGJjwnBAV1OSxrh+iS6yq+475BLtfnNOds5sDjLTwoe2/zBRPr KvOrslnZXPnhMeqQUZ3LCi5BO1TwpUVzW9WY8rXdZNjI1+I+ITChepew6IXb7bhSz/Z0 HYLg== 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=CGELaf9iHFZKKMFhqnOQKxdW+WJUyHw8sFM+8NdBi0c=; fh=1Iv8rkV350k4Rox/M/fzNPi2ksHqavOTDeUuTVBfmsU=; b=Z1p9pFkW71Rx09megHtGov3A5Tpi90/lvie5XrnfDNt95Tn1PFhjlRw8lW+3R2x8Te cVEwqinYbxYPBWDvZ28f5ZiwLeeqds27yJzzykW5eJbDI+1MhLsOUCMrVHUeOrwbIxu7 sG5O7XbNdAx3RNh6zBVaZBwlIQzf+wz/iyWyf+ZII3coMOiAy1QFG3MI0JBP05bcYY21 dJC6Xa4k3CrNeB+0WFLnuIZpPshW18nu+7Qjq1mcOhWUy91HUQsS4wF+xiSRMIq2BHen owvSLeTafsltxRX7xN04tgF1K319zHlHej8tggAUXbaKbTSCJcy4elG6J/ua9SwG8+oq xaFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hugovil.com header.s=x header.b=k3Y0QYXF; 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 y2-20020aa7ccc2000000b0051e0f0fef4fsi8747800edt.555.2023.07.25.07.31.02; Tue, 25 Jul 2023 07:31:26 -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=fail header.i=@hugovil.com header.s=x header.b=k3Y0QYXF; 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 S230144AbjGYOYt (ORCPT + 99 others); Tue, 25 Jul 2023 10:24:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232824AbjGYOYO (ORCPT ); Tue, 25 Jul 2023 10:24:14 -0400 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6428212B; Tue, 25 Jul 2023 07:24:09 -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:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=CGELaf9iHFZKKMFhqnOQKxdW+WJUyHw8sFM+8NdBi0c=; b=k3Y0QYXFr6m+uP/QmA4SuX8AcH 6g57aitu99VfNSU0O+J3USOREGNUndU4iH6zF9axURfnunLhkg0C2ZEKFa1yaqtATGi5qiWZ+xmPu w1u/W5OzE5tW6vvNOrEAHnH+8pSVknn7aarAarhJRhIfOiXpSSCmz1ssssqKrl3Uis6s=; Received: from modemcable061.19-161-184.mc.videotron.ca ([184.161.19.61]:34256 helo=localhost.localdomain) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1qOIxH-0003Kt-Q9; Tue, 25 Jul 2023 10:24:04 -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, isaac.true@canonical.com, jesse.sung@canonical.com, l.perczak@camlintechnologies.com, tomasz.mon@camlingroup.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: Tue, 25 Jul 2023 10:23:40 -0400 Message-Id: <20230725142343.1724130-9-hugo@hugovil.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230725142343.1724130-1-hugo@hugovil.com> References: <20230725142343.1724130-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,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v9 08/10] serial: sc16is7xx: add call to get rs485 DT flags and 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: 1772403280460197893 X-GMAIL-MSGID: 1772403280460197893 From: Hugo Villeneuve Add call to uart_get_rs485_mode() to probe for RS485 flags and properties from device tree. 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 07ae889db296..49213be60baf 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1549,6 +1549,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 */ From patchwork Tue Jul 25 14:23:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 125667 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2511989vqg; Tue, 25 Jul 2023 07:31:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlHEW3CAyTrydfUFCZv84S/ALjRZYFQ78uVMlk/k7Aq9Vf2z2zBg4JUROQLySt2Zd7OAIS3w X-Received: by 2002:a05:6a20:430a:b0:133:8784:15f7 with SMTP id h10-20020a056a20430a00b00133878415f7mr3493617pzk.14.1690295466872; Tue, 25 Jul 2023 07:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690295466; cv=none; d=google.com; s=arc-20160816; b=HxrNozF/r9GqgfU4lv11N8+VcjSf/UzYAC93qUQr2HK9VsiV4fVqTrqwRRzo5ZgZXb s7lgp8D7mdoN2tcc/FyXxVma90ii7a7VBmnEOpv4QZZNwFMJidWPfEf8FoCU83xAi1u3 l/kChkXdO9IDuaB+6x5gh0cMYixje8b9KDCaXPdby/EYwAxh6xwdApnqmymWXcHCT4Lk 39AUl7V2NEKxkPwI6z3C/CxBtNvqF6SfzNeUCn2xGfAQ67RSq3bdpGLzuBA9l4F7bDrc om99whCYxyuLlFDWHKawj1e3VV12YPzn7uT4uEO5uJNWw/05rB2XyB9VO6cu8w6Oiwcz LXQw== 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=hJjkp3frl86bgh+fvqfTcebGX6hsjlqpFUYax05mOtQ=; fh=WkAAKP2XDLTpD1NV5kL3+zXj4aEvohtt5uFwZPTRCiE=; b=GYgdWeR0u7KitEP1cvVA45lMI/DmQP52gH6kjiKC7PAjwP1i0ZpxeD+tB4kpJNCPOH jqeYB4pv9EMCth6K7e1uhjqiaf60QqUJ2Rd/8zDQTDhjWhRqKoUv6iWX7patSEA/TGYD CoXILmcx2R9YBC0CLJb+6fSrKVdaT4RT/Bphz0E1jMk/1qGsIcT5MRd3XOWlepYhM5dQ Z4fNq/X5kig5EyBRnI3iEMEw7tSUZcIv1HvEMNLA2PGTzHAxsPQR5CVM/Zvbd/aLz5fb q7KAB+VDPtFuOltTAcTHTzj0XS7EL3EiMTlbVxH7r6dip3Jbrc/m7SQthQtgE4c7cpdw kh7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hugovil.com header.s=x header.b=dfUCdmeL; 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 j37-20020a634a65000000b00563dc438e52si209307pgl.518.2023.07.25.07.30.52; Tue, 25 Jul 2023 07:31:06 -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=fail header.i=@hugovil.com header.s=x header.b=dfUCdmeL; 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 S230116AbjGYOYz (ORCPT + 99 others); Tue, 25 Jul 2023 10:24:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232920AbjGYOYQ (ORCPT ); Tue, 25 Jul 2023 10:24:16 -0400 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 999572137; Tue, 25 Jul 2023 07:24:12 -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:References: In-Reply-To:Message-Id:Date:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=hJjkp3frl86bgh+fvqfTcebGX6hsjlqpFUYax05mOtQ=; b=dfUCdmeL2XJPxphgf3hkO0tu2i MxQ8dn+8avpS1q+u1doFYd7E7+w74G9jdH7+iPV4nad18XA/WnqtbxWiEg5cB0xyrHYBxUvhb0XhH iPnbWWYXtWsog4CYwPSnQtlkSfOGYTGmZ+Zn4cRAbAB8q+c9QtCNZbVbxm07B1Au4EUw=; Received: from modemcable061.19-161-184.mc.videotron.ca ([184.161.19.61]:34256 helo=localhost.localdomain) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1qOIxJ-0003Kt-J7; Tue, 25 Jul 2023 10:24:06 -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, isaac.true@canonical.com, jesse.sung@canonical.com, l.perczak@camlintechnologies.com, tomasz.mon@camlingroup.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 Date: Tue, 25 Jul 2023 10:23:41 -0400 Message-Id: <20230725142343.1724130-10-hugo@hugovil.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230725142343.1724130-1-hugo@hugovil.com> References: <20230725142343.1724130-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,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v9 09/10] serial: sc16is7xx: add post reset delay 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: 1772403259409006204 X-GMAIL-MSGID: 1772403259409006204 From: Hugo Villeneuve Make sure we wait at least 3us before initiating communication with the device after reset. Signed-off-by: Hugo Villeneuve 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 49213be60baf..718e982e1efe 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1526,6 +1526,12 @@ static int sc16is7xx_probe(struct device *dev, regmap_write(s->regmap, SC16IS7XX_IOCONTROL_REG << SC16IS7XX_REG_SHIFT, SC16IS7XX_IOCONTROL_SRESET_BIT); + /* + * After reset, the host must wait at least 3us before initializing a + * communication with the device. + */ + usleep_range(5, 10); + for (i = 0; i < devtype->nr_uart; ++i) { s->p[i].line = i; /* Initialize port data */ From patchwork Tue Jul 25 14:23:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 125668 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2512007vqg; Tue, 25 Jul 2023 07:31:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlHN+URybFd3rwXnhGnr+qrQpOQM8xjw4zPGvZXDYsuj5ZJJF/NRTd8zqGRV3qsx+U6IuwlO X-Received: by 2002:a17:902:e841:b0:1b6:b44d:a5b6 with SMTP id t1-20020a170902e84100b001b6b44da5b6mr12582488plg.14.1690295468923; Tue, 25 Jul 2023 07:31:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690295468; cv=none; d=google.com; s=arc-20160816; b=IA8q52udw7Lz3V038xh+8gPaJM0RGocBObK/FEzk04eQ8g+uYr9DzMQwlNu1PIcAf9 5dvoz+WWEgoz7DPWgokPDRqhRebGtpRpgmenPEgooRVrtz/Bj4Z+rzpbKi6nhwNVX0YU E9l8PuU0IsNiAVwg23RVBZ5XNgJDiE0VaWbjF3RhS0fu+QAx4ZNYieWE1mXFPoA4TBhZ /Oy4y/O8z39uttIwHeOpyGWf0hXecQoC47rf5GiFlgb2ltNItwIol8ir98mUhNTIa2yf e+xC27PNbsUQ7f0bQG5is3r0QOrx6fHnqHC+X4skr+U+/63pBRXOuQsPPk9pMrUmjbN+ oQow== 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=9yfW8mHRhmt1BZssK5Nqf/xXTWUgDfzvBAsuQ90MFC8=; fh=WkAAKP2XDLTpD1NV5kL3+zXj4aEvohtt5uFwZPTRCiE=; b=mdGVC9Tf0sXsDdkqQHKYjTHnT3puAZMNQPVzvxqN5ZzpAevBluD75oalkSUl+fHmY0 q61+/UZclyI6XCDVs/C0S47A1Mcw07k04aI0ARHqewhfNWbVEatcHAk4HPYyj5h41req vytkYE1eRBetv2YSRc9OSVZLxUynuSwRV5SIo0L8mHjPBXJnvB5qAXYkCQPCYO+mLRuG xCELFIvNI2W6q1Ydm499DjkCHYX2090GzY0CLNeii/686C2CRSjz/rWR5mP/0DskmG5Y NAxfin7CBbVFingDJZee+WoXx6y3QIUTgGRUsfE2bgRyPbXobLVwrVniVeBfYBigmlXX h8fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hugovil.com header.s=x header.b=IFBDaMMu; 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 x1-20020a170902a38100b001b8a70d11e4si6444299pla.529.2023.07.25.07.30.54; Tue, 25 Jul 2023 07:31:08 -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=fail header.i=@hugovil.com header.s=x header.b=IFBDaMMu; 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 S232947AbjGYOY7 (ORCPT + 99 others); Tue, 25 Jul 2023 10:24:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232952AbjGYOY0 (ORCPT ); Tue, 25 Jul 2023 10:24:26 -0400 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77B6D2139; Tue, 25 Jul 2023 07:24:14 -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:References: In-Reply-To:Message-Id:Date:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=9yfW8mHRhmt1BZssK5Nqf/xXTWUgDfzvBAsuQ90MFC8=; b=IFBDaMMucxSRKRjkIyy3YkLhf3 m1IAPNzI/UCH9VMXqoal+9Yas8fzGkWOdArkpv9Ey/x6w/gvkR9JvnOTeQJ3E0FvyVuEiNtiAR5t4 8b7WrioCXmlp9OrM/2VZB868qFEmNASq1AJ5S8x+ZQEFYT8m1tQWnclHXO5BpD914LFk=; Received: from modemcable061.19-161-184.mc.videotron.ca ([184.161.19.61]:34256 helo=localhost.localdomain) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1qOIxM-0003Kt-6C; Tue, 25 Jul 2023 10:24: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, isaac.true@canonical.com, jesse.sung@canonical.com, l.perczak@camlintechnologies.com, tomasz.mon@camlingroup.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 Date: Tue, 25 Jul 2023 10:23:42 -0400 Message-Id: <20230725142343.1724130-11-hugo@hugovil.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230725142343.1724130-1-hugo@hugovil.com> References: <20230725142343.1724130-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,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v9 10/10] serial: sc16is7xx: improve comments about variants 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: 1772403261293586531 X-GMAIL-MSGID: 1772403261293586531 From: Hugo Villeneuve Replace 740/750/760 with generic terms like 74x/75x/76x to account for variants like 741, 752 and 762. Signed-off-by: Hugo Villeneuve Reviewed-by: Lech Perczak --- drivers/tty/serial/sc16is7xx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 718e982e1efe..d6851360ef7d 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -223,7 +223,7 @@ * trigger levels. Trigger levels from 4 characters to 60 characters are * available with a granularity of four. * - * When the trigger level setting in TLR is zero, the SC16IS740/750/760 uses the + * When the trigger level setting in TLR is zero, the SC16IS74x/75x/76x uses the * trigger level setting defined in FCR. If TLR has non-zero trigger level value * the trigger level defined in FCR is discarded. This applies to both transmit * FIFO and receive FIFO trigger level setting. @@ -234,7 +234,7 @@ #define SC16IS7XX_TLR_TX_TRIGGER(words) ((((words) / 4) & 0x0f) << 0) #define SC16IS7XX_TLR_RX_TRIGGER(words) ((((words) / 4) & 0x0f) << 4) -/* IOControl register bits (Only 750/760) */ +/* IOControl register bits (Only 75x/76x) */ #define SC16IS7XX_IOCONTROL_LATCH_BIT (1 << 0) /* Enable input latching */ #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 */ @@ -249,9 +249,9 @@ #define SC16IS7XX_EFCR_RTS_INVERT_BIT (1 << 5) /* RTS output inversion */ #define SC16IS7XX_EFCR_IRDA_MODE_BIT (1 << 7) /* IrDA mode * 0 = rate upto 115.2 kbit/s - * - Only 750/760 + * - Only 75x/76x * 1 = rate upto 1.152 Mbit/s - * - Only 760 + * - Only 76x */ /* EFR register bits */