Skip to content

Commit 967ca91

Browse files
kkyarlagaddabroonie
authored andcommitted
spi: tegra210-quad: Enable TPM wait polling
Trusted Platform Module requires flow control. As defined in TPM interface specification, client would drive MISO line at same cycle as last address bit on MOSI. Tegra234 and Tegra241 QSPI controllers have TPM wait state detection feature which is enabled for TPM client devices reported in SPI device mode bits. Signed-off-by: Krishna Yarlagadda <[email protected]> Reviewed-by: Jon Hunter <[email protected]> Reviewed-by: Jerry Snitselaar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 67a142d commit 967ca91

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

drivers/spi/spi-tegra210-quad.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142

143143
#define QSPI_GLOBAL_CONFIG 0X1a4
144144
#define QSPI_CMB_SEQ_EN BIT(0)
145+
#define QSPI_TPM_WAIT_POLL_EN BIT(1)
145146

146147
#define QSPI_CMB_SEQ_ADDR 0x1a8
147148
#define QSPI_ADDRESS_VALUE_SET(X) (((x) & 0xFFFF) << 0)
@@ -164,6 +165,7 @@
164165
struct tegra_qspi_soc_data {
165166
bool has_dma;
166167
bool cmb_xfer_capable;
168+
bool supports_tpm;
167169
unsigned int cs_count;
168170
};
169171

@@ -1065,6 +1067,12 @@ static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi,
10651067

10661068
/* Enable Combined sequence mode */
10671069
val = tegra_qspi_readl(tqspi, QSPI_GLOBAL_CONFIG);
1070+
if (spi->mode & SPI_TPM_HW_FLOW) {
1071+
if (tqspi->soc_data->supports_tpm)
1072+
val |= QSPI_TPM_WAIT_POLL_EN;
1073+
else
1074+
return -EIO;
1075+
}
10681076
val |= QSPI_CMB_SEQ_EN;
10691077
tegra_qspi_writel(tqspi, val, QSPI_GLOBAL_CONFIG);
10701078
/* Process individual transfer list */
@@ -1196,6 +1204,8 @@ static int tegra_qspi_non_combined_seq_xfer(struct tegra_qspi *tqspi,
11961204
/* Disable Combined sequence mode */
11971205
val = tegra_qspi_readl(tqspi, QSPI_GLOBAL_CONFIG);
11981206
val &= ~QSPI_CMB_SEQ_EN;
1207+
if (tqspi->soc_data->supports_tpm)
1208+
val &= ~QSPI_TPM_WAIT_POLL_EN;
11991209
tegra_qspi_writel(tqspi, val, QSPI_GLOBAL_CONFIG);
12001210
list_for_each_entry(transfer, &msg->transfers, transfer_list) {
12011211
struct spi_transfer *xfer = transfer;
@@ -1454,24 +1464,28 @@ static irqreturn_t tegra_qspi_isr_thread(int irq, void *context_data)
14541464
static struct tegra_qspi_soc_data tegra210_qspi_soc_data = {
14551465
.has_dma = true,
14561466
.cmb_xfer_capable = false,
1467+
.supports_tpm = false,
14571468
.cs_count = 1,
14581469
};
14591470

14601471
static struct tegra_qspi_soc_data tegra186_qspi_soc_data = {
14611472
.has_dma = true,
14621473
.cmb_xfer_capable = true,
1474+
.supports_tpm = false,
14631475
.cs_count = 1,
14641476
};
14651477

14661478
static struct tegra_qspi_soc_data tegra234_qspi_soc_data = {
14671479
.has_dma = false,
14681480
.cmb_xfer_capable = true,
1481+
.supports_tpm = true,
14691482
.cs_count = 1,
14701483
};
14711484

14721485
static struct tegra_qspi_soc_data tegra241_qspi_soc_data = {
14731486
.has_dma = false,
14741487
.cmb_xfer_capable = true,
1488+
.supports_tpm = true,
14751489
.cs_count = 4,
14761490
};
14771491

0 commit comments

Comments
 (0)