Generic Linux architectural discussions
 help / color / mirror / Atom feed
From: Rodolfo Giometti <giometti@enneenne.com>
To: Richard Genoud <richard.genoud@gmail.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: Thu, 12 Sep 2019 14:47:59 +0200	[thread overview]
Message-ID: <c7a63468-4e29-2bbd-912d-4583098507af@enneenne.com> (raw)
In-Reply-To: <c9860c7f-bd06-86aa-c3c0-74e2e1617cae@gmail.com>

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? :-)

Thanks for your help,

Rodolfo Giometti

-- 
GNU/Linux Solutions                  e-mail: giometti@enneenne.com
Linux Device Driver                          giometti@linux.it
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti

  reply	other threads:[~2019-09-12 12:55 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 [this message]
2019-09-13 14:36       ` Richard Genoud
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=c7a63468-4e29-2bbd-912d-4583098507af@enneenne.com \
    --to=giometti@enneenne.com \
    --cc=arnd@arndb.de \
    --cc=giometti@linux.it \
    --cc=gregkh@linuxfoundation.org \
    --cc=joshua.henderson@microchip.com \
    --cc=jslaby@suse.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=richard.genoud@gmail.com \
    /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