Skip to content

Commit 6a983ff

Browse files
BoergeStbroonie
authored andcommitted
spi: spi-imx: add support for SPI_MOSI_IDLE_LOW mode bit
By default, the spi-imx controller pulls the mosi line high, whenever it is idle. This behaviour can be inverted per CS by setting the corresponding DATA_CTL bit in the config register of the controller. Also, since the controller mode-bits have to be touched anyways, the SPI_CPOL and SPI_CPHA are replaced by the combined SPI_MODE_X_MASK flag. Signed-off-by: Boerge Struempfel <boerge.struempfel@gmail.com> Link: https://lore.kernel.org/r/20230530141641.1155691-3-boerge.struempfel@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent a45baa0 commit 6a983ff

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

drivers/spi/spi-imx.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ static bool spi_imx_can_dma(struct spi_controller *controller, struct spi_device
281281
#define MX51_ECSPI_CONFIG_SCLKPOL(cs) (1 << ((cs & 3) + 4))
282282
#define MX51_ECSPI_CONFIG_SBBCTRL(cs) (1 << ((cs & 3) + 8))
283283
#define MX51_ECSPI_CONFIG_SSBPOL(cs) (1 << ((cs & 3) + 12))
284+
#define MX51_ECSPI_CONFIG_DATACTL(cs) (1 << ((cs & 3) + 16))
284285
#define MX51_ECSPI_CONFIG_SCLKCTL(cs) (1 << ((cs & 3) + 20))
285286

286287
#define MX51_ECSPI_INT 0x10
@@ -573,6 +574,11 @@ static int mx51_ecspi_prepare_message(struct spi_imx_data *spi_imx,
573574
cfg &= ~MX51_ECSPI_CONFIG_SCLKCTL(spi_get_chipselect(spi, 0));
574575
}
575576

577+
if (spi->mode & SPI_MOSI_IDLE_LOW)
578+
cfg |= MX51_ECSPI_CONFIG_DATACTL(spi_get_chipselect(spi, 0));
579+
else
580+
cfg &= ~MX51_ECSPI_CONFIG_DATACTL(spi_get_chipselect(spi, 0));
581+
576582
if (spi->mode & SPI_CS_HIGH)
577583
cfg |= MX51_ECSPI_CONFIG_SSBPOL(spi_get_chipselect(spi, 0));
578584
else
@@ -1743,7 +1749,8 @@ static int spi_imx_probe(struct platform_device *pdev)
17431749
controller->prepare_message = spi_imx_prepare_message;
17441750
controller->unprepare_message = spi_imx_unprepare_message;
17451751
controller->slave_abort = spi_imx_slave_abort;
1746-
controller->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_NO_CS;
1752+
controller->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_NO_CS |
1753+
SPI_MOSI_IDLE_LOW;
17471754

17481755
if (is_imx35_cspi(spi_imx) || is_imx51_ecspi(spi_imx) ||
17491756
is_imx53_ecspi(spi_imx))

0 commit comments

Comments
 (0)