Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp146860rdb; Wed, 18 Oct 2023 23:06:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEe4Y10UlmpOVFVKwKFlaX19MCfhkxCp7YEigLyhUZmDSg5+L1hDq/eqsJjB+8oLnkAeScq X-Received: by 2002:a05:6a20:b926:b0:17a:de38:7416 with SMTP id fe38-20020a056a20b92600b0017ade387416mr939700pzb.61.1697695616005; Wed, 18 Oct 2023 23:06:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697695615; cv=none; d=google.com; s=arc-20160816; b=OLmLZg/+Nv4SaC/JaSGMNpPmYDfrbAP3eyIQyNGKVfGrbUcWpm+Ohl2IWPZGILmHLi uZqgH0Gq+w4PZIzjx3uvbwtEyG45MRQ2p9Z3ZugaI0RulKvrxibwUz5gouIo13z5gzg7 PEvRyQCoUlZNOtWxFk4Pg8FWo26iLxvUkvUtRBpa78dL+Layd5J/6V9CQ0HiA7xzkXDJ v82PHgIDGciieYoUp95O1j3Qq11/hjfsTYSvsUmHo8kjW0TIPggn8E1rA6KOkR5SPdl4 SbwatAbyPt5Zw0596q1Q27PqafgPrV0AutDv/J/M311XD2DFNstjhUDi3msJ+thtXEbK wGDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id; bh=XdiAvv6/GMuTeUsasZL+eYHRNQDVY32PG9JD+9V4JpE=; fh=Dohtn8zJcMCIEnkl+6aNEtJyXLcnoEqLwY28K3Wa0As=; b=fQc0MFl3H0YAgClStEkjw/O6XXasRD5xztBN3tuXP1+1Mb9zwtVMJPmXRC3BHaQNrK g9NPvVlGbtl6v7tJkvrEZlZH3TP1+wKauOYmwe/IpTJq1ahhXgs94WHqEQEPxnDoIy4s PQeNPnbpqp1L/hLExXCx0I/FZRGi7VPF3OwxmO7PPaexsIYNsWAT71G0MBPYCQw12uHv bORH01sdXqvFcuOfBzAwTOA2I/tI9sQVEIeGEskStqrxDo5+SfIZYDp/HzCXou2Ys6NV AQBnh9ysCpB4y8zLJtkG1JqorOrSyq0Vu1xZFvP/KTbCIA7NrQKnFKFvOt++HcSgigrb hblg== 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:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id l4-20020a170902f68400b001c9fe071f2bsi1643165plg.8.2023.10.18.23.06.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 23:06:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id A0B0E822D564; Wed, 18 Oct 2023 23:06:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232123AbjJSGGo (ORCPT + 99 others); Thu, 19 Oct 2023 02:06:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232076AbjJSGGn (ORCPT ); Thu, 19 Oct 2023 02:06:43 -0400 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E660116; Wed, 18 Oct 2023 23:06:41 -0700 (PDT) Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-40675f06f1fso1910395e9.1; Wed, 18 Oct 2023 23:06:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697695600; x=1698300400; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XdiAvv6/GMuTeUsasZL+eYHRNQDVY32PG9JD+9V4JpE=; b=QolD7BAHCDacCmnkUybPnty0O6ZRfFUSBaXVmzRohafHhtLe5zysYVjQ4UZT7M2Qfo r0ag1PoqxwaiIqN1JUoEvi3QKi1GJWyVedWNCZrImmyqjbKAT/yI+0LXzmO6to6C1Dy1 EGdAH/oDikMGjmwlbsH55HH0tj9JZf2tAlLc80LneK/PgyLaff1ZxYtVgk+5dJWv7rso X2lNjkawkZYmdGArbFL4MX5l7f8yV1NHrIcLUBQ5RAcQ9UI2vHSc0uIh1frZFs8E6FiT xdHLqgSpZNkAi5XF6Lmv/Fz5gbOQZXN34VO0ho8I3d3qVhnyEky/qWBwYE4KwPF5aYwp QuBg== X-Gm-Message-State: AOJu0YzhbP70S0Dx9PHvyZ72vMdwjPQxfrf1iTWEfDtlBYP9bXEs/UPo ZNfX9drBNzl5yZDszBjn6nY= X-Received: by 2002:a05:600c:1e20:b0:407:5de2:ea4d with SMTP id ay32-20020a05600c1e2000b004075de2ea4dmr705836wmb.13.1697695599524; Wed, 18 Oct 2023 23:06:39 -0700 (PDT) Received: from ?IPV6:2a0b:e7c0:0:107::aaaa:59? ([2a0b:e7c0:0:107::aaaa:59]) by smtp.gmail.com with ESMTPSA id j20-20020a05600c191400b0040641a9d49bsm3521225wmq.17.2023.10.18.23.06.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Oct 2023 23:06:39 -0700 (PDT) Message-ID: <3332a86c-1a1d-4b78-bbfa-8ac3e2e642a1@kernel.org> Date: Thu, 19 Oct 2023 08:06:38 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 6/6] tty: serial: 8250: Add support for MOXA PCIe boards to switch interface between RS422/RS485 Content-Language: en-US To: Crescent CY Hsieh , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org References: <20231018091739.10125-1-crescentcy.hsieh@moxa.com> <20231018091739.10125-7-crescentcy.hsieh@moxa.com> From: Jiri Slaby Autocrypt: addr=jirislaby@kernel.org; keydata= xsFNBE6S54YBEACzzjLwDUbU5elY4GTg/NdotjA0jyyJtYI86wdKraekbNE0bC4zV+ryvH4j rrcDwGs6tFVrAHvdHeIdI07s1iIx5R/ndcHwt4fvI8CL5PzPmn5J+h0WERR5rFprRh6axhOk rSD5CwQl19fm4AJCS6A9GJtOoiLpWn2/IbogPc71jQVrupZYYx51rAaHZ0D2KYK/uhfc6neJ i0WqPlbtIlIrpvWxckucNu6ZwXjFY0f3qIRg3Vqh5QxPkojGsq9tXVFVLEkSVz6FoqCHrUTx wr+aw6qqQVgvT/McQtsI0S66uIkQjzPUrgAEtWUv76rM4ekqL9stHyvTGw0Fjsualwb0Gwdx ReTZzMgheAyoy/umIOKrSEpWouVoBt5FFSZUyjuDdlPPYyPav+hpI6ggmCTld3u2hyiHji2H cDpcLM2LMhlHBipu80s9anNeZhCANDhbC5E+NZmuwgzHBcan8WC7xsPXPaiZSIm7TKaVoOcL 9tE5aN3jQmIlrT7ZUX52Ff/hSdx/JKDP3YMNtt4B0cH6ejIjtqTd+Ge8sSttsnNM0CQUkXps w98jwz+Lxw/bKMr3NSnnFpUZaxwji3BC9vYyxKMAwNelBCHEgS/OAa3EJoTfuYOK6wT6nadm YqYj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ExmlO8JljuOGeXYh6ZkIEyzqzffzBLXZCujlYQ DFXpyMNVJ2ZwPmX2mWEoYuaBU0JN7wM+/zWgOf2zRwhEuD3A2cO2PxoiIfyUEfB9SSmffaK/ S4xXoB6wvGENZ85Hg37C7WDNdaAt6Xh2uQIly5grkgvWppkNy4ZHxE+jeNsU7tg= In-Reply-To: <20231018091739.10125-7-crescentcy.hsieh@moxa.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Wed, 18 Oct 2023 23:06:52 -0700 (PDT) On 18. 10. 23, 11:17, Crescent CY Hsieh wrote: > MOXA PCIe boards have 4 serial interfaces and don't require additional > stuff to switch between interfaces: > > - RS232 > - RS422 > - RS485_2W (half-duplex) > - RS485_4W (full-duplex) > > By using ioctl command "TIOCRS485", it can switch between default > interface and RS485 if supported. > > That means, for RS422/RS485 board, it can switch between RS422 and > RS485 by setting the flags within struct serial_rs485. > > However, for the RS232/RS422/RS485 board, it can only switch between > RS232 and RS485, there's no flag for switching interface into RS422. > > This patch uses "SER_RS485_TERMINATE_BUS" to represent RS422 as a > workaround solution: > > - RS232 = (no flags are set) > - RS422 = SER_RS485_ENABLED | SER_RS485_TERMINATE_BUS > - RS485_2W (half-duplex) = SER_RS485_ENABLED > - RS485_4W (full-duplex) = SER_RS485_ENABLED | SER_RS485_RX_DURING_TX > > Signed-off-by: Crescent CY Hsieh > --- > drivers/tty/serial/8250/8250_pci.c | 58 ++++++++++++++++++++++++++++++ > 1 file changed, 58 insertions(+) > > diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c > index 29a28e72b..098ac466b 100644 > --- a/drivers/tty/serial/8250/8250_pci.c > +++ b/drivers/tty/serial/8250/8250_pci.c > @@ -1974,6 +1974,10 @@ pci_sunix_setup(struct serial_private *priv, > #define MOXA_RS485_2W 0x0F > #define MOXA_UIR_OFFSET 0x04 > > +static const struct serial_rs485 pci_moxa_rs485_supported = { > + .flags = SER_RS485_ENABLED | SER_RS485_RX_DURING_TX | SER_RS485_TERMINATE_BUS, > +}; > + > static bool pci_moxa_is_mini_pcie(unsigned short device) > { > if (device == PCI_DEVICE_ID_MOXA_CP102N || > @@ -2024,6 +2028,46 @@ static int pci_moxa_set_interface(const struct pci_dev *dev, > return 0; > } > > +/* > + * MOXA PCIe boards support switching the serial interface using the ioctl > + * command "TIOCSRS485", but there is currently no dedicated flag for switching > + * to RS422. As a workaround, we utilize the "SER_RS485_TERMINATE_BUS" flag to > + * represent RS422. > + * > + * RS232 = (no flags are set) > + * RS422 = SER_RS485_ENABLED | SER_RS485_TERMINATE_BUS Oh, I noticed only now. Can we implement this properly? I mean by defining e.g. SER_RS422_ENABLED? And add checks to uart_check_rs485_flags() that only one of 485/422 is set and whatever else makes sense. > + * RS485_2W (half-duplex) = SER_RS485_ENABLED > + * RS485_4W (full-duplex) = SER_RS485_ENABLED | SER_RS485_RX_DURING_TX > + */ thanks, -- js suse labs