linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krishna Yarlagadda <kyarlagadda@nvidia.com>
To: <jsnitsel@redhat.com>, <robh+dt@kernel.org>, <broonie@kernel.org>,
	<peterhuewe@gmx.de>, <jgg@ziepe.ca>, <jarkko@kernel.org>,
	<krzysztof.kozlowski+dt@linaro.org>, <linux-spi@vger.kernel.org>,
	<linux-tegra@vger.kernel.org>, <linux-integrity@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Cc: <thierry.reding@gmail.com>, <jonathanh@nvidia.com>,
	<skomatineni@nvidia.com>, <ldewangan@nvidia.com>,
	Krishna Yarlagadda <kyarlagadda@nvidia.com>
Subject: [Patch V10 3/3] spi: tegra210-quad: Enable TPM wait polling
Date: Fri, 21 Apr 2023 14:43:09 +0530	[thread overview]
Message-ID: <20230421091309.2672-4-kyarlagadda@nvidia.com> (raw)
In-Reply-To: <20230421091309.2672-1-kyarlagadda@nvidia.com>

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 <kyarlagadda@nvidia.com>
---
 drivers/spi/spi-tegra210-quad.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/spi/spi-tegra210-quad.c b/drivers/spi/spi-tegra210-quad.c
index bea376acea1f..fbd14dd7be44 100644
--- a/drivers/spi/spi-tegra210-quad.c
+++ b/drivers/spi/spi-tegra210-quad.c
@@ -142,6 +142,7 @@
 
 #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)
@@ -164,6 +165,7 @@
 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,
 };
 
-- 
2.17.1


  parent reply	other threads:[~2023-04-21  9:15 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-21  9:13 [Patch V10 0/3] Tegra TPM driver with HW flow control Krishna Yarlagadda
2023-04-21  9:13 ` [Patch V10 1/3] spi: Add TPM HW flow flag Krishna Yarlagadda
2023-04-21  9:13 ` [Patch V10 2/3] tpm_tis-spi: Add hardware wait polling Krishna Yarlagadda
2023-04-23 15:08   ` Jarkko Sakkinen
2023-04-24 11:56     ` Mark Brown
2023-04-24 13:11       ` Jarkko Sakkinen
2023-04-24 14:46       ` Thierry Reding
2023-04-24 15:18         ` Mark Brown
2023-04-24 15:31           ` Thierry Reding
2023-05-10 15:10             ` Krishna Yarlagadda
2023-05-24 12:43               ` Krishna Yarlagadda
2023-06-01  8:29                 ` Thierry Reding
2023-06-01 11:04                   ` Mark Brown
2023-06-01 12:36                     ` Thierry Reding
2023-06-01 12:40                       ` Mark Brown
2023-06-09 14:19                         ` Jarkko Sakkinen
2023-06-09 14:22                           ` Mark Brown
2023-06-09 15:12                             ` Jarkko Sakkinen
2023-04-21  9:13 ` Krishna Yarlagadda [this message]
2023-04-21  9:39   ` [Patch V10 3/3] spi: tegra210-quad: Enable TPM " Jon Hunter
2023-04-21 12:50 ` [Patch V10 0/3] Tegra TPM driver with HW flow control Jerry Snitselaar
2023-04-24 13:21 ` (subset) " Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230421091309.2672-4-kyarlagadda@nvidia.com \
    --to=kyarlagadda@nvidia.com \
    --cc=broonie@kernel.org \
    --cc=jarkko@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=jonathanh@nvidia.com \
    --cc=jsnitsel@redhat.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=ldewangan@nvidia.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=peterhuewe@gmx.de \
    --cc=robh+dt@kernel.org \
    --cc=skomatineni@nvidia.com \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).