Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp1161885rdf; Wed, 22 Nov 2023 07:11:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFR5dsQ+sQkXpyfPus02Co5iDM2irnKpsdfj389Jc/rPji2R8KpImWsTpQIgoVRetjivoRp X-Received: by 2002:a17:90a:ce8b:b0:27d:47b4:785f with SMTP id g11-20020a17090ace8b00b0027d47b4785fmr2764930pju.18.1700665902509; Wed, 22 Nov 2023 07:11:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700665902; cv=none; d=google.com; s=arc-20160816; b=IiTXQbXyL3Q+uyfLoNmswXflVlXWizgucxo3O0kHocWclz7rKUa2GKAL7K7UTt9zEO RPVDXu0sL1+S60/udsk7BDs8gWeKkKzCL5dslYYhLHjwmVEaQ4s7UTIHkEqXo5zZoReL x/cKPgtIYka+H+N2+pPICN8cAr750DQubgxz5a0tB78FuP2gQcVyg/y/tNGnxx4bTY08 8C9lTsfdEvp1JY0ytVxOf5hPClJYZk2+FWmYsmSHIFnWQDvVIRQgxD2ijmqRhorZK0dc 2WbXn1YkNKsgy1AAhg26C803HEA4C49C+TWHAVprpluP+RL96SIlwfr9w6syxaUVY3gA JO0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=zkBOPHjq/waMNIwBKpltt7ozIijZBnuRctMB7FkwgcQ=; fh=/DGLZnUOLhv8dFd5i3dtO83HKOgSfcuNLqs/dvXO/QA=; b=TnKE7mh/lRjbnvBBeOd/f6PNwGYLM4m1dM0gaR4spc1nEqDS8a6hy89JtCunw9gPsY a4wmOXCgwJBZQDBzGFAOOVgpVmKmNzMeMqgL+84aBESUI9Y2xad2CsTz1R0U3qNPWtrM lW+GFVJxXQnD0T+yOGlYjoq2cApFrE2072+3onpOALobix+HaUibOjxhDw05ggHSws76 0t28ywZJDn27DSLm+tiZWafSzEikj7bAThxaiFx+tTWtoiGghngQyizYJxAzSRBQ7e9v qjHNEv4oimz88Ug3Xty/I2leRcdmivWHkPz/qjCD75EzKMfUYomiNupxsABdHix4HEb+ y+4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id c3-20020a17090abf0300b0027cde38c731si1657325pjs.17.2023.11.22.07.11.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 07:11:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 9C66E807E88C; Wed, 22 Nov 2023 07:10:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344343AbjKVPKP (ORCPT + 99 others); Wed, 22 Nov 2023 10:10:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344329AbjKVPKM (ORCPT ); Wed, 22 Nov 2023 10:10:12 -0500 Received: from bmailout1.hostsharing.net (bmailout1.hostsharing.net [IPv6:2a01:37:1000::53df:5f64:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BBC792; Wed, 22 Nov 2023 07:10:08 -0800 (PST) Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "*.hostsharing.net", Issuer "RapidSSL Global TLS RSA4096 SHA256 2022 CA1" (verified OK)) by bmailout1.hostsharing.net (Postfix) with ESMTPS id BEDFA30000CF4; Wed, 22 Nov 2023 16:10:06 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id B3E17382C1; Wed, 22 Nov 2023 16:10:06 +0100 (CET) Date: Wed, 22 Nov 2023 16:10:06 +0100 From: Lukas Wunner To: Rasmus Villemoes Cc: Greg Kroah-Hartman , Jiri Slaby , devicetree@vger.kernel.org, Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Lino Sanfilippo , Ilpo =?iso-8859-1?Q?J=E4rvinen?= Subject: Re: [PATCH 2/2] serial: core: implement support for rs485-mux-gpios Message-ID: <20231122151006.GB18949@wunner.de> References: <20231120151056.148450-1-linux@rasmusvillemoes.dk> <20231120151056.148450-3-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231120151056.148450-3-linux@rasmusvillemoes.dk> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 22 Nov 2023 07:10:31 -0800 (PST) On Mon, Nov 20, 2023 at 04:10:55PM +0100, Rasmus Villemoes wrote: > Add code for handling a rs485-mux-gpio specified in device tree. Hm, that's a bit terse as a commit message. > @@ -1457,6 +1466,14 @@ static int uart_set_rs485_config(struct tty_struct *tty, struct uart_port *port, > return ret; > uart_sanitize_serial_rs485(port, &rs485); > uart_set_rs485_termination(port, &rs485); > + /* > + * To avoid glitches on the transmit enable pin, the mux must > + * be set before calling the driver's ->rs485_config when > + * disabling rs485 mode, but after when enabling rs485 > + * mode. > + */ > + if (!(rs485.flags & SER_RS485_ENABLED)) > + uart_set_rs485_mux(port, &rs485); Can it happen that the UART's FIFO contains characters such that suddenly switching the mux causes some of them to appear on the RS-485 transceiver and some on the RS-232 driver? Shouldn't we wait for the FIFO to drain before making the switch? I think that would be closer to the behavior expected by user space. > --- a/include/linux/serial_core.h > +++ b/include/linux/serial_core.h > @@ -584,6 +584,7 @@ struct uart_port { > struct serial_rs485 rs485_supported; /* Supported mask for serial_rs485 */ > struct gpio_desc *rs485_term_gpio; /* enable RS485 bus termination */ > struct gpio_desc *rs485_rx_during_tx_gpio; /* Output GPIO that sets the state of RS485 RX during TX */ > + struct gpio_desc *rs485_mux_gpio; /* gpio for selecting RS485 mode */ Again, the code comment isn't really helpful as it doesn't add a whole lot of information to the variable name "rs485_mux_gpio". How about: "select between RS-232 and RS-485 transceiver" ? (I realize I made a typo in my previous e-mail about the DT-binding, sorry about that: s/connect/connected/) Thanks, Lukas