[U-Boot] [PATCH v5] tpm2: tis_spi: add the possibility to reset the chip with a gpio

Miquel Raynal miquel.raynal at bootlin.com
Wed May 16 06:59:16 UTC 2018


On some designs, the reset line could not be connected to the SoC reset
line, in this case, request the GPIO and ensure the chip gets reset.

Signed-off-by: Miquel Raynal <miquel.raynal at bootlin.com>
---

Changes since v4:
=================
* This patch was part of a bigger series, sending it alone as other
  files seems to be in an acceptable state now.
* Changed the commit title with the prefix "tpm2: tis_spi:" to refer to
  the right file ("tpm:" is too generic now).
* Removed the #ifdef CONFIG_DM_GPIO/#endif couple around the
  <.../gpio.h> include.
* Changed the #ifdef CONFIG_DM_GPIO/#endif couple in the code by a
  if (IS_ENABLED(CONFIG_DM_GPIO)).
  
Changes since v3:
=================
* Removed useless reset of rx_buf[0] in tpm_tis_spi_xfer().
* Changed the way spi_xfer return code is checked: error out on any
  value != 0 instead of just negative ones.
* Removed unused functions flagged __maybe_unused as well as well as the
  __maybe_unused flags themselves when not needed.
* Simplified the validity check of the GPIO as suggested.
* Updated the compatible property for the SPI modules (as well as the
  bindings docuementation) to be simply "tis,tpm2-spi" which should work
  with most compliant chips. Data is linked to this generic compatible
  in the TPM driver, other values may be added if needed in the future
  to fit other chips that would use different values than the current
  ones (used by Infineon SLB 9670 and ST ST33TPHF20 modules, for
  instance).

 drivers/tpm/tpm2_tis_spi.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/tpm/tpm2_tis_spi.c b/drivers/tpm/tpm2_tis_spi.c
index 6a4d5284c9..2c4d714e01 100644
--- a/drivers/tpm/tpm2_tis_spi.c
+++ b/drivers/tpm/tpm2_tis_spi.c
@@ -24,6 +24,7 @@
 #include <linux/compiler.h>
 #include <linux/types.h>
 #include <linux/unaligned/be_byteshift.h>
+#include <asm-generic/gpio.h>
 
 #include "tpm_tis.h"
 #include "tpm_internal.h"
@@ -575,6 +576,21 @@ static int tpm_tis_spi_probe(struct udevice *dev)
 	struct tpm_chip *chip = dev_get_priv(dev);
 	int ret;
 
+	if (IS_ENABLED(CONFIG_DM_GPIO)) {
+		struct gpio_desc reset_gpio;
+
+		ret = gpio_request_by_name(dev, "gpio-reset", 0,
+					   &reset_gpio, GPIOD_IS_OUT);
+		if (ret) {
+			log(LOGC_NONE, LOGL_NOTICE, "%s: missing reset GPIO\n",
+			    __func__);
+		} else {
+			dm_gpio_set_value(&reset_gpio, 0);
+			mdelay(1);
+			dm_gpio_set_value(&reset_gpio, 1);
+		}
+	}
+
 	/* Ensure a minimum amount of time elapsed since reset of the TPM */
 	mdelay(drv_data->time_before_first_cmd_ms);
 
-- 
2.14.1



More information about the U-Boot mailing list