From patchwork Thu Apr 7 11:18:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12805087 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 EDE23C433F5 for ; Thu, 7 Apr 2022 11:19:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244719AbiDGLVl (ORCPT ); Thu, 7 Apr 2022 07:21:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235216AbiDGLVb (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 97CFC1959F4; 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=1649330355; bh=T86PXNHzUiQ9diUoGWfpe352m8YYGi+nE1MveqW7gqk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=GyUAD+aPOXzYQpi+6xVupTHdKonp1XYCqXBTTIfjrGa8hmfsNLeAvrWn+rfYQEMXu 2MTuJoDBX5TyHs/k6bLzz6yimvvt9FyfXdQ9lVZ52+jAbo00i2y76VIIr9Vl44tUhF paSe9xSf00EFN5LQSyuXFQlCZpONPdNaEyI5sUA0= 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 1N17Ye-1nztIP0Wh0-012VMn; Thu, 07 Apr 2022 13:19:15 +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 0/5] Support TPM Reset GPIO Date: Thu, 7 Apr 2022 13:18:44 +0200 Message-Id: <20220407111849.5676-1-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:95WZG1t96y168i7Ni5zv4URToJsq22uNWbfzOa/k/DmPGbGAbVV 8FPZgE5gaUmVlItiBPNzN1MvAGTflCpVpEPQaoyOZs85cKge/QK5M42aA2q5ofiZhf2rEbo koTwhjvTJz2f7uHduCQerLGBmRjly0KQIN9O/5DDR/9ymbhBDqRzRX5VeCQxgiUt3Wji1DO R6gc3FftnE5ZuJGxc64Yw== X-UI-Out-Filterresults: notjunk:1;V03:K0:pJCiAE4wdF4=:XbDQRCnStVFNninZ09C8gJ DdsJ7T4Bm9ETEU/omEqkngygkV08REglcaOHUAkJJAloB+5FqwpMDVw+5btNmRrM5/j7cQ0qc xt9i0VIoL20m5GFFAu9Cxo0l+xWHuFPG40UDrpmdCsl6W1ZF9C5KcJhSeL6zVP3B3Hz3TYxTD 2jQB21VaQgQhn838yNGLp8H/AmdiRh03GE6a6NpSdRtNo2CoobBUJTHk9UdNXOocFHHlX4ZBq 2FAeR7mW/gXgziGMPzyUIy7Fe+J3XDEm1N4hW3b5Qgj0p1AGRFWS9m525sY5qdBOhWf+3Qa4l r2N2DicCIrT53dRIucUJgQsrq1OtoxhYsENuQpBwWprcI17CHF9yVh6p/3BNq/KMmfLOMZxQG TBImzpxHqoTxU8gzXoS5A5ZnW9czw+xq7LmfBS/f8/CKRj9eIUx3NcMHVeZixtgYhdnRE7TsA kYxJ18IfhiaPYhqxW5iECrFfT2oP1HrDD+N01hNCNj8Zu4jY2/kkn7dWt7jVmoim2qQY54AVR VtLR/Ax3YRXE+INY4CXgp3Zh5PgOHJrei8PwGlfxR9ExuxPErGLrlk/eYQaUR6zT/gTe/LMqA YJj579eB4QdtaJ1iSKzBjhbOxT6J3iuxmYxd12Fo888r6AoXtd900OYr9eLBj+EoQr+SS+hzg MZQKzMPAnTU2qHyX+rpYRBbsR5UvEw3u3Liu2R2tJPqdOPK9k5AtLuUhFafbR37PnioLG8k0Z QaSggrmLLp+D3/TRKrIAGFxkqONbgDfcDi6DXSI8B5ZRCSaQZkifEemvOGo31kPITwGePIXaf PDuYmFV89n7iq+Dr3T+pFR/V7Rs65/1hWc0sfPbwNfGmQPFdW10YdlTL4qpRNxFSU17nlptGI YDk1jGOf5wuCP+Meqz9TMkWIfZBGVcZJYsRzKJ4fIWIoV9DmhgVYl6Pr/ENxB04rwfZMuM6LP /u6Og50YshiFvHGSUcGBJapBoGrCPqZba7JLe5WjUmiJe06zFYJV6Er+2Erw8jj0/2H8b3lYN EJr6b7tSSEuztpGPdOhVa5HuB15psgoj3fjhm+coFzGDxaCdUP2V8BJ8QrIFYRRC6C2PP1Tj7 wHYZTKsQZt2g+c= Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org If the system starts up with the TPM chip still in reset the probe routine of the tpm-tis driver fails with the following error message: "tpm_tis_spi: probe of spiX.Y failed with error -110" The reason for this error is a missing response to the first command sent to the chip (TPM_DID_VID) and a following timeout. With the SLB9670 this issue can be triggered by setting up a pin configuration in device tree with the reset line setting to BCM2835_PUD_DOWN (note that the reset signal for the SLB9670 is active low). This patchset adds support to set the chip out of reset from within the TPM driver. For this reason two new callbacks are introduced that can optionally be implemented by a tpm tis driver: int (*unset_reset) (struct tpm_tis_data *data); int (*set_reset) (struct tpm_tis_data *data); Function "unset_reset" is called directly before the first TPM command is issued. Function "set_reset" is called at system shutdown directly after the TPM2 shutdown command. Both callbacks are added to the set of tpm_tis_phy_ops functions. Patch 5 of this series provides the implementations for the SLB9670. Patch 1: Extend struct tpm_tis_phy_ops by the optional callbacks "set_reset" and "unset_reset". If defined call "set_reset" before the first TPM command is sent and "unset_reset" at system shutdown after the TPM2 shutdown command. Patch 2: Document the property "reset-gpios" as an optional property which can be used to specify the TPM chips reset gpio. Patch 3: If available get the reset gpio and store it in the tpm_tis_data structure. Patch 4: Declare functions tpm_tis_spi_flow_control, tpm_tis_spi_read_bytes and tpm_tis_spi_write_bytes as extern. This is in preparation of the next patch in which a custom probe function for the SLB9670 is implemented that is used to define its own set of tpm_tis_phy_ops. Patch 5: Implement the "set_reset" and "unset_reset" callbacks for the SLB9670 and assign it in the probe function. The SLB9670 specific parts are moved into an own file to separate it from the generic code (for now I opted not to use a kernel config option for the SLB9670 code as it is used in case of the SPI CR50). This series has been tested with a SLB9670. Lino Sanfilippo (5): tpm: add functions to set and unset the tpm chips reset state dt-bindings: tpm: document reset gpio property tpm: tpm_tis: get optionally defined reset gpio tpm: tpm_tis: make functions available for external linkage tpm: tpm_tis_spi_slb_9670: implement set_reset and unset_reset functions .../bindings/security/tpm/tpm_tis_spi.txt | 2 + drivers/char/tpm/Makefile | 1 + drivers/char/tpm/tpm-chip.c | 5 ++ drivers/char/tpm/tpm_tis_core.c | 23 ++++++ drivers/char/tpm/tpm_tis_core.h | 3 + drivers/char/tpm/tpm_tis_spi.h | 9 ++ drivers/char/tpm/tpm_tis_spi_main.c | 16 ++-- drivers/char/tpm/tpm_tis_spi_slb9670.c | 82 +++++++++++++++++++ 8 files changed, 133 insertions(+), 8 deletions(-) create mode 100644 drivers/char/tpm/tpm_tis_spi_slb9670.c base-commit: ed4643521e6af8ab8ed1e467630a85884d2696cf