From patchwork Thu Apr 7 11:18:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12805085 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40248C433F5 for ; Thu, 7 Apr 2022 11:19:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244690AbiDGLVi (ORCPT ); Thu, 7 Apr 2022 07:21:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234370AbiDGLVb (ORCPT ); Thu, 7 Apr 2022 07:21:31 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97BD01959F1; Thu, 7 Apr 2022 04:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1649330356; bh=qXAcVdb5+U1V68gy4WuSKtITy5q5Oa2Czfs+ThvCSaY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=OIgX8ZVLYVBbUVTKosMn65lDqQV7nNJbX/gyX9ND4tpdrNm9OR9+xMECcaHs61ghf +GlwhfwIO9XFovd2woM6UUy3ukyobi7n6FFcn8+z9qpuseTDg8zXO8gY3fa20rHp8m jvWkLmj5HV16IKB3M1pulz858JfUDv5e89023LOk= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([46.223.2.23]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M89Gj-1ngZAF0f1n-005LBY; Thu, 07 Apr 2022 13:19:16 +0200 From: Lino Sanfilippo To: peterhuewe@gmx.de, jarkko@kernel.org, jgg@ziepe.ca, =robh+dt@kernel.org Cc: devicetree@vger.kernel.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, stefanb@linux.ibm.com, p.rosenberger@kunbus.com, lukas@wunner.de, Lino Sanfilippo Subject: [PATCH 3/5] tpm: tpm_tis: get optionally defined reset gpio Date: Thu, 7 Apr 2022 13:18:47 +0200 Message-Id: <20220407111849.5676-4-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220407111849.5676-1-LinoSanfilippo@gmx.de> References: <20220407111849.5676-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:VOa6nrOx58PxejZldnp8Sgli5Ic8TJYGKO/scam+aIiW/usfP3N Z7lJIkvmgfr4kctD3RHvlgy6npl6/+HPw4t/msp3wgxHW3t2To/OYftSQzEkl2ZB6Ec0ukC nmh1U7KpzoE6W5swBS9aqbSkg9CK/8fZ6lwTozA0UUvSA5MGRA4Pkzj0d3b2o1Id/puHBxx z+MUwHuuYLdnZEJrX4ZEg== X-UI-Out-Filterresults: notjunk:1;V03:K0:7RaNUTefLq8=:PeqP0exQKrSOr4/bM+56KG DOa5bUc9oR+3w5PwlEtawLhJ5G6nw56Kn1hy7GWxJRPBfb2tGdeo3WW9DfeDtztQrpJg9as/D CG5taQ+xMg971mAnjiZpQbN6Km1lJZcnkcrNJuHGQzpm7VXTS4Vi1/tYDQRrekGGH6meJ0Bnz cNou9/PeWaEH9Nxtl+C4ynhk8CdehuUfFIeOD8cB74V3iLNlXW7q+mXnX6wTXer9KaiJ6kQAS 1C4dmTMCa9BNvWHXBT/EuXkr5csYc2hlPGnR4+mT9sfpgg4kIwXN3P8wJ/bcqDb8fTlEX5kN0 ii/S4m9r1TdHFjaUawFi6m0l2Psxz2bCfociTMHk3LrMYRSs/Sj8EVdqVKNJ+g4y/qACjCIdG qipUFN6qqt/+qrtl2PEbpHmt4df/H3Cv4654vT7pHc5Ex8KXj75Pr64CUtMdDYFo4fMGZfKFN tbGJUzQgMBKS4We/1ylch61IlFlbprhzostpXOPpyixmtNJCxYKPBc0blbVDKoy0Zp3X/MzeU eF6lh0Z7cyAp7BHkNj9taiCXs6D331m4rnMkFnRb0An/lGCdHVQ9ig3j9hTCU06rKLuzpnL6U PBg8h6y/Z9nTa/nEJ1uiJgfTPhO5THTo1Lp3FyTOmj527P0xQfjN6xZ9xuhzt2IM545FjBppU 1uuaGBPPKX5tNo62r8ZmeILK1LbbAxLQgChoMHoL6TgEcc7lfUIWPEQkVzTFYIXGOQfqrvfs+ sX4K+bQpCp0LZbAhgtjMq4oi96KfFOCK8coHUKX36DW3eR133uZtyS05CZIDsYptE3hihubaK xlai2FD1VOxntji90tRxVCnVGEQFx0AmcVFeNR45Edii7BoCKzdBEUH/CJTBtLT3X3+xRhuAl ECNHde1IPy3YTnEletTioxWkP8dM/Au8y68pAPxP7qYSFGh9cpQpWx24DbJ163y2zTi2yJBZW svH2AEq9ewzjLsIrHeFjd9wGXQLUJtSYK9PuVg487YCBteSURFU/2HUGYQQEhvKk4eup2EZrp MODTjvqNeHHocCIdOWGuxtVc1Z8vDJBIeWPcRFToYj6d1rJXALt81cR3PZxt1NjhSv49g8F54 zgj5bjOwHZnXoE= Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org Get the optionally specified reset gpio. This property can be set with the con-id "reset-gpios". Signed-off-by: Lino Sanfilippo --- drivers/char/tpm/tpm_tis_core.c | 20 ++++++++++++++++++++ drivers/char/tpm/tpm_tis_core.h | 1 + 2 files changed, 21 insertions(+) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index 11e5e045f3a7..89bfee3cfb18 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "tpm.h" #include "tpm_tis_core.h" @@ -919,6 +920,21 @@ static const struct tpm_class_ops tpm_tis = { .clk_enable = tpm_tis_clkrun_enable, }; +/* + * Retrieve the reset GPIO if it is defined. + */ +static int tpm_tis_get_reset_gpio(struct device *dev, struct tpm_tis_data *data) +{ + data->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); + if (IS_ERR(data->reset_gpio)) + return PTR_ERR(data->reset_gpio); + + if (data->reset_gpio) + gpiod_set_consumer_name(data->reset_gpio, "TPM reset"); + + return 0; +} + int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, const struct tpm_tis_phy_ops *phy_ops, acpi_handle acpi_dev_handle) @@ -952,6 +968,10 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, dev_set_drvdata(&chip->dev, priv); + rc = tpm_tis_get_reset_gpio(dev, priv); + if (rc) + return rc; + if (priv->phy_ops->unset_reset) priv->phy_ops->unset_reset(priv); diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h index f1a67445a5c5..502816d91353 100644 --- a/drivers/char/tpm/tpm_tis_core.h +++ b/drivers/char/tpm/tpm_tis_core.h @@ -94,6 +94,7 @@ struct tpm_tis_data { int irq; bool irq_tested; unsigned long flags; + struct gpio_desc *reset_gpio; void __iomem *ilb_base_addr; u16 clkrun_enabled; wait_queue_head_t int_queue;