All of lore.kernel.org
 help / color / mirror / Atom feed
From: Einar Vading <einar.vading@axis.com>
To: Stefan Agner <stefan@agner.ch>
Cc: linux-arm-kernel@lists.infradead.org, s.hauer@pengutronix.de,
	baruch@tkos.co.il, linux-serial@vger.kernel.org,
	u.kleine-koenig@pengutronix.de
Subject: Re: serial: imx: half-duplex RS485 operation with RTS active low
Date: Mon, 16 Apr 2018 11:54:36 +0200	[thread overview]
Message-ID: <20180416095436.7mxh4cqdvlyleryr@lnxeinarv.se.axis.com> (raw)
In-Reply-To: <0e88706a05a302201be396d2f03c3e9e@agner.ch>

On Mon, Apr 16, 2018 at 11:14:32AM +0200, Stefan Agner wrote:
> Hi,
> 
> Using upstream I noticed that RS-485 does not work in the default
> configuration for our platforms (Toradex Apalis/Colibri). Closer
> debugging shows that it is related to "serial: imx: default to half
> duplex rs485".

We where struggling a bit with half duplex rs485 too a while ago.
> 
> We use the i.MX UART in DTE mode and control the RS-485 transceiver
> using the RTS signal in low-active mode.
> 
> 	uart-has-rtscts;
> 	fsl,dte-mode;
> 	linux,rs485-enabled-at-boot-time;
> 	rs485-rts-active-low;
> 
> Using this setting leads to the RTS signal not getting asserted (the
> oscilloscope only shows a very short fluke before the start bit is
> sent).

I think this is what we had too. But if I recall we where supposed to be
active-high but I think the behavior is the same either way.
> 
> However, using
> 
> 	uart-has-rtscts;
> 	fsl,dte-mode;
> 	linux,rs485-enabled-at-boot-time;
> 	rs485-rts-active-low;
> 	rs485-rx-during-tx;
> 
> Asserts the RTS signal low active just fine...

We have a (RTS active high) configuration working for us now with only

    uart-has-rtscts

in DT, and then when using the port we do

    struct serial_rs485 rs485conf;
    memset(&rs485conf, 0x00, sizeof(struct serial_rs485));

    rs485conf.flags |= SER_RS485_ENABLED;
    rs485conf.flags |= SER_RS485_RTS_ON_SEND;
    rs485conf.flags &= ~(SER_RS485_RTS_AFTER_SEND);

    f_debug("Calling ioctl...");
    if (ioctl (fd, TIOCSRS485, &rs485conf) < 0) {
      f_critical("ioctl serial_rs485 failed");
      return -1;
    }

Hope it helps.
> 
> Is this a known problem? Any idea where that could come from? It looks
> as if the receiver part is actually enabling RTS...?
> 
> Also, isn't enabling RX even in half-duplex mode quite common in order
> to detect collisions?
> 
> --
> Stefan

// Einar
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-serial" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: einar.vading@axis.com (Einar Vading)
To: linux-arm-kernel@lists.infradead.org
Subject: serial: imx: half-duplex RS485 operation with RTS active low
Date: Mon, 16 Apr 2018 11:54:36 +0200	[thread overview]
Message-ID: <20180416095436.7mxh4cqdvlyleryr@lnxeinarv.se.axis.com> (raw)
In-Reply-To: <0e88706a05a302201be396d2f03c3e9e@agner.ch>

On Mon, Apr 16, 2018 at 11:14:32AM +0200, Stefan Agner wrote:
> Hi,
> 
> Using upstream I noticed that RS-485 does not work in the default
> configuration for our platforms (Toradex Apalis/Colibri). Closer
> debugging shows that it is related to "serial: imx: default to half
> duplex rs485".

We where struggling a bit with half duplex rs485 too a while ago.
> 
> We use the i.MX UART in DTE mode and control the RS-485 transceiver
> using the RTS signal in low-active mode.
> 
> 	uart-has-rtscts;
> 	fsl,dte-mode;
> 	linux,rs485-enabled-at-boot-time;
> 	rs485-rts-active-low;
> 
> Using this setting leads to the RTS signal not getting asserted (the
> oscilloscope only shows a very short fluke before the start bit is
> sent).

I think this is what we had too. But if I recall we where supposed to be
active-high but I think the behavior is the same either way.
> 
> However, using
> 
> 	uart-has-rtscts;
> 	fsl,dte-mode;
> 	linux,rs485-enabled-at-boot-time;
> 	rs485-rts-active-low;
> 	rs485-rx-during-tx;
> 
> Asserts the RTS signal low active just fine...

We have a (RTS active high) configuration working for us now with only

    uart-has-rtscts

in DT, and then when using the port we do

    struct serial_rs485 rs485conf;
    memset(&rs485conf, 0x00, sizeof(struct serial_rs485));

    rs485conf.flags |= SER_RS485_ENABLED;
    rs485conf.flags |= SER_RS485_RTS_ON_SEND;
    rs485conf.flags &= ~(SER_RS485_RTS_AFTER_SEND);

    f_debug("Calling ioctl...");
    if (ioctl (fd, TIOCSRS485, &rs485conf) < 0) {
      f_critical("ioctl serial_rs485 failed");
      return -1;
    }

Hope it helps.
> 
> Is this a known problem? Any idea where that could come from? It looks
> as if the receiver part is actually enabling RTS...?
> 
> Also, isn't enabling RX even in half-duplex mode quite common in order
> to detect collisions?
> 
> --
> Stefan

// Einar
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-serial" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2018-04-16  9:54 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-16  9:14 serial: imx: half-duplex RS485 operation with RTS active low Stefan Agner
2018-04-16  9:14 ` Stefan Agner
2018-04-16  9:22 ` Uwe Kleine-König
2018-04-16  9:22   ` Uwe Kleine-König
2018-04-16 10:29   ` Stefan Agner
2018-04-16 10:29     ` Stefan Agner
2018-04-16 13:01     ` Stefan Agner
2018-04-16 13:01       ` Stefan Agner
2018-04-16 13:42       ` Uwe Kleine-König
2018-04-16 13:42         ` Uwe Kleine-König
2018-04-16 16:12         ` Stefan Agner
2018-04-16 16:12           ` Stefan Agner
2018-04-16 18:02           ` Uwe Kleine-König
2018-04-16 18:02             ` Uwe Kleine-König
2018-04-16  9:54 ` Einar Vading [this message]
2018-04-16  9:54   ` Einar Vading
2018-04-16  9:57   ` Einar Vading
2018-04-16  9:57     ` Einar Vading
2018-04-16 10:35   ` Stefan Agner
2018-04-16 10:35     ` Stefan Agner

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=20180416095436.7mxh4cqdvlyleryr@lnxeinarv.se.axis.com \
    --to=einar.vading@axis.com \
    --cc=baruch@tkos.co.il \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=stefan@agner.ch \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.