Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1705166pxp; Mon, 7 Mar 2022 00:03:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJyExvXOkP90sKjDGUM9OXwPTwWzn11J7X28Li7zmCciAKPgd43PhE7QiB/iM8BiLPjtfdRb X-Received: by 2002:a05:6402:11c8:b0:416:4828:9242 with SMTP id j8-20020a05640211c800b0041648289242mr3511831edw.405.1646640215176; Mon, 07 Mar 2022 00:03:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646640215; cv=none; d=google.com; s=arc-20160816; b=W/VGhmoNCyoTvDi4zlTrLcPMMP2lhs6ozTKYJtLVaFThvlIs/EBOVbYdFHDVAJFJ9Y AGxDmUaK4xDG7oWsany5M8PF8UHZPE0MRQNpwVcRXFn+DahWIQM79x77lVUk323MJN+P xDPqAGkzEk8HsMxUG9CMvGOhKFc13fbpn1Uqf2NIgzoYp0Nzy3tuf6kEwUWdrv5+cZl3 ZvcI4uFv9D/yRFZKLqXIk3oTn8s/7LSO9eokotGDbMHao4jTsf1eO0UKCUXLk1S0tTXK /sNy1QhC6izXjB5H0PsybTHm3mtUCbmcyD3WVzsUa5MJ96QS/Nh0IrET4g2y8w5zdROU 4z4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=d07l6897o6MrSAkIwgSUFhA0NhycxI0AnBPO1cVoW8o=; b=uq8GPe8MaMRP40tUYZdF6AumXAHiySpUrqB5qxT2BUWx3d6DZMW0b4D/dTQpEM1ngR AiVDIFCBAedLohdsC3f4zJ6lwa7v9XDfnZC0HvVUq/lo98Dc6Mv9wTgUmUr4NwkL6lMa W7PsKdHuxSWZnUpGBjuLewgdDb3pmZrkBy0KlSTzH6Rpk+q4ajAA7jS1Vcr1B79YYCBh Mi1uT72+sCoinnhqIc/h/Xw7Aunu7m53mqe6SQ/WtCfbGnUBL+AGCjQXk54M2RBdn0I0 naeeDf46EQ8BNtssr8MwhkWlFhxXB+zzp65EmoboeakB3uTwR+F1CP+/VXjcwrQ/TU3+ 4w2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="B6y/niMv"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q17-20020a1709063d5100b006b87b731924si7250440ejf.425.2022.03.07.00.03.10; Mon, 07 Mar 2022 00:03:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="B6y/niMv"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234332AbiCFWOo (ORCPT + 99 others); Sun, 6 Mar 2022 17:14:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231239AbiCFWOk (ORCPT ); Sun, 6 Mar 2022 17:14:40 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5132366AD; Sun, 6 Mar 2022 14:13:46 -0800 (PST) Received: by mail-ed1-x535.google.com with SMTP id g20so17489264edw.6; Sun, 06 Mar 2022 14:13:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=d07l6897o6MrSAkIwgSUFhA0NhycxI0AnBPO1cVoW8o=; b=B6y/niMvLqAqBPL90NfdQwBJiRcjHs6OGnXR875jYgCEK4Se5HLcO5/svp+7R2kCYf 9z864K1QRXbch5fVAucZjUpBoegiSoFXhHwziPlRxl4PoJyy2ZlQS7Vi6SJ8btyuIr9d FSi+uMFFCH5gRrHWnrMdyRsgHfW+x/ROJ3I2GQx4msxjb7ZvWwvp6zp2PU5VpUdRMTt5 XbZZ8ys3g9YZGKsymfJjL+jmICOYPzhfNxxxEuWNHaiTjeaBdL6w3rQP4kJFUV3wPar6 C3DqDHLP6zirpcfs2ai6SCK5QAvElMPfifHWoGE+txKv7+p0OS8DLjdaYhWiJdSSPnnj ULPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=d07l6897o6MrSAkIwgSUFhA0NhycxI0AnBPO1cVoW8o=; b=12e61SaL+sQ+ww6JFUJK9DPvoRu/tt51y2r96vPNJ8rkdAOq2Lbeyh1B78XW3h5Rm/ 3L0BUDzkXimfjCuTip+p+vYhi0/D1JcRsNDUboOJkNO7aEn5YQ+sqoR6dOsJhBFE1fd+ EvMOBXaM9anPZ71eE3CgUWgt3VZ8ePvzIa8y0ldrO+Qcxe4SV8J9M1gX+hL6GMxS7rNk fQevZMLQP9xXH3//4kikARQJlETlZHbgbyFihRuFVcMmn9HKKk8QyHRruoTtr0ImU97E L0oT6zSBLYTholFb6DusHKNtM5Me2rf+7hn9NNy6SMbUlDSG0U/+ob7BJMHbsd8/s9Pd W7Pw== X-Gm-Message-State: AOAM530bUmLdqsyH+ivajoumWK28Zi/rkl6EWD6UKPoYn7fIr+IQUlwm BdsPI0eublB5KxDIg9ekm0XSHMIHBKGf9rYGg/Y= X-Received: by 2002:a05:6402:3452:b0:415:9d25:3967 with SMTP id l18-20020a056402345200b004159d253967mr8355081edc.125.1646604825414; Sun, 06 Mar 2022 14:13:45 -0800 (PST) MIME-Version: 1.0 References: <20220302095606.14818-1-ilpo.jarvinen@linux.intel.com> <20220302095606.14818-4-ilpo.jarvinen@linux.intel.com> <20220306192135.GC19394@wunner.de> In-Reply-To: <20220306192135.GC19394@wunner.de> From: Andy Shevchenko Date: Mon, 7 Mar 2022 00:13:09 +0200 Message-ID: Subject: Re: [RFC PATCH 3/7] serial: 8250_dwlib: Implement SW half duplex support To: Lukas Wunner Cc: =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= , "open list:SERIAL DRIVERS" , Jiri Slaby , Greg Kroah-Hartman , Linux Kernel Mailing List , Johan Hovold , Andy Shevchenko , Heikki Krogerus , Eric Tremblay , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , =?UTF-8?Q?Heiko_St=C3=BCbner?= , Giulio Benetti Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Mon, Mar 7, 2022 at 12:01 AM Lukas Wunner wrote: > On Wed, Mar 02, 2022 at 11:56:02AM +0200, Ilpo J=C3=A4rvinen wrote: > > This patch enables support for SW half-duplex mode. Synopsys > > DesignWare UART has a build-in support for the RS485 protocol > > from IP version 4.0 onward with dedicated RE/DE_EN registers. > > This patch enables RS485 either using dedicated registers or > > em485 as fallback. > > > > In order to select preference for SW half-duplex mode (em485 + > > RE/DE_EN) over HW managed one, as both are supported under > > some configurations, SER_RS485_SW_RX_OR_TX flag is added to > > serial_rs485. > > > > This patch depends on UART_CAP_NOTEMT which is not provided > > by this series but another one: > > https://lore.kernel.org/all/20210204161158.643-1-etremblay@distech-co= ntrols.com/ > > I don't see any benefit in using software emulated RTS assertion > if hardware support is present. It just consumes more CPU time > and is slower to deassert RTS, thereby increasing bus turn-around time. > > So if hardware support is present, I think you always want to > use that and you need to fallback to software emulation only > if hardware support is missing (i.e. on IP versions < 4). No, this is not a good idea because presence of the HW support does not guarantee we will have pins on PCB level and/or properly muxed by firmware, or be able to be properly muxed by software (OS). Or am I missing something here and you have an idea how to enable RS485 in that case? > The registers you're using here, DW_UART_RE_EN and DW_UART_DE_EN > don't seem to be present on older IP versions. I'm looking at > the databook for version 3.04a and those registers aren't mentioned: > > https://linux-sunxi.org/images/d/d2/Dw_apb_uart_db.pdf > > So the software emulation you've implemented here won't help with > older IP and the newer IP doesn't need it because it supports > RTS assertion in hardware. Is that correct? If so, I'd suggest > not supporting DW_UART_TCR_XFER_MODE_SW_DE_OR_RE at all. > > A number of people have attempted to add rs485 software emulation > to 8250_dw.c but noone ever pursued it into mainline. The last > attempt was by Heiko St=C3=BCbner, who used patches by Giulio Benetti (+c= c): > > https://lore.kernel.org/linux-serial/20200517215610.2131618-1-heiko@sntec= h.de/ > > FWIW, newer TI Sitara SoCs have also added hardware support for > rs485 and in this (not yet upstreamed) patch, I likewise chose > to use software emulation only if hardware support is not available: > > https://github.com/l1k/linux/commit/82c989617a05 --=20 With Best Regards, Andy Shevchenko