Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3535924pxp; Tue, 8 Mar 2022 16:53:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJwA7svG9/Xsk/BD+yjt+H7MGg1ZLs1QvwohU5B6eK+yQuERTvWHY0FsEx/ruX4XFLSSb4N/ X-Received: by 2002:a17:902:d4c6:b0:151:d21c:7eb7 with SMTP id o6-20020a170902d4c600b00151d21c7eb7mr18729577plg.148.1646787199686; Tue, 08 Mar 2022 16:53:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646787199; cv=none; d=google.com; s=arc-20160816; b=LCgsQH+Tqhiw2AaheAzU573uZR3LCnMgjE04XrpnRbjWoauwC4GOHd5lB5v4OmVJ9s OwHBRFFKCPUHvsXTznT+z1UitZwkGOL4h2eLJmSW1oqlWCSjG2RAH40/9rHbvQIQ0KcF tF0eKrt/YRROEUJGtRzATbItkmDpRSSrPS2OlylGMRwPX4wT55KGbRpsjHnZCDLVagkP AzJpcZqsD9JJhoDWwPRTXxeqUuEYgEGbF9jqcrtS6mmUFVm3yFRexep3MY46UBTjJU/J LvBTcypJAkRuCJ6SX0q21sa42w9nlE2gqrAkgqQN7Yh4IbghEXmRaGwNS0gZkCScYsFc lQoQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=kw0kT5kEwzXZNEA/f8dA0TA/sECtpoYg+DyXZ6gkc/0=; b=0g7RZ7I6fWuF0O2MD+r7si2ZVVZARPzHqEaxWJXXU7UGHEn2yNBmWGCI5ssjJXgn7Q 5ZvSvH1YYqbeFLvKqMtaDiQQ0NTwEsK4m+rGycteBDx6v877lGuSknnOU4NmLTwfZTu5 CKLxGddBasdrf3HFI5P3C0HWKW84kkeI2q3CHrxP2hvpTp3g6y6qPLWxQDoe9lcF7DYM lbvDZUSJptHdLR6AgKOPuzMnljkYeJ5PvyBWQOC2+vKas8rQaBE6hkjTklSNDjxuezGy h48X1n+FOCXhEEDK40EWb5r9/FzwJ3TY3pLxjc3r6ntWaOwq0Bud5Fy++mVl9zd+6Vym ZqUg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s20-20020a056a00195400b004e1b7d97a51si397206pfk.140.2022.03.08.16.53.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 16:53:19 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0EEB2164D3B; Tue, 8 Mar 2022 16:08:37 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347620AbiCHOvl (ORCPT + 99 others); Tue, 8 Mar 2022 09:51:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234154AbiCHOvk (ORCPT ); Tue, 8 Mar 2022 09:51:40 -0500 Received: from bmailout1.hostsharing.net (bmailout1.hostsharing.net [IPv6:2a01:37:1000::53df:5f64:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74E2A3C733; Tue, 8 Mar 2022 06:50:43 -0800 (PST) Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.hostsharing.net", Issuer "RapidSSL TLS DV RSA Mixed SHA256 2020 CA-1" (verified OK)) by bmailout1.hostsharing.net (Postfix) with ESMTPS id 1E8B730057E8D; Tue, 8 Mar 2022 15:50:42 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 11FC547A006; Tue, 8 Mar 2022 15:50:42 +0100 (CET) Date: Tue, 8 Mar 2022 15:50:42 +0100 From: Lukas Wunner To: Ilpo =?iso-8859-1?Q?J=E4rvinen?= Cc: Andy Shevchenko , "open list:SERIAL DRIVERS" , Jiri Slaby , Greg Kroah-Hartman , Linux Kernel Mailing List , Johan Hovold , Heikki Krogerus , Raymond Tan , Heiko Stuebner Subject: Re: [PATCH 1/7] serial: 8250_dwlib: RS485 HW half duplex support Message-ID: <20220308145042.GA20520@wunner.de> References: <20220302095606.14818-1-ilpo.jarvinen@linux.intel.com> <20220302095606.14818-2-ilpo.jarvinen@linux.intel.com> <20220306184857.GA19394@wunner.de> <20220307191854.GA27748@wunner.de> <6931d6ad-7520-b585-a8ba-35349e730bb@linux.intel.com> <20220308122220.GA24694@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 08, 2022 at 02:59:59PM +0200, Ilpo J?rvinen wrote: > On Tue, 8 Mar 2022, Lukas Wunner wrote: > > On Tue, Mar 08, 2022 at 02:16:56PM +0200, Ilpo J?rvinen wrote: > > > The SoC also has a pin to select between RS485 and RS232. With a combo > > > transceiver, TCR-based heuristic just runs into the same problems as the > > > version-based one did. > > > > I thought this was about detecting whether hardware-assisted DE assertion > > may be used (versus software-controlled), not about whether to enable > > RS-485 mode. Right? > > HW DE assertion only works when RS485 mode is enabled so I don't see how > these questions could be easily decoupled like that. That's assuming with > "software-controlled" you mean RTS(RS232)+em485? Right, that's what I meant. Enabling RS-485 mode is only supposed to happen upon a TIOCSRS485 ioctl or if the "linux,rs485-enabled-at-boot-time" property is present. We don't need to second-guess the user's decision to enable RS-485 mode. If that's what they've asked for, then we can and should assume that an RS-485 transceiver is attached. Of course, if hardware-assisted DE assertion requires a particular pinmux state, we could double-check whether that pinmux state is set. If the RTS/DE pin is not muxed as a DE pin but rather as an RTS pin, one option would be to fall back to software-controlled RTS assertion. A warning message may be warranted in that case. Whether hardware-assisted DE assertion is supported by the chip can not only be detected by checking for the POR 0x6 value in the TCR register: You can alternatively write a non-zero value to any of the RS-485 registers, then check if reading the register back returns a non-zero value (RE_EN is probably a good candidate). That approach is more robust than relying on the POR value 0x6 in TCR because you never know if boot firmware fiddled with the registers before passing control to the kernel. Thanks, Lukas