linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Lukas Wunner <lukas@wunner.de>
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"open list:SERIAL DRIVERS" <linux-serial@vger.kernel.org>,
	"Jiri Slaby" <jirislaby@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Johan Hovold" <johan@kernel.org>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"Heikki Krogerus" <heikki.krogerus@linux.intel.com>,
	"Eric Tremblay" <etremblay@distech-controls.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Heiko Stübner" <heiko@sntech.de>,
	"Giulio Benetti" <giulio.benetti@micronovasrl.com>
Subject: Re: [RFC PATCH 3/7] serial: 8250_dwlib: Implement SW half duplex support
Date: Mon, 7 Mar 2022 00:13:09 +0200	[thread overview]
Message-ID: <CAHp75Ve3EmFMZGsHpsBfy4QUnKqP3LhOXFZ+d7RhVS9RkAqCHw@mail.gmail.com> (raw)
In-Reply-To: <20220306192135.GC19394@wunner.de>

On Mon, Mar 7, 2022 at 12:01 AM Lukas Wunner <lukas@wunner.de> wrote:
> On Wed, Mar 02, 2022 at 11:56:02AM +0200, Ilpo Järvinen 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-controls.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übner, who used patches by Giulio Benetti (+cc):
>
> https://lore.kernel.org/linux-serial/20200517215610.2131618-1-heiko@sntech.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



-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2022-03-06 22:13 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-02  9:55 [PATCH 0/7] Add RS485 support to DW UART Ilpo Järvinen
2022-03-02  9:56 ` [PATCH 1/7] serial: 8250_dwlib: RS485 HW half duplex support Ilpo Järvinen
2022-03-06 18:48   ` Lukas Wunner
2022-03-06 22:07     ` Andy Shevchenko
2022-03-07  9:19       ` Ilpo Järvinen
2022-03-07 19:18         ` Lukas Wunner
2022-03-07 19:39           ` Andy Shevchenko
2022-03-08 12:16             ` Ilpo Järvinen
2022-03-08 12:22               ` Lukas Wunner
2022-03-08 12:59                 ` Ilpo Järvinen
2022-03-08 14:50                   ` Lukas Wunner
2022-03-08 14:53                     ` Andy Shevchenko
2022-03-08 20:30                       ` Lukas Wunner
2022-03-09  9:51                         ` Ilpo Järvinen
2022-03-07 10:54     ` Ilpo Järvinen
2022-03-09  8:52       ` Lukas Wunner
2022-03-09 12:19       ` Ilpo Järvinen
2022-03-09 12:59         ` Lukas Wunner
2022-03-02  9:56 ` [PATCH 2/7] serial: 8250_dwlib: RS485 HW full " Ilpo Järvinen
2022-03-06 18:51   ` Lukas Wunner
2022-03-07  9:22     ` Ilpo Järvinen
2022-03-02  9:56 ` [RFC PATCH 3/7] serial: 8250_dwlib: Implement SW half " Ilpo Järvinen
2022-03-06 19:21   ` Lukas Wunner
2022-03-06 22:13     ` Andy Shevchenko [this message]
2022-03-02  9:56 ` [PATCH 4/7] dt_bindings: snps-dw-apb-uart: Add RS485 Ilpo Järvinen
2022-03-02 17:47   ` Rob Herring
2022-03-02  9:56 ` [RFC PATCH 5/7] serial: termbits: ADDRB to indicate 9th bit addressing mode Ilpo Järvinen
2022-03-02  9:56 ` [RFC PATCH 6/7] serial: General support for multipoint addresses Ilpo Järvinen
2022-03-06 19:40   ` Lukas Wunner
2022-03-07  9:48     ` Ilpo Järvinen
2022-03-09 19:05       ` Lukas Wunner
2022-03-10 12:29         ` Ilpo Järvinen
2022-03-10 14:09         ` Andy Shevchenko
2022-03-02  9:56 ` [RFC PATCH 7/7] serial: 8250_dwlib: Support for 9th bit multipoint addressing Ilpo Järvinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHp75Ve3EmFMZGsHpsBfy4QUnKqP3LhOXFZ+d7RhVS9RkAqCHw@mail.gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=etremblay@distech-controls.com \
    --cc=giulio.benetti@micronovasrl.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=heiko@sntech.de \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jirislaby@kernel.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).