From patchwork Wed May 16 06:59:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 914207 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40m5042Pn4z9s2R for ; Wed, 16 May 2018 16:59:32 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 0E79AC21D74; Wed, 16 May 2018 06:59:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 15CB6C21C50; Wed, 16 May 2018 06:59:24 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 29815C21C50; Wed, 16 May 2018 06:59:22 +0000 (UTC) Received: from mail.bootlin.com (mail.bootlin.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id CDFF0C21BE5 for ; Wed, 16 May 2018 06:59:21 +0000 (UTC) Received: by mail.bootlin.com (Postfix, from userid 110) id 744292084E; Wed, 16 May 2018 08:59:20 +0200 (CEST) Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.bootlin.com (Postfix) with ESMTPSA id 33160206F6; Wed, 16 May 2018 08:59:20 +0200 (CEST) From: Miquel Raynal To: Tom Rini , Simon Glass Date: Wed, 16 May 2018 08:59:16 +0200 Message-Id: <20180516065916.29683-1-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.14.1 Cc: u-boot@lists.denx.de, Bastian Fraune Subject: [U-Boot] [PATCH v5] tpm2: tis_spi: add the possibility to reset the chip with a gpio X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "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 Reviewed-by: Simon Glass --- 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 #include #include +#include #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);