Skip to content

Commit 61249ce

Browse files
Jungseung-Leebroonie
authored andcommitted
spi: spi-ep93xx: fix wrong SPI mode selection
The mode bits on control register 0 are in a different order compared to the spi mode define values. Thus, in the current code, it fails to set the correct SPI mode selection. Fix it. Signed-off-by: Jungseung Lee <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent ebb3b9a commit 61249ce

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/spi/spi-ep93xx.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
#include <linux/platform_data/spi-ep93xx.h>
3232

3333
#define SSPCR0 0x0000
34-
#define SSPCR0_MODE_SHIFT 6
34+
#define SSPCR0_SPO BIT(6)
35+
#define SSPCR0_SPH BIT(7)
3536
#define SSPCR0_SCR_SHIFT 8
3637

3738
#define SSPCR1 0x0004
@@ -159,7 +160,10 @@ static int ep93xx_spi_chip_setup(struct spi_master *master,
159160
return err;
160161

161162
cr0 = div_scr << SSPCR0_SCR_SHIFT;
162-
cr0 |= (spi->mode & (SPI_CPHA | SPI_CPOL)) << SSPCR0_MODE_SHIFT;
163+
if (spi->mode & SPI_CPOL)
164+
cr0 |= SSPCR0_SPO;
165+
if (spi->mode & SPI_CPHA)
166+
cr0 |= SSPCR0_SPH;
163167
cr0 |= dss;
164168

165169
dev_dbg(&master->dev, "setup: mode %d, cpsr %d, scr %d, dss %d\n",

0 commit comments

Comments
 (0)