Linux SPI subsystem development
 help / color / mirror / Atom feed
From: Baruch Siach <baruch@tkos.co.il>
To: linux-spi@vger.kernel.org
Subject: Change CPHA in the middle of transaction
Date: Wed, 06 Apr 2022 13:38:57 +0300	[thread overview]
Message-ID: <87sfqqfq54.fsf@tarshish> (raw)

Hi linux-spi list,

I am trying to communicate with an SPI device that latches MOSI bits on the
rising edge of the clock, while MISO bits are latched on the falling
edge. Fortunately, MOSI and MISO bits are not simultaneous. So Tx/Rx
work if SPI master changes CPHA at the right time with chip-select asserted.

It looks like generic SPI code provides no way to flip CPHA for different
spi_transfer in the context of a single spi_message. At the drivers level,
some drivers program SPI mode per spi_transfer (e.g. spi-imx mx1/mx21/mx31
variants), while others do that per spi_message (e.g. spi-imx mx51 variant).

I can hack around the problem from userspace with manual control of the GPIO
chip-select signal, and separate spidev SPI_IOC_MESSAGE calls with
SPI_IOC_RD_MODE in between. Not very nice.

I think about adding SPI_RX_CPHA_FLIP mode bit for that. Hardware that
supports separate MISO/MOSI CPHA can program that permanently for spi_device
that needs it (is there any such SPI master?). If not, the driver flips CPHA
when spi_transfer tx_buf is NULL.

Would that be acceptable?

Any other suggestion?

Thanks,
baruch

-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -

                 reply	other threads:[~2022-04-06 14:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=87sfqqfq54.fsf@tarshish \
    --to=baruch@tkos.co.il \
    --cc=linux-spi@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