Skip to contentSkip to conversation

mpc8xxx_spi: Fix polarity inversion in chipselect

PATCH In review Michael Barkowski 1 participant 3 messages Aug 18, 2009 SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mpc8xxx_spi: Fix polarity inversion in chipselect

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.

---
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(-)
drivers/spi/spi_mpc8xxx.c +2 -8
index 0fd0ec4..36bda94 100644
@@ -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
Signature · 1 line
1.6.3.3
#1 lore raw
Quoted 3 lines · Michael Barkowski

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.

Hang on - I missed your most recent patches to spi_mpc8xxx

--Michael

#2 lore raw

Anton - thanks for the offline correction.

SPI_CS_HIGH means that the device interprets high as active. The alow flag means there is an inverter somewhere.

My mistake - patch retracted.

Signature · 1 line
Michael