Subject: Re: spi_mpc8xxx.c: chip select polarity problem

From: Anton Vorontsov <[email-masked]>
Date: Thu, 26 Nov 2009 15:12:04 +0300

On Wed, Nov 25, 2009 at 03:11:57PM -0700, Grant Likely wrote:
> On Wed, Nov 25, 2009 at 1:41 PM, Torsten Fleischer
> <[email-masked]> wrote:
> > On Wen, Nov 25, 2009 at 01:33:57 Grant Likely wrote:
> >> Thanks.  However, there needs to be a proper description of what this
> >> patch does to go in the commit header.  Can you please write one?
> >>
> >> Thanks,
> >> g.
> >>
> > [...]
> >
> > The initialization of the chip selects is removed from the probe() function of
> > the spi_mpc8xxx driver, because the driver doesn't know the polarity of the
> > chip selects of the SPI devices at the time of its initialization.
> >
> > For this reason the initialization of the several chip selects is postponed
> > to the point of time when the very first SPI transfer to the associated device
> > occurs.
> >
> >
> > Signed-off-by: Torsten Fleischer <[email-masked]>
> 
> Ah.  I understand what you're doing now.   Hmmm.  This approach
> concerns me because it relies on firmware or platform code to get CS
> gpios set up properly before the driver is probed.

Yes, that was said at the very beginning of this thread.

>  Firmware doesn't
> always get it right, and I prefer to avoid platform specific setups as
> much as possible.  Why can't the CS polarity be encoded into the
> device tree so the driver *does* have the polarity data at probe time?

We have the spi-cs-high property, but it duplicates compatible
property. 'compatible' is enough to tell whether some device has
cs-high or cs-low (device's driver knows that already).

The problem is that SPI bus master doesn't know all the devices,
so it can't extract that information from the compatible string.
To workaround that we can use 'spi-cs-high', but that's ugly
workaround.

SPI modes (0,1,2,3) is another matter, some devices can work in
several modes, so 'spi-cpol' and 'spi-cpha' are actually useful.

-- 
Anton Vorontsov
email: [email-masked]
irc://irc.freenode.net/bd2