From: Henri Roosen <henri.roosen@ginzinger.com>
To: peterhuewe@gmx.de, jarkko@kernel.org
Cc: jgg@ziepe.ca, linux-integrity@vger.kernel.org,
linux-kernel@vger.kernel.org,
Martin.Kepplinger-Novakovic@ginzinger.com,
Henri Roosen <henri.roosen@ginzinger.com>
Subject: [PATCH 1/1] tpm_tis_spi: add reset handling for SLM/SLB9670
Date: Wed, 18 Nov 2026 16:10:29 +0100 [thread overview]
Message-ID: <20261118151029.1259673-1-henri.roosen@ginzinger.com> (raw)
On an i.MX8MP board, the SLM9670 could not always be successfully
probed at boot time. The first call to tpm_tis_read32() returned with
timeout.
This turned out to be related to no reset-line handling of the chip.
Although a reset-gpio was provided in the dts, the tpm_tis_spi driver
didn't use it.
This patch implements reset-line handling for SLM/SLB9670 when a
reset-line is provided and uses the timings from the datasheet [1].
Tested with SLM9670.
[1] https://www.infineon.com/assets/row/public/documents/30/49/infineon-slb-9670vq2.0-datasheet-en.pdf
Signed-off-by: Henri Roosen <henri.roosen@ginzinger.com>
---
drivers/char/tpm/tpm_tis_spi_main.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/drivers/char/tpm/tpm_tis_spi_main.c b/drivers/char/tpm/tpm_tis_spi_main.c
index 61b42c83ced8..8ed9344041c1 100644
--- a/drivers/char/tpm/tpm_tis_spi_main.c
+++ b/drivers/char/tpm/tpm_tis_spi_main.c
@@ -22,6 +22,8 @@
#include <linux/acpi.h>
#include <linux/completion.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
@@ -39,6 +41,10 @@
#define MAX_SPI_FRAMESIZE 64
#define SPI_HDRSIZE 4
+/* Timings from the SLB9670/SLM9670 datasheets */
+#define SLB9670_RESET_ASSERT_US 2
+#define SLB9670_RESET_READY_MS 60
+
/*
* TCG SPI flow control is documented in section 6.4 of the spec[1]. In short,
* keep trying to read from the device until MISO goes high indicating the
@@ -287,6 +293,24 @@ static int tpm_tis_spi_probe(struct spi_device *dev)
return tpm_tis_spi_init(dev, phy, irq, &tpm_spi_phy_ops);
}
+static int slb9670_spi_probe(struct spi_device *spi)
+{
+ struct gpio_desc *reset;
+
+ reset = devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_HIGH);
+ if (IS_ERR(reset))
+ return dev_err_probe(&spi->dev, PTR_ERR(reset),
+ "failed to get reset GPIO\n");
+ if (reset) {
+ fsleep(SLB9670_RESET_ASSERT_US);
+ gpiod_set_value_cansleep(reset, 0);
+ msleep(SLB9670_RESET_READY_MS);
+ }
+
+ /* call generic probe function */
+ return tpm_tis_spi_probe(spi);
+}
+
typedef int (*tpm_tis_spi_probe_func)(struct spi_device *);
static int tpm_tis_spi_driver_probe(struct spi_device *spi)
@@ -320,7 +344,7 @@ static void tpm_tis_spi_remove(struct spi_device *dev)
static const struct spi_device_id tpm_tis_spi_id[] = {
{ "attpm20p", (unsigned long)tpm_tis_spi_probe },
{ "st33htpm-spi", (unsigned long)tpm_tis_spi_probe },
- { "slb9670", (unsigned long)tpm_tis_spi_probe },
+ { "slb9670", (unsigned long)slb9670_spi_probe },
{ "tpm_tis_spi", (unsigned long)tpm_tis_spi_probe },
{ "tpm_tis-spi", (unsigned long)tpm_tis_spi_probe },
{ "cr50", (unsigned long)cr50_spi_probe },
@@ -331,7 +355,7 @@ MODULE_DEVICE_TABLE(spi, tpm_tis_spi_id);
static const struct of_device_id of_tis_spi_match[] __maybe_unused = {
{ .compatible = "atmel,attpm20p", .data = tpm_tis_spi_probe },
{ .compatible = "st,st33htpm-spi", .data = tpm_tis_spi_probe },
- { .compatible = "infineon,slb9670", .data = tpm_tis_spi_probe },
+ { .compatible = "infineon,slb9670", .data = slb9670_spi_probe },
{ .compatible = "tcg,tpm_tis-spi", .data = tpm_tis_spi_probe },
{ .compatible = "google,cr50", .data = cr50_spi_probe },
{}
--
2.47.3
next reply other threads:[~2026-11-18 15:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 15:10 Henri Roosen [this message]
2026-11-18 15:31 ` Jarkko Sakkinen
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=20261118151029.1259673-1-henri.roosen@ginzinger.com \
--to=henri.roosen@ginzinger.com \
--cc=Martin.Kepplinger-Novakovic@ginzinger.com \
--cc=jarkko@kernel.org \
--cc=jgg@ziepe.ca \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterhuewe@gmx.de \
/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
all inboxes | Powered by JetHome®