Skip to contentSkip to conversation

spi: tegra114: Preserve SPI mode bits in def_command1_reg

PATCH In review Vishwaroop A 2 participants 2 messages Feb 4 – Feb 6

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

PATCH 1/1 spi: tegra114: Preserve SPI mode bits in def_command1_reg

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 f333a331adfa ("spi/tegra114: add spi driver")
---
 drivers/spi/spi-tegra114.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/spi/spi-tegra114.c +3 -0
index 795a8482c2c7..48fb11fea55f 100644
@@ -978,11 +978,14 @@ static int tegra_spi_setup(struct spi_device *spi)
 	if (spi_get_csgpiod(spi, 0))
 		gpiod_set_value(spi_get_csgpiod(spi, 0), 0);
 
+	/* Update default register to include CS polarity and SPI mode */
 	val = tspi->def_command1_reg;
 	if (spi->mode & SPI_CS_HIGH)
 		val &= ~SPI_CS_POL_INACTIVE(spi_get_chipselect(spi, 0));
 	else
 		val |= SPI_CS_POL_INACTIVE(spi_get_chipselect(spi, 0));
+	val &= ~SPI_CONTROL_MODE_MASK;
+	val |= SPI_MODE_SEL(spi->mode & 0x3);
 	tspi->def_command1_reg = val;
 	tegra_spi_writel(tspi, tspi->def_command1_reg, SPI_COMMAND1);
 	spin_unlock_irqrestore(&tspi->lock, flags);
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 8 lines · Vishwaroop A

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.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: tegra114: Preserve SPI mode bits in def_command1_reg

      commit: a0a75b40c919b9f6d3a0b6c978e6ccf344c1be5a

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark