* [PATCH] tty: serial: imx: Fix broken RS485 @ 2024-02-16 12:46 Rickard Andersson 2024-02-16 15:17 ` Marek Vasut 0 siblings, 1 reply; 6+ messages in thread From: Rickard Andersson @ 2024-02-16 12:46 UTC (permalink / raw) To: linux-serial, rickard314.andersson, gregkh, shawnguo, s.hauer, kernel, festevam, linux-imx, martin.fuzzey, marex Cc: rickaran, kernel From: Rickard x Andersson <rickaran@axis.com> When about to transmit the function imx_uart_start_tx is called and in some RS485 configurations this function will call imx_uart_stop_rx. The problem is that imx_uart_stop_rx will enable loopback and when loopback is enabled transmitted data will just be looped to RX. This patch fixes the above problem by explicitly disabling loopback in the case described above. Signed-off-by: Rickard x Andersson <rickaran@axis.com> --- drivers/tty/serial/imx.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 4aa72d5aeafb..899e331bdfc8 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -683,8 +683,15 @@ static void imx_uart_start_tx(struct uart_port *port) imx_uart_writel(sport, ucr2, UCR2); if (!(port->rs485.flags & SER_RS485_RX_DURING_TX) && - !port->rs485_rx_during_tx_gpio) + !port->rs485_rx_during_tx_gpio) { imx_uart_stop_rx(port); + /* + * The function imx_uart_stop_rx right above + * will enable loopback, but since we are just + * about to transmit then disable loopback. + */ + imx_uart_disable_loopback_rs485(sport); + } sport->tx_state = WAIT_AFTER_RTS; -- 2.30.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] tty: serial: imx: Fix broken RS485 2024-02-16 12:46 [PATCH] tty: serial: imx: Fix broken RS485 Rickard Andersson @ 2024-02-16 15:17 ` Marek Vasut 2024-02-20 6:07 ` Rickard X Andersson 0 siblings, 1 reply; 6+ messages in thread From: Marek Vasut @ 2024-02-16 15:17 UTC (permalink / raw) To: Rickard Andersson, linux-serial, rickard314.andersson, gregkh, shawnguo, s.hauer, kernel, festevam, linux-imx, martin.fuzzey, Christoph Niedermaier Cc: kernel On 2/16/24 13:46, Rickard Andersson wrote: > From: Rickard x Andersson <rickaran@axis.com> > > When about to transmit the function imx_uart_start_tx is called and in > some RS485 configurations this function will call imx_uart_stop_rx. The > problem is that imx_uart_stop_rx will enable loopback and when loopback > is enabled transmitted data will just be looped to RX. > > This patch fixes the above problem by explicitly disabling loopback in > the case described above. > > Signed-off-by: Rickard x Andersson <rickaran@axis.com> Fixes: tag is missing. > --- > drivers/tty/serial/imx.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c > index 4aa72d5aeafb..899e331bdfc8 100644 > --- a/drivers/tty/serial/imx.c > +++ b/drivers/tty/serial/imx.c > @@ -683,8 +683,15 @@ static void imx_uart_start_tx(struct uart_port *port) > imx_uart_writel(sport, ucr2, UCR2); > > if (!(port->rs485.flags & SER_RS485_RX_DURING_TX) && > - !port->rs485_rx_during_tx_gpio) > + !port->rs485_rx_during_tx_gpio) { > imx_uart_stop_rx(port); > + /* > + * The function imx_uart_stop_rx right above > + * will enable loopback, but since we are just > + * about to transmit then disable loopback. > + */ > + imx_uart_disable_loopback_rs485(sport); > + } Maybe it would be better to update the stop_rx and add parameter, whether it should/shouldn't enable the loopback ? ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tty: serial: imx: Fix broken RS485 2024-02-16 15:17 ` Marek Vasut @ 2024-02-20 6:07 ` Rickard X Andersson 2024-02-20 6:52 ` Marek Vasut 0 siblings, 1 reply; 6+ messages in thread From: Rickard X Andersson @ 2024-02-20 6:07 UTC (permalink / raw) To: Marek Vasut, linux-serial@vger.kernel.org, rickard314.andersson@gmail.com, gregkh@linuxfoundation.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, martin.fuzzey@flowbird.group, Christoph Niedermaier Cc: kernel On Fri, Feb 16, 2024 at 4:17 PM Marek Vasut <marex@denx.de> wrote: > > On 2/16/24 13:46, Rickard Andersson wrote: > > From: Rickard x Andersson <rickaran@axis.com> > > > > When about to transmit the function imx_uart_start_tx is called and in > > some RS485 configurations this function will call imx_uart_stop_rx. The > > problem is that imx_uart_stop_rx will enable loopback and when loopback > > is enabled transmitted data will just be looped to RX. > > > > This patch fixes the above problem by explicitly disabling loopback in > > the case described above. > > > > Signed-off-by: Rickard x Andersson <rickaran@axis.com> > > Fixes: tag is missing. Ok, I will add. > > > --- > > drivers/tty/serial/imx.c | 9 ++++++++- > > 1 file changed, 8 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c > > index 4aa72d5aeafb..899e331bdfc8 100644 > > --- a/drivers/tty/serial/imx.c > > +++ b/drivers/tty/serial/imx.c > > @@ -683,8 +683,15 @@ static void imx_uart_start_tx(struct uart_port *port) > > imx_uart_writel(sport, ucr2, UCR2); > > > > if (!(port->rs485.flags & SER_RS485_RX_DURING_TX) && > > - !port->rs485_rx_during_tx_gpio) > > + !port->rs485_rx_during_tx_gpio) { > > imx_uart_stop_rx(port); > > + /* > > + * The function imx_uart_stop_rx right above > > + * will enable loopback, but since we are just > > + * about to transmit then disable loopback. > > + */ > > + imx_uart_disable_loopback_rs485(sport); > > + } > > Maybe it would be better to update the stop_rx and add parameter, > whether it should/shouldn't enable the loopback ? Since *stop_rx is part of struct uart_ops I can not add an input argument to the function. Best regards, Rickard ________________________________________ From: Marek Vasut <marex@denx.de> Sent: Friday, February 16, 2024 4:17 PM To: Rickard X Andersson; linux-serial@vger.kernel.org; rickard314.andersson@gmail.com; gregkh@linuxfoundation.org; shawnguo@kernel.org; s.hauer@pengutronix.de; kernel@pengutronix.de; festevam@gmail.com; linux-imx@nxp.com; martin.fuzzey@flowbird.group; Christoph Niedermaier Cc: kernel Subject: Re: [PATCH] tty: serial: imx: Fix broken RS485 On 2/16/24 13:46, Rickard Andersson wrote: > From: Rickard x Andersson <rickaran@axis.com> > > When about to transmit the function imx_uart_start_tx is called and in > some RS485 configurations this function will call imx_uart_stop_rx. The > problem is that imx_uart_stop_rx will enable loopback and when loopback > is enabled transmitted data will just be looped to RX. > > This patch fixes the above problem by explicitly disabling loopback in > the case described above. > > Signed-off-by: Rickard x Andersson <rickaran@axis.com> Fixes: tag is missing. > --- > drivers/tty/serial/imx.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c > index 4aa72d5aeafb..899e331bdfc8 100644 > --- a/drivers/tty/serial/imx.c > +++ b/drivers/tty/serial/imx.c > @@ -683,8 +683,15 @@ static void imx_uart_start_tx(struct uart_port *port) > imx_uart_writel(sport, ucr2, UCR2); > > if (!(port->rs485.flags & SER_RS485_RX_DURING_TX) && > - !port->rs485_rx_during_tx_gpio) > + !port->rs485_rx_during_tx_gpio) { > imx_uart_stop_rx(port); > + /* > + * The function imx_uart_stop_rx right above > + * will enable loopback, but since we are just > + * about to transmit then disable loopback. > + */ > + imx_uart_disable_loopback_rs485(sport); > + } Maybe it would be better to update the stop_rx and add parameter, whether it should/shouldn't enable the loopback ? ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tty: serial: imx: Fix broken RS485 2024-02-20 6:07 ` Rickard X Andersson @ 2024-02-20 6:52 ` Marek Vasut 2024-02-20 8:39 ` Rickard X Andersson 0 siblings, 1 reply; 6+ messages in thread From: Marek Vasut @ 2024-02-20 6:52 UTC (permalink / raw) To: Rickard X Andersson, linux-serial@vger.kernel.org, rickard314.andersson@gmail.com, gregkh@linuxfoundation.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, martin.fuzzey@flowbird.group, Christoph Niedermaier Cc: kernel On 2/20/24 07:07, Rickard X Andersson wrote: > On Fri, Feb 16, 2024 at 4:17 PM Marek Vasut <marex@denx.de> wrote: >> >> On 2/16/24 13:46, Rickard Andersson wrote: >>> From: Rickard x Andersson <rickaran@axis.com> >>> >>> When about to transmit the function imx_uart_start_tx is called and in >>> some RS485 configurations this function will call imx_uart_stop_rx. The >>> problem is that imx_uart_stop_rx will enable loopback and when loopback >>> is enabled transmitted data will just be looped to RX. >>> >>> This patch fixes the above problem by explicitly disabling loopback in >>> the case described above. >>> >>> Signed-off-by: Rickard x Andersson <rickaran@axis.com> >> >> Fixes: tag is missing. > > Ok, I will add. >> >>> --- >>> drivers/tty/serial/imx.c | 9 ++++++++- >>> 1 file changed, 8 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c >>> index 4aa72d5aeafb..899e331bdfc8 100644 >>> --- a/drivers/tty/serial/imx.c >>> +++ b/drivers/tty/serial/imx.c >>> @@ -683,8 +683,15 @@ static void imx_uart_start_tx(struct uart_port *port) >>> imx_uart_writel(sport, ucr2, UCR2); >>> >>> if (!(port->rs485.flags & SER_RS485_RX_DURING_TX) && >>> - !port->rs485_rx_during_tx_gpio) >>> + !port->rs485_rx_during_tx_gpio) { >>> imx_uart_stop_rx(port); >>> + /* >>> + * The function imx_uart_stop_rx right above >>> + * will enable loopback, but since we are just >>> + * about to transmit then disable loopback. >>> + */ >>> + imx_uart_disable_loopback_rs485(sport); >>> + } >> >> Maybe it would be better to update the stop_rx and add parameter, >> whether it should/shouldn't enable the loopback ? > > Since *stop_rx is part of struct uart_ops I can not add an input argument to the function. You could add a wrapper function and make stop_tx call that one. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tty: serial: imx: Fix broken RS485 2024-02-20 6:52 ` Marek Vasut @ 2024-02-20 8:39 ` Rickard X Andersson 2024-02-20 8:43 ` Marek Vasut 0 siblings, 1 reply; 6+ messages in thread From: Rickard X Andersson @ 2024-02-20 8:39 UTC (permalink / raw) To: Marek Vasut, linux-serial@vger.kernel.org, rickard314.andersson@gmail.com, gregkh@linuxfoundation.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, martin.fuzzey@flowbird.group, Christoph Niedermaier Cc: kernel > >> Maybe it would be better to update the stop_rx and add parameter, > >> whether it should/shouldn't enable the loopback ? > > > > Since *stop_rx is part of struct uart_ops I can not add an input argument to the function. > > You could add a wrapper function and make stop_tx call that one. Ok, yes that is possible. Do you want me to do that change? Best regards, Rickard ________________________________________ From: Marek Vasut <marex@denx.de> Sent: Tuesday, February 20, 2024 7:52 AM To: Rickard X Andersson; linux-serial@vger.kernel.org; rickard314.andersson@gmail.com; gregkh@linuxfoundation.org; shawnguo@kernel.org; s.hauer@pengutronix.de; kernel@pengutronix.de; festevam@gmail.com; linux-imx@nxp.com; martin.fuzzey@flowbird.group; Christoph Niedermaier Cc: kernel Subject: Re: [PATCH] tty: serial: imx: Fix broken RS485 On 2/20/24 07:07, Rickard X Andersson wrote: > On Fri, Feb 16, 2024 at 4:17 PM Marek Vasut <marex@denx.de> wrote: >> >> On 2/16/24 13:46, Rickard Andersson wrote: >>> From: Rickard x Andersson <rickaran@axis.com> >>> >>> When about to transmit the function imx_uart_start_tx is called and in >>> some RS485 configurations this function will call imx_uart_stop_rx. The >>> problem is that imx_uart_stop_rx will enable loopback and when loopback >>> is enabled transmitted data will just be looped to RX. >>> >>> This patch fixes the above problem by explicitly disabling loopback in >>> the case described above. >>> >>> Signed-off-by: Rickard x Andersson <rickaran@axis.com> >> >> Fixes: tag is missing. > > Ok, I will add. >> >>> --- >>> drivers/tty/serial/imx.c | 9 ++++++++- >>> 1 file changed, 8 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c >>> index 4aa72d5aeafb..899e331bdfc8 100644 >>> --- a/drivers/tty/serial/imx.c >>> +++ b/drivers/tty/serial/imx.c >>> @@ -683,8 +683,15 @@ static void imx_uart_start_tx(struct uart_port *port) >>> imx_uart_writel(sport, ucr2, UCR2); >>> >>> if (!(port->rs485.flags & SER_RS485_RX_DURING_TX) && >>> - !port->rs485_rx_during_tx_gpio) >>> + !port->rs485_rx_during_tx_gpio) { >>> imx_uart_stop_rx(port); >>> + /* >>> + * The function imx_uart_stop_rx right above >>> + * will enable loopback, but since we are just >>> + * about to transmit then disable loopback. >>> + */ >>> + imx_uart_disable_loopback_rs485(sport); >>> + } >> >> Maybe it would be better to update the stop_rx and add parameter, >> whether it should/shouldn't enable the loopback ? > > Since *stop_rx is part of struct uart_ops I can not add an input argument to the function. You could add a wrapper function and make stop_tx call that one. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tty: serial: imx: Fix broken RS485 2024-02-20 8:39 ` Rickard X Andersson @ 2024-02-20 8:43 ` Marek Vasut 0 siblings, 0 replies; 6+ messages in thread From: Marek Vasut @ 2024-02-20 8:43 UTC (permalink / raw) To: Rickard X Andersson, linux-serial@vger.kernel.org, rickard314.andersson@gmail.com, gregkh@linuxfoundation.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, martin.fuzzey@flowbird.group, Christoph Niedermaier Cc: kernel On 2/20/24 09:39, Rickard X Andersson wrote: > >>>> Maybe it would be better to update the stop_rx and add parameter, >>>> whether it should/shouldn't enable the loopback ? >>> >>> Since *stop_rx is part of struct uart_ops I can not add an input argument to the function. >> >> You could add a wrapper function and make stop_tx call that one. > > Ok, yes that is possible. Do you want me to do that change? Better wait a few days before sending V3, so that others can chime in. And yes, I think it would be better. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-02-20 9:35 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-02-16 12:46 [PATCH] tty: serial: imx: Fix broken RS485 Rickard Andersson 2024-02-16 15:17 ` Marek Vasut 2024-02-20 6:07 ` Rickard X Andersson 2024-02-20 6:52 ` Marek Vasut 2024-02-20 8:39 ` Rickard X Andersson 2024-02-20 8:43 ` Marek Vasut
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox