public inbox for linux-serial@vger.kernel.org
 help / color / mirror / Atom feed
* RS-485 automatic RTS toggle in Linux (on Winbond W83627UHG)
@ 2011-11-29 17:20 Tomas Lastovicka
  2011-11-29 17:57 ` Wolfram Sang
  0 siblings, 1 reply; 8+ messages in thread
From: Tomas Lastovicka @ 2011-11-29 17:20 UTC (permalink / raw)
  To: linux-serial

Hi,

i am trying to use a Linux running embedded PC with built-it RS-485
port as a master to control one slave device. My problem is the usual
one, i can not figure out how to perform an automatic RTS toggle. I.e.
to send data to 485 and after the last byte was sent, quickly switch
to the read mode (but not from my code in the user space). The Linux
kernel is 2.6.32 and an automatic RTS toggle is not natively
supported. Googling this issue around, i found a couple of suggestions
but no solution (except drivers for Atmel and Etrax since kernel
2.6.38).

Does anyone has experience with RS-485 in embedded real-time Linux
PCs? The chip used is Winbond W83627UHG and looking into its
documentation, it is not obvious to me how to handle the RTS toggle
properly. I can write and read to/from 485 but i have to toggle RTS by
hand from my code, which is not what i want to do and it does not
quite work with the slave device either.

Cheers,

Tomas

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: RS-485 automatic RTS toggle in Linux (on Winbond W83627UHG)
  2011-11-29 17:20 RS-485 automatic RTS toggle in Linux (on Winbond W83627UHG) Tomas Lastovicka
@ 2011-11-29 17:57 ` Wolfram Sang
  2011-11-29 22:13   ` Tomas Lastovicka
  0 siblings, 1 reply; 8+ messages in thread
From: Wolfram Sang @ 2011-11-29 17:57 UTC (permalink / raw)
  To: Tomas Lastovicka; +Cc: linux-serial

[-- Attachment #1: Type: text/plain, Size: 622 bytes --]

> supported. Googling this issue around, i found a couple of suggestions
> but no solution (except drivers for Atmel and Etrax since kernel
> 2.6.38).

Judging from the datasheet, the device can do hardware based RS485,
nice. So look at those drivers you mentioned above how they handle the
RS485-related IOCTLs and adapt the bits for the hardware configuration.
Should be more fun with a newer kernel, but I think it is doable.

Regards,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: RS-485 automatic RTS toggle in Linux (on Winbond W83627UHG)
  2011-11-29 17:57 ` Wolfram Sang
@ 2011-11-29 22:13   ` Tomas Lastovicka
  2011-11-29 22:20     ` Wolfram Sang
  0 siblings, 1 reply; 8+ messages in thread
From: Tomas Lastovicka @ 2011-11-29 22:13 UTC (permalink / raw)
  To: linux-serial, Wolfram Sang

Unless i have overlooked something, i do not see how to toggle the
automatic RTS mode from W83627UHG's datasheet. Have you found it?

Regarding 2.6.38+ drivers, Atmel supports RS485 on the hardware level
and Etrax is handling the RTS toggling directly from the driver. I
guess this is what i will finally have to do, i.e. to toggle RTS from
the driver myself.

I am surprised that the RTS toggling issue for RS485 in Linux is
around for quite a while.

Cheers,

Tomas


On Tue, Nov 29, 2011 at 12:57 PM, Wolfram Sang <w.sang@pengutronix.de> wrote:
>> supported. Googling this issue around, i found a couple of suggestions
>> but no solution (except drivers for Atmel and Etrax since kernel
>> 2.6.38).
>
> Judging from the datasheet, the device can do hardware based RS485,
> nice. So look at those drivers you mentioned above how they handle the
> RS485-related IOCTLs and adapt the bits for the hardware configuration.
> Should be more fun with a newer kernel, but I think it is doable.
>
> Regards,
>
>   Wolfram
>
> --
> Pengutronix e.K.                           | Wolfram Sang                |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iEYEARECAAYFAk7VHQgACgkQD27XaX1/VRsO2wCfXOsvPoOtw8QV8YzkKHocp6K8
> lYEAnR/OExYTbdEtEqT8Dgl3Y/TCra83
> =0ZuI
> -----END PGP SIGNATURE-----
>
>
--
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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: RS-485 automatic RTS toggle in Linux (on Winbond W83627UHG)
  2011-11-29 22:13   ` Tomas Lastovicka
@ 2011-11-29 22:20     ` Wolfram Sang
  2011-11-29 22:25       ` Tomas Lastovicka
  0 siblings, 1 reply; 8+ messages in thread
From: Wolfram Sang @ 2011-11-29 22:20 UTC (permalink / raw)
  To: Tomas Lastovicka; +Cc: linux-serial

[-- Attachment #1: Type: text/plain, Size: 1030 bytes --]


> Unless i have overlooked something, i do not see how to toggle the
> automatic RTS mode from W83627UHG's datasheet. Have you found it?

Yes, searching for '485' gives you all the info you need (if we got the same
datasheet).

> Regarding 2.6.38+ drivers, Atmel supports RS485 on the hardware level
> and Etrax is handling the RTS toggling directly from the driver. I

Hardware level is the only official supported way in Linux. Software toggling
can easily fail due to preemption.

> guess this is what i will finally have to do, i.e. to toggle RTS from
> the driver myself.

Why? If the hardware has support?

> I am surprised that the RTS toggling issue for RS485 in Linux is
> around for quite a while.

It has come a long way, but all you need is there now (except for software
based direction control, see above).

Regards,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: RS-485 automatic RTS toggle in Linux (on Winbond W83627UHG)
  2011-11-29 22:20     ` Wolfram Sang
@ 2011-11-29 22:25       ` Tomas Lastovicka
  2011-11-29 22:36         ` Wolfram Sang
  0 siblings, 1 reply; 8+ messages in thread
From: Tomas Lastovicka @ 2011-11-29 22:25 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-serial

Then i definitely have a different datasheet (v1.41). No 485 matches were found.
Indeed, if it has support then there is no need for software toggle
(although i still think it is done this way in the Etrax driver coming
with the kernel).


On Tue, Nov 29, 2011 at 5:20 PM, Wolfram Sang <w.sang@pengutronix.de> wrote:
>
>> Unless i have overlooked something, i do not see how to toggle the
>> automatic RTS mode from W83627UHG's datasheet. Have you found it?
>
> Yes, searching for '485' gives you all the info you need (if we got the same
> datasheet).
>
>> Regarding 2.6.38+ drivers, Atmel supports RS485 on the hardware level
>> and Etrax is handling the RTS toggling directly from the driver. I
>
> Hardware level is the only official supported way in Linux. Software toggling
> can easily fail due to preemption.
>
>> guess this is what i will finally have to do, i.e. to toggle RTS from
>> the driver myself.
>
> Why? If the hardware has support?
>
>> I am surprised that the RTS toggling issue for RS485 in Linux is
>> around for quite a while.
>
> It has come a long way, but all you need is there now (except for software
> based direction control, see above).
>
> Regards,
>
>   Wolfram
>
> --
> Pengutronix e.K.                           | Wolfram Sang                |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
>
--
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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: RS-485 automatic RTS toggle in Linux (on Winbond W83627UHG)
  2011-11-29 22:25       ` Tomas Lastovicka
@ 2011-11-29 22:36         ` Wolfram Sang
  2011-11-29 23:15           ` Tomas Lastovicka
  0 siblings, 1 reply; 8+ messages in thread
From: Wolfram Sang @ 2011-11-29 22:36 UTC (permalink / raw)
  To: Tomas Lastovicka; +Cc: linux-serial

[-- Attachment #1: Type: text/plain, Size: 932 bytes --]

On Tue, Nov 29, 2011 at 05:25:32PM -0500, Tomas Lastovicka wrote:

> Then i definitely have a different datasheet (v1.41). No 485 matches were found.

I got v1.7:

http://www.nuvoton.com/NuvotonMOSS/Community/ProductInfo.aspx?tp_GUID=8310ab06-af65-4ec9-92a6-17cf791aa9f2

Ah, it says RS485 is only available on Revision E. Hopefully, you have that.

> Indeed, if it has support then there is no need for software toggle
> (although i still think it is done this way in the Etrax driver coming
> with the kernel).

I think that was the first RS485 one, so probably just lucky ;)

If you are interested, another series adding support for 8250-variants that
have HW support can be found here:

http://lkml.org/lkml/2011/11/16/270

Regards,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: RS-485 automatic RTS toggle in Linux (on Winbond W83627UHG)
  2011-11-29 22:36         ` Wolfram Sang
@ 2011-11-29 23:15           ` Tomas Lastovicka
  2011-12-07 11:58             ` Tomas Lastovicka
  0 siblings, 1 reply; 8+ messages in thread
From: Tomas Lastovicka @ 2011-11-29 23:15 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-serial

Thanks for both links Wolfram! I will find out what revision i actually have.

Best,
Tomas


On Tue, Nov 29, 2011 at 5:36 PM, Wolfram Sang <w.sang@pengutronix.de> wrote:
> On Tue, Nov 29, 2011 at 05:25:32PM -0500, Tomas Lastovicka wrote:
>
>> Then i definitely have a different datasheet (v1.41). No 485 matches were found.
>
> I got v1.7:
>
> http://www.nuvoton.com/NuvotonMOSS/Community/ProductInfo.aspx?tp_GUID=8310ab06-af65-4ec9-92a6-17cf791aa9f2
>
> Ah, it says RS485 is only available on Revision E. Hopefully, you have that.
>
>> Indeed, if it has support then there is no need for software toggle
>> (although i still think it is done this way in the Etrax driver coming
>> with the kernel).
>
> I think that was the first RS485 one, so probably just lucky ;)
>
> If you are interested, another series adding support for 8250-variants that
> have HW support can be found here:
>
> http://lkml.org/lkml/2011/11/16/270
>
> Regards,
>
>   Wolfram
>
> --
> Pengutronix e.K.                           | Wolfram Sang                |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
>
--
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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: RS-485 automatic RTS toggle in Linux (on Winbond W83627UHG)
  2011-11-29 23:15           ` Tomas Lastovicka
@ 2011-12-07 11:58             ` Tomas Lastovicka
  0 siblings, 0 replies; 8+ messages in thread
From: Tomas Lastovicka @ 2011-12-07 11:58 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-serial

Hi,

to conclude this thread: the Winbond W83627UHG, used in my brand new
device, really does not support the automatic RTS toggle for the
RS-485 line. Thus the most appropriate solution appears to be the RTS
toggling from within a driver.

Cheers,
Tomas


On Tue, Nov 29, 2011 at 6:15 PM, Tomas Lastovicka
<tomas.lastovicka@gmail.com> wrote:
> Thanks for both links Wolfram! I will find out what revision i actually have.
>
> Best,
> Tomas
>
>
> On Tue, Nov 29, 2011 at 5:36 PM, Wolfram Sang <w.sang@pengutronix.de> wrote:
>> On Tue, Nov 29, 2011 at 05:25:32PM -0500, Tomas Lastovicka wrote:
>>
>>> Then i definitely have a different datasheet (v1.41). No 485 matches were found.
>>
>> I got v1.7:
>>
>> http://www.nuvoton.com/NuvotonMOSS/Community/ProductInfo.aspx?tp_GUID=8310ab06-af65-4ec9-92a6-17cf791aa9f2
>>
>> Ah, it says RS485 is only available on Revision E. Hopefully, you have that.
>>
>>> Indeed, if it has support then there is no need for software toggle
>>> (although i still think it is done this way in the Etrax driver coming
>>> with the kernel).
>>
>> I think that was the first RS485 one, so probably just lucky ;)
>>
>> If you are interested, another series adding support for 8250-variants that
>> have HW support can be found here:
>>
>> http://lkml.org/lkml/2011/11/16/270
>>
>> Regards,
>>
>>   Wolfram
>>
>> --
>> Pengutronix e.K.                           | Wolfram Sang                |
>> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
>>
--
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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-12-07 11:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-29 17:20 RS-485 automatic RTS toggle in Linux (on Winbond W83627UHG) Tomas Lastovicka
2011-11-29 17:57 ` Wolfram Sang
2011-11-29 22:13   ` Tomas Lastovicka
2011-11-29 22:20     ` Wolfram Sang
2011-11-29 22:25       ` Tomas Lastovicka
2011-11-29 22:36         ` Wolfram Sang
2011-11-29 23:15           ` Tomas Lastovicka
2011-12-07 11:58             ` Tomas Lastovicka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox