linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* spi-imx: correct interpretation of num-cs DT property?
@ 2020-09-03  9:22 Matthias Schiffer
  2020-09-03 13:22 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Matthias Schiffer @ 2020-09-03  9:22 UTC (permalink / raw)
  To: Mark Brown, Rob Herring
  Cc: Shawn Guo, Sascha Hauer, Fabio Estevam, NXP Linux Team,
	linux-spi, devicetree, linux-kernel

Hi,

I've recently had a discussion about the correct way for an SPI driver
to handle the num-cs property: https://lkml.org/lkml/2020/8/25/184

Since 8cdcd8aeee281 ("spi: imx/fsl-lpspi: Convert to GPIO
descriptors"), the logic of the spi-imx driver is somewhat confusing:
If fewer than 3 cs-gpios are defined, and no explicit num-cs property
exists, the driver will set num_chipselect to 3 by default, instead of
the number of cs-gpios entries.

To avoid having to specify num-cs when the number cs-gpios would
suffice, I suggested to modify the logic to the following:

- If num-cs is set, use that
- If num-cs is unset, use the number of cs-gpios
- If num-cs is unset and no cs-gpios are defined, use a driver-provided 
default (which is 3 for spi-imx; this matches the number of native CS
pins in older implementations of this SPI controller; i.MX6 and newer
support up to 4)

Also, would it make sense to add num-cs to all DTS files for boards
that actually use fewer than 3 CS pins?

At the moment, the num-cs property is not explicitly documented for the
spi-imx driver, although the driver understands it. I also suggested to
add this to the docs, which Fabio didn't deem a good idea (I don't
quite understand the reasoning here - isn't num-cs generally a useful
property to have?)

Kind regards,
Matthias


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: spi-imx: correct interpretation of num-cs DT property?
  2020-09-03  9:22 spi-imx: correct interpretation of num-cs DT property? Matthias Schiffer
@ 2020-09-03 13:22 ` Mark Brown
  2020-09-03 13:40   ` Matthias Schiffer
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2020-09-03 13:22 UTC (permalink / raw)
  To: Matthias Schiffer
  Cc: Rob Herring, Shawn Guo, Sascha Hauer, Fabio Estevam,
	NXP Linux Team, linux-spi, devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1112 bytes --]

On Thu, Sep 03, 2020 at 11:22:20AM +0200, Matthias Schiffer wrote:

> - If num-cs is set, use that
> - If num-cs is unset, use the number of cs-gpios
> - If num-cs is unset and no cs-gpios are defined, use a driver-provided 
> default (which is 3 for spi-imx; this matches the number of native CS
> pins in older implementations of this SPI controller; i.MX6 and newer
> support up to 4)

That sounds like what's expected, though we coould just skip the first
step.

> Also, would it make sense to add num-cs to all DTS files for boards
> that actually use fewer than 3 CS pins?

No, it was never a good idea to have that property in the first place
and there should be no case where it helps anything.

> At the moment, the num-cs property is not explicitly documented for the
> spi-imx driver, although the driver understands it. I also suggested to
> add this to the docs, which Fabio didn't deem a good idea (I don't
> quite understand the reasoning here - isn't num-cs generally a useful
> property to have?)

Could you explain what benefit you would expect having num-cs to offer?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: spi-imx: correct interpretation of num-cs DT property?
  2020-09-03 13:22 ` Mark Brown
@ 2020-09-03 13:40   ` Matthias Schiffer
  2020-09-03 13:47     ` Fabio Estevam
  0 siblings, 1 reply; 4+ messages in thread
From: Matthias Schiffer @ 2020-09-03 13:40 UTC (permalink / raw)
  To: Mark Brown
  Cc: Rob Herring, Shawn Guo, Sascha Hauer, Fabio Estevam,
	NXP Linux Team, linux-spi, devicetree, linux-kernel

On Thu, 2020-09-03 at 14:22 +0100, Mark Brown wrote:
> * PGP Signed by an unknown key
> 
> On Thu, Sep 03, 2020 at 11:22:20AM +0200, Matthias Schiffer wrote:
> 
> > - If num-cs is set, use that
> > - If num-cs is unset, use the number of cs-gpios
> > - If num-cs is unset and no cs-gpios are defined, use a driver-
> > provided 
> > default (which is 3 for spi-imx; this matches the number of native
> > CS
> > pins in older implementations of this SPI controller; i.MX6 and
> > newer
> > support up to 4)
> 
> That sounds like what's expected, though we coould just skip the
> first
> step.
> 
> > Also, would it make sense to add num-cs to all DTS files for boards
> > that actually use fewer than 3 CS pins?
> 
> No, it was never a good idea to have that property in the first place
> and there should be no case where it helps anything.


Oh, thank you for the clarification.

As currently no in-tree DTs use the num-cs property for spi-imx and
it's not documented, should support for it be dropped from the driver
altogether?


> 
> > At the moment, the num-cs property is not explicitly documented for
> > the
> > spi-imx driver, although the driver understands it. I also
> > suggested to
> > add this to the docs, which Fabio didn't deem a good idea (I don't
> > quite understand the reasoning here - isn't num-cs generally a
> > useful
> > property to have?)
> 
> Could you explain what benefit you would expect having num-cs to
> offer?
> 
> * Unknown Key
> * 0x5D5487D0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: spi-imx: correct interpretation of num-cs DT property?
  2020-09-03 13:40   ` Matthias Schiffer
@ 2020-09-03 13:47     ` Fabio Estevam
  0 siblings, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2020-09-03 13:47 UTC (permalink / raw)
  To: Matthias Schiffer
  Cc: Mark Brown, Rob Herring, Shawn Guo, Sascha Hauer, NXP Linux Team,
	linux-spi,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linux-kernel

Hi Matthias,

On Thu, Sep 3, 2020 at 10:40 AM Matthias Schiffer
<matthias.schiffer@ew.tq-group.com> wrote:

> As currently no in-tree DTs use the num-cs property for spi-imx and
> it's not documented, should support for it be dropped from the driver
> altogether?

Yes, it makes sense to drop num-cs support from the spi-imx driver.

Care to send a patch?

Thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-03 15:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-03  9:22 spi-imx: correct interpretation of num-cs DT property? Matthias Schiffer
2020-09-03 13:22 ` Mark Brown
2020-09-03 13:40   ` Matthias Schiffer
2020-09-03 13:47     ` Fabio Estevam

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).