All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v5] tpm2: tis_spi: add the possibility to reset the chip with a gpio
@ 2018-05-16  6:59 Miquel Raynal
  2018-05-16 15:40 ` Simon Glass
  2018-05-26 15:56 ` [U-Boot] [U-Boot, " Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Miquel Raynal @ 2018-05-16  6:59 UTC (permalink / raw)
  To: u-boot

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>
---

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH v5] tpm2: tis_spi: add the possibility to reset the chip with a gpio
  2018-05-16  6:59 [U-Boot] [PATCH v5] tpm2: tis_spi: add the possibility to reset the chip with a gpio Miquel Raynal
@ 2018-05-16 15:40 ` Simon Glass
  2018-05-26 15:56 ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2018-05-16 15:40 UTC (permalink / raw)
  To: u-boot

On 16 May 2018 at 16:59, Miquel Raynal <miquel.raynal@bootlin.com> wrote:
>
> 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>
> ---
>
> 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(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [U-Boot, v5] tpm2: tis_spi: add the possibility to reset the chip with a gpio
  2018-05-16  6:59 [U-Boot] [PATCH v5] tpm2: tis_spi: add the possibility to reset the chip with a gpio Miquel Raynal
  2018-05-16 15:40 ` Simon Glass
@ 2018-05-26 15:56 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2018-05-26 15:56 UTC (permalink / raw)
  To: u-boot

On Wed, May 16, 2018 at 08:59:16AM +0200, Miquel Raynal wrote:

> 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>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180526/f61cfe69/attachment.sig>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-26 15:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-16  6:59 [U-Boot] [PATCH v5] tpm2: tis_spi: add the possibility to reset the chip with a gpio Miquel Raynal
2018-05-16 15:40 ` Simon Glass
2018-05-26 15:56 ` [U-Boot] [U-Boot, " Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.