Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: imx: fix ecspi mode setup

Fixed problem with setting spi mode 0 or 1 after setting mode 2 or 3

SPI_MODE_0 and SPI_MODE_1 requires clock low when inactive. SPI_MODE_2
and SPI_MODE_3 requires clk high when inactive.
Currently driver can just set bits in fields SCLK_PHA (SPI Clock/Data
Phase Control), SCLK_POL (SPI Clock Polarity Control),
SCLK_CTL (controls the inactive state of SCLK) ans SS_POL (SPI SS
Polarity Select) of ECSPIx_CONFIGREG register.
This patch allows driver to clear corresponding bits in these fields.

Signed-off-by: Andrew Y. Kuksov <qxovxp@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Andrew Y. Kuksov and committed by
Mark Brown
1476253c 6ff33f39

+7
+7
drivers/spi/spi-imx.c
··· 336 336 337 337 if (config->mode & SPI_CPHA) 338 338 cfg |= MX51_ECSPI_CONFIG_SCLKPHA(config->cs); 339 + else 340 + cfg &= ~MX51_ECSPI_CONFIG_SCLKPHA(config->cs); 339 341 340 342 if (config->mode & SPI_CPOL) { 341 343 cfg |= MX51_ECSPI_CONFIG_SCLKPOL(config->cs); 342 344 cfg |= MX51_ECSPI_CONFIG_SCLKCTL(config->cs); 345 + } else { 346 + cfg &= ~MX51_ECSPI_CONFIG_SCLKPOL(config->cs); 347 + cfg &= ~MX51_ECSPI_CONFIG_SCLKCTL(config->cs); 343 348 } 344 349 if (config->mode & SPI_CS_HIGH) 345 350 cfg |= MX51_ECSPI_CONFIG_SSBPOL(config->cs); 351 + else 352 + cfg &= ~MX51_ECSPI_CONFIG_SSBPOL(config->cs); 346 353 347 354 writel(ctrl, spi_imx->base + MX51_ECSPI_CTRL); 348 355 writel(cfg, spi_imx->base + MX51_ECSPI_CONFIG);