linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Måns Rullgård" <mans@mansr.com>
To: Mark Brown <broonie@kernel.org>
Cc: Cyrille Pitchen <cyrille.pitchen@atmel.com>,
	Nicolas Ferre <nicolas.ferre@atmel.com>,
	linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
	Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>
Subject: Re: [PATCH v3 1/3] spi: atmel: add support for the internal chip-select of the spi controller
Date: Thu, 07 Jan 2016 16:14:12 +0000	[thread overview]
Message-ID: <yw1xvb75z7sb.fsf@unicorn.mansr.com> (raw)
In-Reply-To: <20160107154024.GF6588@sirena.org.uk> (Mark Brown's message of "Thu, 7 Jan 2016 15:40:24 +0000")

Mark Brown <broonie@kernel.org> writes:

> On Tue, Jan 05, 2016 at 09:50:54PM +0000, Måns Rullgård wrote:
>> Cyrille Pitchen <cyrille.pitchen@atmel.com> writes:
>
>> > +	as->use_cs_gpios = true;
>> > +	if (atmel_spi_is_v2(as) &&
>> > +	    !of_get_property(pdev->dev.of_node, "cs-gpios", NULL)) {
>> > +		as->use_cs_gpios = false;
>> > +		master->num_chipselect = 4;
>> > +	}
>
>> This part breaks the AVR32 boards and probably anything else that
>> doesn't use devicetree but does use GPIOs for chip select.
>
> Shouldn't this just be setting defaults for the case where nothing is
> provided?

Traditionally the platform data included a GPIO number to use and that
was that.  At some point DT support was added wherein the platform data
is overridden by cs_gpio from struct spi_device if this is valid (it is
set to a negative value by default).  Thus far all was well.  Then came
this patch.  It assumes that everybody uses DT and treats a missing
cs-gpios property as indication that the controller's own pins should be
used.  It also assumes that if any device uses GPIO for CS all of them
do, even though the SPI core driver might provide a partial list
(probably since many boards don't use all the available chip selects,
but it doesn't prevent someone abusing this).

To work correctly in call cases, this driver should use, for each
peripheral, the following priority:

- spi->cs_gpio (filled from DT or -ENOENT)
- GPIO from platform data
- controller chip select pin

The trouble is that there is no way to reliably tell a valid GPIO number
of zero in the platform data from an unset value.  In practice, I
believe existing old boards using this driver all use a non-zero GPIO
(the AVR32 platform code requires this), so checking for a non-zero
number is probably sufficient.  I'll cook up a patch for this unless
someone objects.

-- 
Måns Rullgård

  reply	other threads:[~2016-01-07 16:14 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-09 11:53 [PATCH v3 0/3] spi: atmel: add support to FIFOs and the internal chip-select Cyrille Pitchen
2015-06-09 11:53 ` [PATCH v3 1/3] spi: atmel: add support for the internal chip-select of the spi controller Cyrille Pitchen
2015-06-09 12:15   ` Nicolas Ferre
2015-06-09 17:26   ` Mark Brown
2016-01-05 21:50   ` Måns Rullgård
2016-01-07 15:40     ` Mark Brown
2016-01-07 16:14       ` Måns Rullgård [this message]
2016-01-27 15:46     ` Nicolas Ferre
2016-01-27 15:53       ` Måns Rullgård
2016-01-27 16:55         ` Nicolas Ferre
2016-01-27 16:57           ` Måns Rullgård
2015-06-09 11:53 ` [PATCH v3 2/3] spi: atmel: update DT bindings documentation Cyrille Pitchen
2015-06-09 12:15   ` Nicolas Ferre
2015-06-09 17:25   ` Mark Brown
2015-06-11 16:37     ` Cyrille Pitchen
2015-06-15 15:49       ` Mark Brown
2015-06-09 11:53 ` [PATCH v3 3/3] spi: atmel: add support to FIFOs Cyrille Pitchen
2015-06-09 12:24   ` Nicolas Ferre
2015-06-09 17:30   ` Mark Brown

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=yw1xvb75z7sb.fsf@unicorn.mansr.com \
    --to=mans@mansr.com \
    --cc=broonie@kernel.org \
    --cc=cyrille.pitchen@atmel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=nicolas.ferre@atmel.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@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).