Skip to contentSkip to conversation

fix SPI_CPHA related errors

PATCH In review David Brownell 3 participants 3 messages May 23, 2007 – May 25, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix SPI_CPHA related errors

The OMAP SPI controller drivers handle SPI_CPHA incorrectly. It should mean:

CPHA=0 ... sample at leading edge of clock
CPHA=1 ... sample at trailing edge of clock

This fixes them, and the protocol drivers which depended on the wrong meaning. Separate ads7846 and omap_uwire patches are going upstream, already since those drivers were already pushed there. The tsc2102 code already had this right ... strange.

---
 drivers/input/touchscreen/tsc2046_ts.c |    2 +-
 drivers/spi/omap2_mcspi.c              |    4 ++--
 drivers/spi/tsc2101.c                  |    2 +-
 drivers/spi/tsc2301-core.c             |    2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
drivers/spi/omap2_mcspi.c +2 -2
@@ -550,9 +550,9 @@ static int omap2_mcspi_setup_transfer(st
 	else
 		l &= ~OMAP2_MCSPI_CHCONF_POL;
 	if (spi->mode & SPI_CPHA)
-		l &= ~OMAP2_MCSPI_CHCONF_PHA;
-	else
 		l |= OMAP2_MCSPI_CHCONF_PHA;
+	else
+		l &= ~OMAP2_MCSPI_CHCONF_PHA;
 	mcspi_write_cs_reg(spi, OMAP2_MCSPI_CHCONF0, l);
 
 	dev_dbg(&spi->dev, "setup: speed %d, sample %s edge, clk %s inverted\n",
drivers/spi/tsc2101.c +1 -1
@@ -237,7 +237,7 @@ static int tsc2101_probe(struct spi_devi
 
 	mutex_init(&tsc2101->mutex);
 
-	spi->mode = SPI_MODE_0;
+	spi->mode = SPI_MODE_1;
 	spi->bits_per_word = 16;
 	if ((r = spi_setup(spi)) < 0) {
 		dev_err(&spi->dev, "SPI setup failed\n");
drivers/spi/tsc2301-core.c +1 -1
@@ -170,7 +170,7 @@ static int __devinit tsc2301_probe(struc
 	} else
 		tsc->reset_gpio = -1;
 
-	spi->mode = SPI_MODE_0;
+	spi->mode = SPI_MODE_1;
 	spi->bits_per_word = 16;
 	/* The max speed might've been defined by the board-specific
 	 * struct */
drivers/input/touchscreen/tsc2046_ts.c +1 -1
@@ -499,7 +499,7 @@ static int __devinit tsc2046_probe(struc
 	tsc->spi = spi;
 	spi->dev.power.power_state = PMSG_ON;
 
-	spi->mode = SPI_MODE_1;
+	spi->mode = SPI_MODE_0;
 	spi->bits_per_word = 16;
 
 	/*
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · David Brownell

The OMAP SPI controller drivers handle SPI_CPHA incorrectly. It should mean:

CPHA=0 ... sample at leading edge of clock
CPHA=1 ... sample at trailing edge of clock

Quoted 6 lines

This fixes them, and the protocol drivers which depended on the wrong meaning. Separate ads7846 and omap_uwire patches are going upstream, already since those drivers were already pushed there. The tsc2102 code already had this right ... strange.

Verified that tsc2046 driver still works.

#2 lore raw
Quoted 12 lines · Kevin Hilman
Quoted 11 lines · David Brownell

The OMAP SPI controller drivers handle SPI_CPHA incorrectly. It should mean:

CPHA=0 ... sample at leading edge of clock
CPHA=1 ... sample at trailing edge of clock

This fixes them, and the protocol drivers which depended on the wrong meaning. Separate ads7846 and omap_uwire patches are going upstream, already since those drivers were already pushed there. The tsc2102 code already had this right ... strange.

Quoted 5 lines
Quoted 1 line

Verified that tsc2046 driver still works.

Pushing today.

Tony