linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Torsten Fleischer <to-fleischer@t-online.de>
To: linuxppc-dev@lists.ozlabs.org
Subject: spi_mpc8xxx.c: chip select polarity problem
Date: Mon, 16 Nov 2009 17:42:46 +0100	[thread overview]
Message-ID: <200911161742.46663.to-fleischer@t-online.de> (raw)

Hi all,

I have 3 devices connected to the SPI bus of the MPC8313. For the Chip Select 
(CS) signals 3 GPIOs of the controller are used. But the driver uses the 
inverse polarity of the CS either during the initialization or at the transfer 
- depending on the setup of the flattened device tree.

Here is what I discovered:
The driver uses a polarity flag for each CS signal (the alow_flags array). 
These flags are set according to the 'gpios' property of the SPI node of the 
flattened device tree.
Is it correct that alow_flags[x] = 1 means CSx is active low?

During the initialization the driver sets the CS to the value of 
alow_flags[x]. I.e. CSx is High if alow_flags[x] = 1 and otherwise Low.

The flags are used in the function mpc8xxx_spi_cs_control() to take care about 
the polarity when setting the appropriate GPIO pin. But the function 
mpc8xxx_spi_chipselect() that calls the mpc8xxx_spi_cs_control() takes also 
care about the polarity of the CS (bool pol = spi->mode & SPI_CS_HIGH).

Lets assume alow_flags[x] = 1 and the property 'spi-cs-high' is not set for 
the SPI device. During initialization the driver sets the chip select signal 
'x' to High (see of_mpc8xxx_spi_get_chipselects()). This is OK if the chip 
select is active low, because this disables the device on start-up. But during 
the transfer the chip select signal is High and after the transfer is 
completed the signal is set to Low. This is not the intended behavior for an 
active low chip select.

I also tried to set alow_flags[x] = 0 for active low. In this case the 
transfer works, but the initial value for the CS is wrong (Low instead of 
High).

The problem seems to be that the polarity is taken into account twice (as 
described above).
So what would be the better solution: removing the usage of the alow_flags in 
mpc8xxx_spi_cs_control() or the variable 'pol' in mpc8xxx_spi_chipselect()?

Best Regards
Torsten Fleischer

             reply	other threads:[~2009-11-16 16:43 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-16 16:42 Torsten Fleischer [this message]
2009-11-16 17:10 ` spi_mpc8xxx.c: chip select polarity problem Anton Vorontsov
2009-11-16 18:00   ` Anton Vorontsov
2009-11-17 20:09     ` Torsten Fleischer
2009-11-17 20:22       ` Anton Vorontsov
2009-11-17 23:28         ` Anton Vorontsov
2009-11-18 16:20           ` Torsten Fleischer
2009-11-18 23:29             ` Anton Vorontsov
2009-11-21  8:45               ` Grant Likely
2009-11-21 16:08                 ` Torsten Fleischer
2009-11-25  0:33                   ` Grant Likely
2009-11-25 20:41                     ` Torsten Fleischer
2009-11-25 22:11                       ` Grant Likely
2009-11-26 12:12                         ` Anton Vorontsov
2009-11-26 17:27                           ` Torsten Fleischer
2009-11-26 18:18                             ` Grant Likely
2009-11-26 18:16                           ` Grant Likely
2009-11-26 18:41                             ` Anton Vorontsov
2009-11-26 18:50                               ` Grant Likely
2009-11-26 19:01                                 ` Anton Vorontsov
2009-11-26 19:17                                   ` Grant Likely
2009-12-09 15:49                                     ` Torsten Fleischer
2009-12-09 17:46                                       ` Grant Likely
2009-12-09 19:13                                         ` Torsten Fleischer
2009-12-14 16:54                                         ` Torsten Fleischer

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=200911161742.46663.to-fleischer@t-online.de \
    --to=to-fleischer@t-online.de \
    --cc=linuxppc-dev@lists.ozlabs.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).