Skip to content

Commit 57bac08

Browse files
Vishwaroop Agregkh
authored andcommitted
spi: tegra114: Preserve SPI mode bits in def_command1_reg
[ Upstream commit a0a75b4 ] The COMMAND1 register bits [29:28] set the SPI mode, which controls the clock idle level. When a transfer ends, tegra_spi_transfer_end() writes def_command1_reg back to restore the default state, but this register value currently lacks the mode bits. This results in the clock always being configured as idle low, breaking devices that need it high. Fix this by storing the mode bits in def_command1_reg during setup, to prevent this field from always being cleared. Fixes: f333a33 ("spi/tegra114: add spi driver") Signed-off-by: Vishwaroop A <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent b8eec12 commit 57bac08

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/spi/spi-tegra114.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,11 +978,14 @@ static int tegra_spi_setup(struct spi_device *spi)
978978
if (spi_get_csgpiod(spi, 0))
979979
gpiod_set_value(spi_get_csgpiod(spi, 0), 0);
980980

981+
/* Update default register to include CS polarity and SPI mode */
981982
val = tspi->def_command1_reg;
982983
if (spi->mode & SPI_CS_HIGH)
983984
val &= ~SPI_CS_POL_INACTIVE(spi_get_chipselect(spi, 0));
984985
else
985986
val |= SPI_CS_POL_INACTIVE(spi_get_chipselect(spi, 0));
987+
val &= ~SPI_CONTROL_MODE_MASK;
988+
val |= SPI_MODE_SEL(spi->mode & 0x3);
986989
tspi->def_command1_reg = val;
987990
tegra_spi_writel(tspi, tspi->def_command1_reg, SPI_COMMAND1);
988991
spin_unlock_irqrestore(&tspi->lock, flags);

0 commit comments

Comments
 (0)