serial: imx: support RS-485 Rx disable on Tx (2024)

diff mbox

Message ID 3b5ba06fdb9c1bdd0b3018bf2f623f52b2856d18.1456651551.git.baruch@tkos.co.il (mailing list archive)
State New, archived
Headers show

Commit Message

Some RS-232 to RS-485 transceivers require Rx to be disabled on Tx toavoid echo of Tx data into the Rx buffer. Specifically, the XR3160ERS-232/RS-485/RS-422 transceiver behaves this way.This commit disables Rx on active Tx when SER_RS485_ENABLED is active andSER_RS485_RX_DURING_TX is disabled.Note that this is a change in behavior of the driver. Until nowSER_RS485_RX_DURING_TX was enabled unconditionally even when disabled inthe TIOCSRS485 ioctl serial_rs485 flags field.Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>Signed-off-by: Baruch Siach <baruch@tkos.co.il>--- drivers/tty/serial/imx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Uwe Kleine-König Feb. 28, 2016, 9:56 a.m. UTC | #1

Hello Baruch,On Sun, Feb 28, 2016 at 11:25:51AM +0200, Baruch Siach wrote:> Some RS-232 to RS-485 transceivers require Rx to be disabled on Tx to> avoid echo of Tx data into the Rx buffer. Specifically, the XR3160E> RS-232/RS-485/RS-422 transceiver behaves this way.> > This commit disables Rx on active Tx when SER_RS485_ENABLED is active and> SER_RS485_RX_DURING_TX is disabled.> > Note that this is a change in behavior of the driver. Until nowBut this change is a good one (assuming it does what it advertises :-).Userspace got informed before that SER_RS485_RX_DURING_TX is enabled, sothis is not an incompatible change.Best regardsUwe> SER_RS485_RX_DURING_TX was enabled unconditionally even when disabled in> the TIOCSRS485 ioctl serial_rs485 flags field.> > Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>> Signed-off-by: Baruch Siach <baruch@tkos.co.il>> ---> drivers/tty/serial/imx.c | 5 ++++-> 1 file changed, 4 insertions(+), 1 deletion(-)> > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c> index 9362f54c816c..333d34ff358c 100644> --- a/drivers/tty/serial/imx.c> +++ b/drivers/tty/serial/imx.c> @@ -361,6 +361,8 @@ static void imx_stop_tx(struct uart_port *port)> imx_port_rts_inactive(sport, &temp);> else> imx_port_rts_active(sport, &temp);> +if (!(port->rs485.flags & SER_RS485_RX_DURING_TX))> +temp |= UCR2_RXEN;> writel(temp, port->membase + UCR2);> > temp = readl(port->membase + UCR4);> @@ -568,6 +570,8 @@ static void imx_start_tx(struct uart_port *port)> imx_port_rts_inactive(sport, &temp);> else> imx_port_rts_active(sport, &temp);> +if (!(port->rs485.flags & SER_RS485_RX_DURING_TX))> +temp &= ~UCR2_RXEN;> writel(temp, port->membase + UCR2);Can this happen: - SER_RS485_RX_DURING_TX is off - thread A starts sending (and so disables RX) - thread B sets SER_RS485_RX_DURING_TX - thread A finishes sending, and doesn't restore RXEN.?Even if this cannot happen it might be more robust to restore RXENunconditionally in imx_stop_tx?!Best regardsUwe

Baruch Siach Feb. 28, 2016, 10:23 a.m. UTC | #2

Hi Uwe,Thanks for your prompt response.On Sun, Feb 28, 2016 at 10:56:01AM +0100, Uwe Kleine-König wrote:> On Sun, Feb 28, 2016 at 11:25:51AM +0200, Baruch Siach wrote:> > Some RS-232 to RS-485 transceivers require Rx to be disabled on Tx to> > avoid echo of Tx data into the Rx buffer. Specifically, the XR3160E> > RS-232/RS-485/RS-422 transceiver behaves this way.> > > > This commit disables Rx on active Tx when SER_RS485_ENABLED is active and> > SER_RS485_RX_DURING_TX is disabled.> > > > Note that this is a change in behavior of the driver. Until now> > But this change is a good one (assuming it does what it advertises :-).> Userspace got informed before that SER_RS485_RX_DURING_TX is enabled, so> this is not an incompatible change.I thought it is a good idea to mention this fact in the commit log anyway. It is not hard to imagine broken userspace being affected by this change.> > SER_RS485_RX_DURING_TX was enabled unconditionally even when disabled in> > the TIOCSRS485 ioctl serial_rs485 flags field.> > > > Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>> > Signed-off-by: Baruch Siach <baruch@tkos.co.il>> > ---> > drivers/tty/serial/imx.c | 5 ++++-> > 1 file changed, 4 insertions(+), 1 deletion(-)> > > > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c> > index 9362f54c816c..333d34ff358c 100644> > --- a/drivers/tty/serial/imx.c> > +++ b/drivers/tty/serial/imx.c> > @@ -361,6 +361,8 @@ static void imx_stop_tx(struct uart_port *port)> > imx_port_rts_inactive(sport, &temp);> > else> > imx_port_rts_active(sport, &temp);> > +if (!(port->rs485.flags & SER_RS485_RX_DURING_TX))> > +temp |= UCR2_RXEN;> > writel(temp, port->membase + UCR2);> > > > temp = readl(port->membase + UCR4);> > @@ -568,6 +570,8 @@ static void imx_start_tx(struct uart_port *port)> > imx_port_rts_inactive(sport, &temp);> > else> > imx_port_rts_active(sport, &temp);> > +if (!(port->rs485.flags & SER_RS485_RX_DURING_TX))> > +temp &= ~UCR2_RXEN;> > writel(temp, port->membase + UCR2);> > Can this happen:> > - SER_RS485_RX_DURING_TX is off> - thread A starts sending (and so disables RX)> - thread B sets SER_RS485_RX_DURING_TX> - thread A finishes sending, and doesn't restore RXEN.> > ?> > Even if this cannot happen it might be more robust to restore RXEN> unconditionally in imx_stop_tx?!Sounds like a good idea. But if I take your comment to its logical conclusion, thread B might just disable SER_RS485_ENABLED entirely. Would it make sense to restore RXEN outside the 'if (port->rs485.flags & SER_RS485_ENABLED)' block? Or maybe we should just set RXEN in imx_rs485_config() when SER_RS485_RX_DURING_TX is enabled?baruch

Uwe Kleine-König Feb. 29, 2016, 8:51 a.m. UTC | #3

Hello Baruch,On Sun, Feb 28, 2016 at 12:23:23PM +0200, Baruch Siach wrote:> Thanks for your prompt response.> > On Sun, Feb 28, 2016 at 10:56:01AM +0100, Uwe Kleine-König wrote:> > On Sun, Feb 28, 2016 at 11:25:51AM +0200, Baruch Siach wrote:> > > Some RS-232 to RS-485 transceivers require Rx to be disabled on Tx to> > > avoid echo of Tx data into the Rx buffer. Specifically, the XR3160E> > > RS-232/RS-485/RS-422 transceiver behaves this way.> > > > > > This commit disables Rx on active Tx when SER_RS485_ENABLED is active and> > > SER_RS485_RX_DURING_TX is disabled.> > > > > > Note that this is a change in behavior of the driver. Until now> > > > But this change is a good one (assuming it does what it advertises :-).> > Userspace got informed before that SER_RS485_RX_DURING_TX is enabled, so> > this is not an incompatible change.> > I thought it is a good idea to mention this fact in the commit log anyway. It > is not hard to imagine broken userspace being affected by this change.> > > > SER_RS485_RX_DURING_TX was enabled unconditionally even when disabled in> > > the TIOCSRS485 ioctl serial_rs485 flags field.> > > > > > Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>> > > Signed-off-by: Baruch Siach <baruch@tkos.co.il>> > > ---> > > drivers/tty/serial/imx.c | 5 ++++-> > > 1 file changed, 4 insertions(+), 1 deletion(-)> > > > > > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c> > > index 9362f54c816c..333d34ff358c 100644> > > --- a/drivers/tty/serial/imx.c> > > +++ b/drivers/tty/serial/imx.c> > > @@ -361,6 +361,8 @@ static void imx_stop_tx(struct uart_port *port)> > > imx_port_rts_inactive(sport, &temp);> > > else> > > imx_port_rts_active(sport, &temp);> > > +if (!(port->rs485.flags & SER_RS485_RX_DURING_TX))> > > +temp |= UCR2_RXEN;> > > writel(temp, port->membase + UCR2);> > > > > > temp = readl(port->membase + UCR4);> > > @@ -568,6 +570,8 @@ static void imx_start_tx(struct uart_port *port)> > > imx_port_rts_inactive(sport, &temp);> > > else> > > imx_port_rts_active(sport, &temp);> > > +if (!(port->rs485.flags & SER_RS485_RX_DURING_TX))> > > +temp &= ~UCR2_RXEN;> > > writel(temp, port->membase + UCR2);> > > > Can this happen:> > > > - SER_RS485_RX_DURING_TX is off> > - thread A starts sending (and so disables RX)> > - thread B sets SER_RS485_RX_DURING_TX> > - thread A finishes sending, and doesn't restore RXEN.> > > > ?> > > > Even if this cannot happen it might be more robust to restore RXEN> > unconditionally in imx_stop_tx?!> > Sounds like a good idea. But if I take your comment to its logical conclusion, > thread B might just disable SER_RS485_ENABLED entirely. Would it make sense to > restore RXEN outside the 'if (port->rs485.flags & SER_RS485_ENABLED)' block? > Or maybe we should just set RXEN in imx_rs485_config() when > SER_RS485_RX_DURING_TX is enabled?The latter sounds like the right thing to do.Best regardsUwe

diff mbox

Patch

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.cindex 9362f54c816c..333d34ff358c 100644--- a/drivers/tty/serial/imx.c+++ b/drivers/tty/serial/imx.c@@ -361,6 +361,8 @@  static void imx_stop_tx(struct uart_port *port) imx_port_rts_inactive(sport, &temp); else imx_port_rts_active(sport, &temp);+if (!(port->rs485.flags & SER_RS485_RX_DURING_TX))+temp |= UCR2_RXEN; writel(temp, port->membase + UCR2); temp = readl(port->membase + UCR4);@@ -568,6 +570,8 @@  static void imx_start_tx(struct uart_port *port) imx_port_rts_inactive(sport, &temp); else imx_port_rts_active(sport, &temp);+if (!(port->rs485.flags & SER_RS485_RX_DURING_TX))+temp &= ~UCR2_RXEN; writel(temp, port->membase + UCR2); /* enable transmitter and shifter empty irq */@@ -1614,7 +1618,6 @@  static int imx_rs485_config(struct uart_port *port, /* unimplemented */ rs485conf->delay_rts_before_send = 0; rs485conf->delay_rts_after_send = 0;-rs485conf->flags |= SER_RS485_RX_DURING_TX; /* RTS is required to control the transmitter */ if (!sport->have_rtscts)
serial: imx: support RS-485 Rx disable on Tx (2024)

References

Top Articles
Neil Bonnett ~ The Racer, The Broadcaster, The Legend
How Do Banks/Check Cashing Places Verify Checks? Answered
Spasa Parish
Rentals for rent in Maastricht
159R Bus Schedule Pdf
Sallisaw Bin Store
Black Adam Showtimes Near Maya Cinemas Delano
Espn Transfer Portal Basketball
Pollen Levels Richmond
11 Best Sites Like The Chive For Funny Pictures and Memes
Things to do in Wichita Falls on weekends 12-15 September
Craigslist Pets Huntsville Alabama
Paulette Goddard | American Actress, Modern Times, Charlie Chaplin
Red Dead Redemption 2 Legendary Fish Locations Guide (“A Fisher of Fish”)
What's the Difference Between Halal and Haram Meat & Food?
R/Skinwalker
Rugged Gentleman Barber Shop Martinsburg Wv
Jennifer Lenzini Leaving Ktiv
Justified - Streams, Episodenguide und News zur Serie
Epay. Medstarhealth.org
Olde Kegg Bar & Grill Portage Menu
Cubilabras
Half Inning In Which The Home Team Bats Crossword
Amazing Lash Bay Colony
Juego Friv Poki
Dirt Devil Ud70181 Parts Diagram
Truist Bank Open Saturday
Water Leaks in Your Car When It Rains? Common Causes & Fixes
What’s Closing at Disney World? A Complete Guide
New from Simply So Good - Cherry Apricot Slab Pie
Drys Pharmacy
Ohio State Football Wiki
Find Words Containing Specific Letters | WordFinder®
FirstLight Power to Acquire Leading Canadian Renewable Operator and Developer Hydromega Services Inc. - FirstLight
Webmail.unt.edu
2024-25 ITH Season Preview: USC Trojans
Metro By T Mobile Sign In
Restored Republic December 1 2022
12 30 Pacific Time
Jami Lafay Gofundme
Wi Dept Of Regulation & Licensing
Pick N Pull Near Me [Locator Map + Guide + FAQ]
Crystal Westbrooks Nipple
Ice Hockey Dboard
Über 60 Prozent Rabatt auf E-Bikes: Aldi reduziert sämtliche Pedelecs stark im Preis - nur noch für kurze Zeit
Wie blocke ich einen Bot aus Boardman/USA - sellerforum.de
Infinity Pool Showtimes Near Maya Cinemas Bakersfield
Dermpathdiagnostics Com Pay Invoice
How To Use Price Chopper Points At Quiktrip
Maria Butina Bikini
Busted Newspaper Zapata Tx
Latest Posts
Article information

Author: Pres. Lawanda Wiegand

Last Updated:

Views: 5487

Rating: 4 / 5 (51 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Pres. Lawanda Wiegand

Birthday: 1993-01-10

Address: Suite 391 6963 Ullrich Shore, Bellefort, WI 01350-7893

Phone: +6806610432415

Job: Dynamic Manufacturing Assistant

Hobby: amateur radio, Taekwondo, Wood carving, Parkour, Skateboarding, Running, Rafting

Introduction: My name is Pres. Lawanda Wiegand, I am a inquisitive, helpful, glamorous, cheerful, open, clever, innocent person who loves writing and wants to share my knowledge and understanding with you.