linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Markus Koch <markus@notsyncing.net>
To: linux-spi@vger.kernel.org
Subject: Active-high chip select with BCM2835 SPI
Date: Sun, 14 Feb 2021 13:33:27 +0100	[thread overview]
Message-ID: <876a6779-5187-6313-3dc0-558d6efdee9a@notsyncing.net> (raw)

Hi,

I noticed that setting `spi-cs-high` in the DT, or setting the `SPI_CS_HIGH` mode flag when using spidev on my Raspberry Pi does not have any effect. It always uses an active-low chip select. However, spidev's `ioctl(fd, SPI_IOC_RD_MODE, &mode)` always reports the CS as high-active (even if I don't configure it to high).

After looking through the source code for a bit, I think that this behavior applies to all GPIO-based CS implementations. So I have a few questions about this:

1. Is this behavior expected?
	I think (haven't tried yet) the only way to actually configure the CS polarity is by reconfiguring the GPIO entry in the DT that defines the chip select polarity to be GPIO_ACTIVE_HIGH or GPIO_ACTIVE_LOW.

2. Would it be a good idea to implement a feature that changes the GPIO polarity depending on the `SPI_CS_HIGH` bit?
	Where would be the right place? (`spi_setup` in spi.c maybe?)

If this is indeed a problem, I'll look into preparing a patch. But I have a feeling this is expected behavior and I'm just overlooking something...

Thanks!
Markus

                 reply	other threads:[~2021-02-14 12:36 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=876a6779-5187-6313-3dc0-558d6efdee9a@notsyncing.net \
    --to=markus@notsyncing.net \
    --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;
as well as URLs for NNTP newsgroup(s).