From patchwork Wed Jun 29 07:52:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: andrew.zamansky@nuvoton.com X-Patchwork-Id: 9204361 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2559F60757 for ; Wed, 29 Jun 2016 07:51:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1691028621 for ; Wed, 29 Jun 2016 07:51:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0AECC28644; Wed, 29 Jun 2016 07:51:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1720728621 for ; Wed, 29 Jun 2016 07:50:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1bIAGu-0006fv-NY; Wed, 29 Jun 2016 07:50:56 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1bIAGt-0006fe-L7 for tpmdd-devel@lists.sourceforge.net; Wed, 29 Jun 2016 07:50:55 +0000 Received: from 212.199.177.27.static.012.net.il ([212.199.177.27] helo=herzl.nuvoton.co.il) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1bIAGr-0006SQ-KI for tpmdd-devel@lists.sourceforge.net; Wed, 29 Jun 2016 07:50:55 +0000 Received: from talu02.nuvoton.co.il (ntil-fw [212.199.177.25]) by herzl.nuvoton.co.il (8.13.8/8.13.8) with ESMTP id u5T7bj6j023067; Wed, 29 Jun 2016 10:37:45 +0300 Received: from andrew-desktop.nuvoton.com (unknown [10.191.20.94]) by talu02.nuvoton.co.il (Postfix) with ESMTP id 8993B24FD9; Wed, 29 Jun 2016 10:50:43 +0300 (IDT) From: andrew zamansky To: jarkko.sakkinen@linux.intel.com, tpmdd-devel@lists.sourceforge.net Date: Wed, 29 Jun 2016 10:52:39 +0300 Message-Id: <1467186759-5149-3-git-send-email-andrew.zamansky@nuvoton.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467186759-5149-1-git-send-email-andrew.zamansky@nuvoton.com> References: <1467186759-5149-1-git-send-email-andrew.zamansky@nuvoton.com> MIME-Version: 1.0 X-MIME-Autoconverted: from 8bit to quoted-printable by herzl.nuvoton.co.il id u5T7bj6j023067 X-Headers-End: 1bIAGr-0006SQ-KI Cc: devicetree@vger.kernel.org, andrew.zamansky@nuvoton.com, gcwilson@us.ibm.com, azamansk@nuvoton.com, Dan.Morav@nuvoton.com, stimpy1@gmail.com Subject: [tpmdd-devel] [PATCH 2/2 v4] tpm: Add TPM 2.0 support to the Nuvoton i2c driver (NPCT6xx family) X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tpmdd-devel-bounces@lists.sourceforge.net X-Virus-Scanned: ClamAV using ClamSMTP From: Jason Gunthorpe The command flow is exactly the same, the core simply needs to be told to enable TPM2 mode when the compatible string indicates a TPM2. Signed-off-by: Andrew Azmansky Signed-off-by: Jason Gunthorpe Acked-by: Rob Herring --- .../devicetree/bindings/i2c/trivial-devices.txt | 1 + drivers/char/tpm/tpm_i2c_nuvoton.c | 24 +++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/trivial-devices.txt b/Documentation/devicetree/bindings/i2c/trivial-devices.txt index 53987449..5a14ef8 100644 --- a/Documentation/devicetree/bindings/i2c/trivial-devices.txt +++ b/Documentation/devicetree/bindings/i2c/trivial-devices.txt @@ -62,6 +62,7 @@ national,lm80 Serial Interface ACPI-Compatible Microprocessor System Hardware M national,lm85 Temperature sensor with integrated fan control national,lm92 ±0.33°C Accurate, 12-Bit + Sign Temperature Sensor and Thermal Window Comparator with Two-Wire Interface nuvoton,npct501 i2c trusted platform module (TPM) +nuvoton,npct6xx i2c trusted platform module (TPM2) nxp,pca9556 Octal SMBus and I2C registered interface nxp,pca9557 8-bit I2C-bus and SMBus I/O port with reset nxp,pcf8563 Real-time clock/calendar diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c index e8ff362..5b7b459 100644 --- a/drivers/char/tpm/tpm_i2c_nuvoton.c +++ b/drivers/char/tpm/tpm_i2c_nuvoton.c @@ -1,5 +1,5 @@ /****************************************************************************** - * Nuvoton TPM I2C Device Driver Interface for WPCT301/NPCT501, + * Nuvoton TPM I2C Device Driver Interface for WPCT301/NPCT501/NPCT6XX, * based on the TCG TPM Interface Spec version 1.2. * Specifications at www.trustedcomputinggroup.org * @@ -31,6 +31,7 @@ #include #include #include +#include #include "tpm.h" /* I2C interface offsets */ @@ -52,7 +53,8 @@ #define TPM_I2C_RETRY_DELAY_SHORT 2 /* msec */ #define TPM_I2C_RETRY_DELAY_LONG 10 /* msec */ -#define I2C_DRIVER_NAME "tpm_i2c_nuvoton" +#define OF_IS_TPM2 ((void *)1) +#define I2C_IS_TPM2 1 struct priv_data { int irq; @@ -165,7 +167,7 @@ static int i2c_nuvoton_get_burstcount(struct i2c_client *client, } /* - * WPCT301/NPCT501 SINT# supports only dataAvail + * WPCT301/NPCT501/NPCT6XX SINT# supports only dataAvail * any call to this function which is not waiting for dataAvail will * set queue to NULL to avoid waiting for interrupt */ @@ -545,6 +547,16 @@ static int i2c_nuvoton_probe(struct i2c_client *client, if (!priv) return -ENOMEM; + if (dev->of_node) { + const struct of_device_id *of_id; + + of_id = of_match_device(dev->driver->of_device_id, dev); + if (of_id && of_id->data == OF_IS_TPM2) + chip->flags |= TPM_CHIP_FLAG_TPM2; + } else + if (id->driver_data == I2C_IS_TPM2) + chip->flags |= TPM_CHIP_FLAG_TPM2; + init_waitqueue_head(&priv->read_queue); /* Default timeouts */ @@ -622,7 +634,8 @@ static int i2c_nuvoton_remove(struct i2c_client *client) } static const struct i2c_device_id i2c_nuvoton_id[] = { - {I2C_DRIVER_NAME, 0}, + {"tpm_i2c_nuvoton"}, + {"tpm2_i2c_nuvoton", .driver_data = I2C_IS_TPM2}, {} }; MODULE_DEVICE_TABLE(i2c, i2c_nuvoton_id); @@ -631,6 +644,7 @@ MODULE_DEVICE_TABLE(i2c, i2c_nuvoton_id); static const struct of_device_id i2c_nuvoton_of_match[] = { {.compatible = "nuvoton,npct501"}, {.compatible = "winbond,wpct301"}, + {.compatible = "nuvoton,npct6xx", .data = OF_IS_TPM2}, {}, }; MODULE_DEVICE_TABLE(of, i2c_nuvoton_of_match); @@ -643,7 +657,7 @@ static struct i2c_driver i2c_nuvoton_driver = { .probe = i2c_nuvoton_probe, .remove = i2c_nuvoton_remove, .driver = { - .name = I2C_DRIVER_NAME, + .name = "tpm_i2c_nuvoton", .pm = &i2c_nuvoton_pm_ops, .of_match_table = of_match_ptr(i2c_nuvoton_of_match), },