Message ID | 20230227172108.8206-4-kyarlagadda@nvidia.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Tegra TPM driver with HW flow control | expand |
On Mon, Feb 27, 2023 at 10:51:08PM +0530, Krishna Yarlagadda wrote: > 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. > Tegra241 QSPI controller has TPM wait state detection feature which is > enabled for TPM client devices reported in SPI device mode bits. > Set half duplex flag for TPM device to detect and send entire message > to controller in one shot. > > Signed-off-by: Krishna Yarlagadda <kyarlagadda@nvidia.com> > --- > drivers/spi/spi-tegra210-quad.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) Acked-by: Thierry Reding <treding@nvidia.com>
On Mon, Feb 27, 2023 at 10:51:08PM +0530, Krishna Yarlagadda wrote: > 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. > Tegra241 QSPI controller has TPM wait state detection feature which is > enabled for TPM client devices reported in SPI device mode bits. > Set half duplex flag for TPM device to detect and send entire message > to controller in one shot. > > 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 b967576b6c96..e1165584a20a 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 support_tpm; Nit: this could be "supports_tpm" for slightly more consistency with "has_dma". Thierry
On 27/02/2023 17:21, Krishna Yarlagadda wrote: > 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. > Tegra241 QSPI controller has TPM wait state detection feature which is > enabled for TPM client devices reported in SPI device mode bits. Earlier in patch 2/3 we say Tegra234 and Tegra241 but here we just say Tegra241. > static struct tegra_qspi_soc_data tegra186_qspi_soc_data = { > .has_dma = true, > .cmb_xfer_capable = true, > + .support_tpm = false, > .cs_count = 1, > }; > > static struct tegra_qspi_soc_data tegra234_qspi_soc_data = { > .has_dma = false, > .cmb_xfer_capable = true, > + .support_tpm = true, > .cs_count = 1, > }; > > static struct tegra_qspi_soc_data tegra241_qspi_soc_data = { > .has_dma = false, > .cmb_xfer_capable = true, > + .support_tpm = true, > .cs_count = 4, > }; > We enable for both Tegra234 and Tegra241 and so the commit message should say so. Jon
diff --git a/drivers/spi/spi-tegra210-quad.c b/drivers/spi/spi-tegra210-quad.c index b967576b6c96..e1165584a20a 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 support_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->support_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 */ @@ -1192,6 +1200,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->support_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; @@ -1450,24 +1460,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, + .support_tpm = false, .cs_count = 1, }; static struct tegra_qspi_soc_data tegra186_qspi_soc_data = { .has_dma = true, .cmb_xfer_capable = true, + .support_tpm = false, .cs_count = 1, }; static struct tegra_qspi_soc_data tegra234_qspi_soc_data = { .has_dma = false, .cmb_xfer_capable = true, + .support_tpm = true, .cs_count = 1, }; static struct tegra_qspi_soc_data tegra241_qspi_soc_data = { .has_dma = false, .cmb_xfer_capable = true, + .support_tpm = true, .cs_count = 4, };
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. Tegra241 QSPI controller has TPM wait state detection feature which is enabled for TPM client devices reported in SPI device mode bits. Set half duplex flag for TPM device to detect and send entire message to controller in one shot. Signed-off-by: Krishna Yarlagadda <kyarlagadda@nvidia.com> --- drivers/spi/spi-tegra210-quad.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)