From: Richard Genoud <richard.genoud@gmail.com>
To: Rodolfo Giometti <giometti@enneenne.com>, linux-arch@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jslaby@suse.com>, Arnd Bergmann <arnd@arndb.de>,
Rodolfo Giometti <giometti@linux.it>,
Joshua Henderson <joshua.henderson@microchip.com>
Subject: Re: [PATCH 1/2] tty: add bits to manage multidrop mode
Date: Fri, 13 Sep 2019 16:36:02 +0200 [thread overview]
Message-ID: <f0071444-7885-db74-ba50-17f3e7fae1f7@gmail.com> (raw)
In-Reply-To: <c7a63468-4e29-2bbd-912d-4583098507af@enneenne.com>
Le 12/09/2019 à 14:47, Rodolfo Giometti a écrit :
> On 12/09/2019 13:01, Richard Genoud wrote:
>> Hi Rodolfo,
>>
>> You could also add these mailing lists:
>> - linux-serial@vger.kernel.org
>> - linux-arm-kernel@lists.infradead.org
>> - linux-kernel@vger.kernel.org
>
> OK. No problem!
>
>> For reference, I've dug the conversation we had 2 years ago:
>> 0/2 : https://marc.info/?t=149192176100002&r=1&w=2
>> 1/2 : https://marc.info/?t=149192176300001&r=1&w=2
>> 2/2 : https://marc.info/?t=149192176700001&r=1&w=2
>
> Thanks.
>
>> And, like I said at that time, one problem I see with this
>> implementation (setting a SENDA bit that automatically unsets itself)
>> will break the way tcgetattr() is working:
>> https://marc.info/?l=linux-serial&m=149209522108027&w=2
>
> I see... however the problem here is that this attribute is not sticky and it is
> reset by the controller after the first byte as been sent. Here is how
> Atmel/Microchip multidrop works (from the SAMA5D3's datasheet):
>
> 44.7.3.9 Multidrop Mode
> If the value 0x6 or 0x07 is written to the PAR field in the US_MR, the USART
> runs in Multidrop Mode. This mode differentiates the data characters and the
> address characters. Data is transmitted with the parity bit to 0 and addresses
> are transmitted with the parity bit to 1.
> ...
> The transmitter sends an address byte (parity bit set) when SENDA is written to
> in the US_CR. In this case, the next byte written to the US_THR is transmitted
> as an address. Any character written in the US_THR without having written the
> command SENDA is transmitted normally with the parity to 0.
>
> So, if we have a 4 bytes message where the first one is the address byte we can
> use multidrop by setting the SENDA bit at the beginning and then by just
> invoking a write() with the four bytes message. The controller automatically
> will set the 9th bit to 1 for the first byte and then to 0 for the following
> three bytes.
>
> To do so we need a syscall to tell to the controller when the address bit
> (SENDA) must be set, each time, before sending the message.
>
> In this implementation I used the syscall within tcsetattr() function but if
> this is not right, then I have to use another one... maybe a custom ioctl? Or
> can you please suggest a suitable solution? :-)
What's bothering me with this implementation, is that it's too close to
the hardware. Some other micro-controllers may not have the SENDA bit.
For instance, i.MX6ULL:
--->8----
To transmit 9-bit RS-485 frames, user need to enable parity (PREN=1) to
enable
trasmitting the ninth data bit, set 8-bit data word size (WS=1), and
write TXB8
(UMCR[2]) as the 9 th bit (bit [8]) to be transmitted (write '0' to TXB8
to transmit a data
frame, write '1' to transmit a address frame). The other data bit [7:0]
is written to TxFIFO
by writing to the UTXD same as normal RS-232 operation.
---8<----
And the TXB8 bit doesn't seem to clear itself automatically.
I maybe wrong, but I think that writing a line discipline for multidrop
mode would be more versatile.
Regards,
Richard
>
> Thanks for your help,
>
> Rodolfo Giometti
>
next prev parent reply other threads:[~2019-09-13 14:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-12 8:40 Multidrop support Rodolfo Giometti
2019-09-12 8:40 ` [PATCH 1/2] tty: add bits to manage multidrop mode Rodolfo Giometti
2019-09-12 8:48 ` Arnd Bergmann
2019-09-12 11:01 ` Richard Genoud
2019-09-12 12:47 ` Rodolfo Giometti
2019-09-13 14:36 ` Richard Genoud [this message]
2019-09-12 8:40 ` [PATCH 2/2] tty serial: add multidrop support for atmel serial controllers Rodolfo Giometti
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=f0071444-7885-db74-ba50-17f3e7fae1f7@gmail.com \
--to=richard.genoud@gmail.com \
--cc=arnd@arndb.de \
--cc=giometti@enneenne.com \
--cc=giometti@linux.it \
--cc=gregkh@linuxfoundation.org \
--cc=joshua.henderson@microchip.com \
--cc=jslaby@suse.com \
--cc=linux-arch@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