From mboxrd@z Thu Jan 1 00:00:00 1970 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 3848AC433F5 for ; Thu, 26 May 2022 12:32:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347237AbiEZMcF (ORCPT ); Thu, 26 May 2022 08:32:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347241AbiEZMb6 (ORCPT ); Thu, 26 May 2022 08:31:58 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CF5221A0 for ; Thu, 26 May 2022 05:31:53 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id gi33so2770206ejc.3 for ; Thu, 26 May 2022 05:31:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=LBL/8y8/LUYPF5+lyivMH99zmCcurEDsFooG2UU4WWA=; b=W2zqnFCyFSQ++tFA7S3b0yktYXOz/D9JMCw10nnNav9hy4QfgmkWMui5iFy6xEr8o+ X/RCetDX9ZBi2elH8/0Gfd6LCouxCVLgA1/m57R7oJrcvnON0lYJCwccwBX+2Mo+k457 AO9y12hotM9p5BJ1m+6i8ruYEapMeDJcKOsXoRyULW/oVhN9tyw2sxd9WpCFKhGsT710 BC6B1Z2VamQPSs001O/+GzVlln02VdbV+9zWpRHgNkG2n81tl9nXRDtLAJdNm8Ey2unv m4mZLVNcEYaplBd/SZDQizB3rnLsNlbX2J4a2WS5pneMlKdL+Z7nWRnMHZw/ZM5IESoX JPGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=LBL/8y8/LUYPF5+lyivMH99zmCcurEDsFooG2UU4WWA=; b=M2LjfD8mhCQsn84/N4D+G3bs6U6iD+r83SGAqsNjjvk75IzgYW9cHPaaj6tzOJ0zf+ uqQNA4C6sFI46w4xmDhf6RSaJB/jyG+vJE79H/TntK11KzY0RRNhdkl33w6JLds3d48d G7WAa8L6q2SJR+sAxkr3Em5i8tRm7RXzzEG+/FDU9IRjV4ZEzpw406UHseOKfKUnpxzI o/Dzmn0SV0UQh/aNX/Q4FtblcdxG/DwnxVZP1MhV3Zb8e6KAes7LWGzaYXY7UTQFDU7O zyzmy6dn4v4i+NEaKV0vp9Ubqjb1IBwdKOKUJb2qI0BuB9fMvfIOcdTPrgAsHOWKwy/w BlcA== X-Gm-Message-State: AOAM532+GiQw3owSMo9JmJ6iz2/Lm07Xgf0P75JimmHVn05/Cf7XhN9S +bWqsxHInuWVH4E958fQ2lW8ww== X-Google-Smtp-Source: ABdhPJwfFQ63TrQfru3/+Z/7dBzyzpa0UwjSeQH0rtIVp+Pb8HIBVLXpCN/yGk2ZdKFzTzOr/OhA4g== X-Received: by 2002:a17:906:52c7:b0:6ce:a880:50a3 with SMTP id w7-20020a17090652c700b006cea88050a3mr32905178ejn.437.1653568311744; Thu, 26 May 2022 05:31:51 -0700 (PDT) Received: from [192.168.0.177] (xdsl-188-155-176-92.adslplus.ch. [188.155.176.92]) by smtp.gmail.com with ESMTPSA id d4-20020a50e404000000b0042617ba63c4sm742811edm.78.2022.05.26.05.31.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 May 2022 05:31:51 -0700 (PDT) Message-ID: <4ee1f7e8-d73f-21f7-eaab-4c8fdca34a31@linaro.org> Date: Thu, 26 May 2022 14:31:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v4 3/3] tpm: Add tpm_tis_i2c backend for tpm_tis_core Content-Language: en-US To: Alexander Steffen , jarkko@kernel.org, linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org Cc: peterhuewe@gmx.de, jgg@ziepe.ca, krzysztof.kozlowski+dt@linaro.org, Johannes Holland , Amir Mizinski References: <20220525165849.7789-1-Alexander.Steffen@infineon.com> <20220525165849.7789-4-Alexander.Steffen@infineon.com> From: Krzysztof Kozlowski In-Reply-To: <20220525165849.7789-4-Alexander.Steffen@infineon.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25/05/2022 18:58, Alexander Steffen wrote: > Implement the TCG I2C Interface driver, as specified in the TCG PC > Client Platform TPM Profile (PTP) specification for TPM 2.0 v1.04 > revision 14, section 8, I2C Interface Definition. > > This driver supports Guard Times. That is, if required by the TPM, the > driver has to wait by a vendor-specific time after each I2C read/write. > The specific time is read from the TPM_I2C_INTERFACE_CAPABILITY register. > > Unfortunately, the TCG specified almost but not quite compatible > register addresses. Therefore, the TIS register addresses need to be > mapped to I2C ones. The locality is stripped because for now, only > locality 0 is supported. > > Add a sanity check to I2C reads of e.g. TPM_ACCESS and TPM_STS. This is > to detect communication errors and issues due to non-standard behaviour > (E.g. the clock stretching quirk in the BCM2835, see 4dbfb5f4401f). In > case the sanity check fails, attempt a retry. > > Co-developed-by: Johannes Holland > Signed-off-by: Johannes Holland > Co-developed-by: Amir Mizinski > Signed-off-by: Amir Mizinski > Signed-off-by: Alexander Steffen > --- > drivers/char/tpm/Kconfig | 12 + > drivers/char/tpm/Makefile | 1 + > drivers/char/tpm/tpm_tis_i2c.c | 406 +++++++++++++++++++++++++++++++++ > 3 files changed, 419 insertions(+) > create mode 100644 drivers/char/tpm/tpm_tis_i2c.c > > diff --git a/drivers/char/tpm/Kconfig b/drivers/char/tpm/Kconfig > index 4a5516406c22..927088b2c3d3 100644 > --- a/drivers/char/tpm/Kconfig > +++ b/drivers/char/tpm/Kconfig > @@ -74,6 +74,18 @@ config TCG_TIS_SPI_CR50 > If you have a H1 secure module running Cr50 firmware on SPI bus, > say Yes and it will be accessible from within Linux. > > +config TCG_TIS_I2C > + tristate "TPM Interface Specification 1.3 Interface / TPM 2.0 FIFO Interface - (I2C - generic)" > + depends on I2C > + select CRC_CCITT > + select TCG_TIS_CORE > + help > + If you have a TPM security chip, compliant with the TCG TPM PTP > + (I2C interface) specification and connected to an I2C bus master, > + say Yes and it will be accessible from within Linux. > + To compile this driver as a module, choose M here; > + the module will be called tpm_tis_i2c. > + > config TCG_TIS_SYNQUACER > tristate "TPM Interface Specification 1.2 Interface / TPM 2.0 FIFO Interface (MMIO - SynQuacer)" > depends on ARCH_SYNQUACER || COMPILE_TEST > diff --git a/drivers/char/tpm/Makefile b/drivers/char/tpm/Makefile > index 66d39ea6bd10..0222b1ddb310 100644 > --- a/drivers/char/tpm/Makefile > +++ b/drivers/char/tpm/Makefile > @@ -29,6 +29,7 @@ tpm_tis_spi-$(CONFIG_TCG_TIS_SPI_CR50) += tpm_tis_spi_cr50.o > > obj-$(CONFIG_TCG_TIS_I2C_CR50) += tpm_tis_i2c_cr50.o > > +obj-$(CONFIG_TCG_TIS_I2C) += tpm_tis_i2c.o > obj-$(CONFIG_TCG_TIS_I2C_ATMEL) += tpm_i2c_atmel.o > obj-$(CONFIG_TCG_TIS_I2C_INFINEON) += tpm_i2c_infineon.o > obj-$(CONFIG_TCG_TIS_I2C_NUVOTON) += tpm_i2c_nuvoton.o > diff --git a/drivers/char/tpm/tpm_tis_i2c.c b/drivers/char/tpm/tpm_tis_i2c.c > new file mode 100644 > index 000000000000..8b9218e5405f > --- /dev/null > +++ b/drivers/char/tpm/tpm_tis_i2c.c > @@ -0,0 +1,406 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (c) 2014-2021 Nuvoton Technology corporation > + * Copyright (C) 2019-2022 Infineon Technologies AG > + * > + * This device driver implements the TPM interface as defined in the TCG PC > + * Client Platform TPM Profile (PTP) Specification for TPM 2.0 v1.04 > + * Revision 14. > + * > + * It is based on the tpm_tis_spi device driver. > + */ > + > +#include > +#include > +#include > +#include > +#include Is it used? > +#include > +#include Is it used? > +#include Is it used? > + > +#include > +#include > +#include > +#include > +#include The same for these three. Best regards, Krzysztof