summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMiquel Raynal <miquel.raynal@bootlin.com>2018-05-16 08:59:16 +0200
committerTom Rini <trini@konsulko.com>2018-05-25 20:12:59 -0400
commita174f0001f5920f3ce76866cde85ee1aa8c94ee1 (patch)
treed8c056d98315ca97b242a3039e875accfa7d4d87 /drivers
parenteb46910b4bf03e2651533473dd75267704a6c659 (diff)
tpm2: tis_spi: add the possibility to reset the chip with a gpio
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@bootlin.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/tpm/tpm2_tis_spi.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/tpm/tpm2_tis_spi.c b/drivers/tpm/tpm2_tis_spi.c
index 518a08b48d..c5d17a679d 100644
--- a/drivers/tpm/tpm2_tis_spi.c
+++ b/drivers/tpm/tpm2_tis_spi.c
@@ -23,6 +23,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"
@@ -574,6 +575,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);