From: Jiri Slaby <jirislaby@kernel.org>
To: Crescent CY Hsieh <crescentcy.hsieh@moxa.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: Re: [PATCH v3 6/6] tty: serial: 8250: Add support for MOXA PCIe boards to switch interface between RS422/RS485
Date: Thu, 19 Oct 2023 08:06:38 +0200 [thread overview]
Message-ID: <3332a86c-1a1d-4b78-bbfa-8ac3e2e642a1@kernel.org> (raw)
In-Reply-To: <20231018091739.10125-7-crescentcy.hsieh@moxa.com>
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 <crescentcy.hsieh@moxa.com>
> ---
> 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
next prev parent reply other threads:[~2023-10-19 6:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-18 9:17 [PATCH v3 0/6] tty: serial: 8250: Changes of MOXA PCIe boards in 8250_pci.c Crescent CY Hsieh
2023-10-18 9:17 ` [PATCH v3 1/6] tty: serial: 8250: Modify MOXA enum name within 8250_pci.c Crescent CY Hsieh
2023-10-18 9:17 ` [PATCH v3 2/6] tty: serial: 8250: Cleanup MOXA configurations Crescent CY Hsieh
2023-10-18 9:17 ` [PATCH v3 3/6] tty: serial: 8250: Relocate macros within 8250_pci.c Crescent CY Hsieh
2023-10-18 9:17 ` [PATCH v3 4/6] tty: serial: 8250: Add support for MOXA Mini PCIe boards Crescent CY Hsieh
2023-10-18 9:17 ` [PATCH v3 5/6] tty: serial: 8250: Fix MOXA RS422/RS485 PCIe boards not work by default Crescent CY Hsieh
2023-10-19 5:59 ` Jiri Slaby
2023-10-19 6:16 ` Jiri Slaby
2023-10-23 9:21 ` Ilpo Järvinen
2023-10-18 9:17 ` [PATCH v3 6/6] tty: serial: 8250: Add support for MOXA PCIe boards to switch interface between RS422/RS485 Crescent CY Hsieh
2023-10-19 6:06 ` Jiri Slaby [this message]
2023-10-19 6:24 ` Jiri Slaby
2023-10-23 9:25 ` Ilpo Järvinen
2023-10-24 7:48 ` Crescent CY Hsieh
2023-10-24 8:10 ` Greg Kroah-Hartman
2023-10-21 16:31 ` [PATCH v3 0/6] tty: serial: 8250: Changes of MOXA PCIe boards in 8250_pci.c Greg Kroah-Hartman
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=3332a86c-1a1d-4b78-bbfa-8ac3e2e642a1@kernel.org \
--to=jirislaby@kernel.org \
--cc=crescentcy.hsieh@moxa.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
/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
Powered by JetHome