linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Michael Barkowski <michaelbarkowski@ruggedcom.com>
To: linuxppc-dev@ozlabs.org
Subject: [PATCH] mpc8xxx_spi: Fix polarity inversion in chipselect
Date: Tue, 18 Aug 2009 11:08:24 -0400	[thread overview]
Message-ID: <4A8AC3E8.5070301@ruggedcom.com> (raw)

If we use open firmware, then alow_flags handles active-low
chipselects, which is the same as SPI_CS_HIGH. This patch fixes the
double negative.

Signed-off-by: Michael Barkowski <michaelbarkowski@ruggedcom.com>
---
Anton,

thanks to your device table matching support patch I can use open firmware
to configure two spi devices on 8360E.  I use the gpios node, with flags set
to 1, matching OF_GPIO_ACTIVE_LOW.  When I do this I notice that the polarity
was already handled in a different way.  Did some searching and didn't find
it had been discussed.  Here's what I am doing now - feel free to use it or
abuse it :) (based in galak-powerpc/next plus your patches 1 and 2)

 drivers/spi/spi_mpc8xxx.c |   10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/spi/spi_mpc8xxx.c b/drivers/spi/spi_mpc8xxx.c
index 0fd0ec4..36bda94 100644
--- a/drivers/spi/spi_mpc8xxx.c
+++ b/drivers/spi/spi_mpc8xxx.c
@@ -159,14 +159,8 @@ static void mpc8xxx_spi_chipselect(struct spi_device *spi, int value)
 {
 	struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master);
 	struct fsl_spi_platform_data *pdata = spi->dev.parent->platform_data;
-	bool pol = spi->mode & SPI_CS_HIGH;
 	struct spi_mpc8xxx_cs	*cs = spi->controller_state;
 
-	if (value == BITBANG_CS_INACTIVE) {
-		if (pdata->cs_control)
-			pdata->cs_control(spi, !pol);
-	}
-
 	if (value == BITBANG_CS_ACTIVE) {
 		u32 regval = mpc8xxx_spi_read_reg(&mpc8xxx_spi->base->mode);
 
@@ -189,9 +183,9 @@ static void mpc8xxx_spi_chipselect(struct spi_device *spi, int value)
 			mpc8xxx_spi_write_reg(mode, regval);
 			local_irq_restore(flags);
 		}
-		if (pdata->cs_control)
-			pdata->cs_control(spi, pol);
 	}
+	if (pdata->cs_control)
+		pdata->cs_control(spi, value);
 }
 
 static
-- 
1.6.3.3

             reply	other threads:[~2009-08-18 15:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-18 15:08 Michael Barkowski [this message]
2009-08-18 15:16 ` [PATCH] mpc8xxx_spi: Fix polarity inversion in chipselect Michael Barkowski
2009-08-18 16:02   ` Michael Barkowski

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=4A8AC3E8.5070301@ruggedcom.com \
    --to=michaelbarkowski@ruggedcom.com \
    --cc=linuxppc-dev@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).