]> Git Repo - linux.git/commitdiff
spi: tegra210-quad: Enable TPM wait polling
authorKrishna Yarlagadda <[email protected]>
Fri, 21 Apr 2023 09:13:09 +0000 (14:43 +0530)
committerMark Brown <[email protected]>
Fri, 21 Apr 2023 13:37:04 +0000 (14:37 +0100)
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]>
drivers/spi/spi-tegra210-quad.c

index bea376acea1fcb3ca30b160a8b4f65dda1c4d7c7..fbd14dd7be44324454b6b5f82b34df7810fe8cd4 100644 (file)
 
 #define QSPI_GLOBAL_CONFIG                     0X1a4
 #define QSPI_CMB_SEQ_EN                                BIT(0)
+#define QSPI_TPM_WAIT_POLL_EN                  BIT(1)
 
 #define QSPI_CMB_SEQ_ADDR                      0x1a8
 #define QSPI_ADDRESS_VALUE_SET(X)              (((x) & 0xFFFF) << 0)
 struct tegra_qspi_soc_data {
        bool has_dma;
        bool cmb_xfer_capable;
+       bool supports_tpm;
        unsigned int cs_count;
 };
 
@@ -1065,6 +1067,12 @@ static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi,
 
        /* Enable Combined sequence mode */
        val = tegra_qspi_readl(tqspi, QSPI_GLOBAL_CONFIG);
+       if (spi->mode & SPI_TPM_HW_FLOW) {
+               if (tqspi->soc_data->supports_tpm)
+                       val |= QSPI_TPM_WAIT_POLL_EN;
+               else
+                       return -EIO;
+       }
        val |= QSPI_CMB_SEQ_EN;
        tegra_qspi_writel(tqspi, val, QSPI_GLOBAL_CONFIG);
        /* Process individual transfer list */
@@ -1196,6 +1204,8 @@ static int tegra_qspi_non_combined_seq_xfer(struct tegra_qspi *tqspi,
        /* Disable Combined sequence mode */
        val = tegra_qspi_readl(tqspi, QSPI_GLOBAL_CONFIG);
        val &= ~QSPI_CMB_SEQ_EN;
+       if (tqspi->soc_data->supports_tpm)
+               val &= ~QSPI_TPM_WAIT_POLL_EN;
        tegra_qspi_writel(tqspi, val, QSPI_GLOBAL_CONFIG);
        list_for_each_entry(transfer, &msg->transfers, transfer_list) {
                struct spi_transfer *xfer = transfer;
@@ -1454,24 +1464,28 @@ static irqreturn_t tegra_qspi_isr_thread(int irq, void *context_data)
 static struct tegra_qspi_soc_data tegra210_qspi_soc_data = {
        .has_dma = true,
        .cmb_xfer_capable = false,
+       .supports_tpm = false,
        .cs_count = 1,
 };
 
 static struct tegra_qspi_soc_data tegra186_qspi_soc_data = {
        .has_dma = true,
        .cmb_xfer_capable = true,
+       .supports_tpm = false,
        .cs_count = 1,
 };
 
 static struct tegra_qspi_soc_data tegra234_qspi_soc_data = {
        .has_dma = false,
        .cmb_xfer_capable = true,
+       .supports_tpm = true,
        .cs_count = 1,
 };
 
 static struct tegra_qspi_soc_data tegra241_qspi_soc_data = {
        .has_dma = false,
        .cmb_xfer_capable = true,
+       .supports_tpm = true,
        .cs_count = 4,
 };
 
This page took 0.060111 seconds and 4 git commands to generate.