[tpmdd-devel] 0001-added-tpm-2.0-support-to-nuvoton-i2c-driver.patch
diff mbox

Message ID 20160419050442.7048840F8@taln70.nuvoton.co.il
State New
Headers show

Commit Message

andrew.zamansky@nuvoton.com April 19, 2016, 5:04 a.m. UTC
>From b1503617a4c2b89f5a366a3d38b303b5de606c59 Mon Sep 17 00:00:00 2001
From: andrew azmansky <andrew.zamansky@nuvoton.com>
Date: Thu, 7 Apr 2016 09:19:57 +0300
Subject: [PATCH 1/1] added tpm 2.0 support to nuvoton i2c driver

add tpm 2.0 support to nuvoton i2c tpm driver

Signed-off-by: andrew azmansky <andrew.zamansky@nuvoton.com>
---
 .../devicetree/bindings/i2c/trivial-devices.txt    |  1 +
 drivers/char/tpm/tpm_i2c_nuvoton.c                 | 25 +++++++++++++++++++---
 2 files changed, 23 insertions(+), 3 deletions(-)

--
1.9.1



===========================================================================================
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z

Comments

Jarkko Sakkinen April 19, 2016, 10:02 a.m. UTC | #1
On Tue, Apr 19, 2016 at 08:04:42AM +0300, Andrew Zamansky (NTIL) wrote:
> >From b1503617a4c2b89f5a366a3d38b303b5de606c59 Mon Sep 17 00:00:00 2001
> From: andrew azmansky <andrew.zamansky@nuvoton.com>
> Date: Thu, 7 Apr 2016 09:19:57 +0300
> Subject: [PATCH 1/1] added tpm 2.0 support to nuvoton i2c driver
> 
> add tpm 2.0 support to nuvoton i2c tpm driver
> 
> Signed-off-by: andrew azmansky <andrew.zamansky@nuvoton.com>


https://www.kernel.org/doc/Documentation/SubmittingPatches

/Jarkko

> ---
>  .../devicetree/bindings/i2c/trivial-devices.txt    |  1 +
>  drivers/char/tpm/tpm_i2c_nuvoton.c                 | 25 +++++++++++++++++++---
>  2 files changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/i2c/trivial-devices.txt b/Documentation/devicetree/bindings/i2c/trivial-devices.txt
> index 53987449..0a07cbc 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 (TPM) 6xx series
>  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 847f159..215a2b4 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
>   *
> @@ -163,7 +163,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
>   */
> @@ -601,10 +601,28 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
>                 }
>         }
> 
> +       rc = tpm2_probe(chip);
> +       if (rc)
> +               return rc;
> +
>         if (tpm_get_timeouts(chip))
>                 return -ENODEV;
> 
> -       if (tpm_do_selftest(chip))
> +       if (chip->flags & TPM_CHIP_FLAG_TPM2) {
> +
> +               rc = tpm2_do_selftest(chip);
> +               if (rc == TPM2_RC_INITIALIZE) {
> +                       if (tpm2_startup(chip, TPM2_SU_CLEAR))
> +                               return -ENODEV;
> +
> +                       rc = tpm2_do_selftest(chip);
> +               }
> +
> +       } else {
> +               rc = tpm_do_selftest(chip);
> +       }
> +
> +       if (rc)
>                 return -ENODEV;
> 
>         return tpm_chip_register(chip);
> @@ -628,6 +646,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"},
>         {},
>  };
>  MODULE_DEVICE_TABLE(of, i2c_nuvoton_of_match);
> --
> 1.9.1
> 
> 
> 
> ===========================================================================================
> The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.
> 
> ------------------------------------------------------------------------------
> Find and fix application performance issues faster with Applications Manager
> Applications Manager provides deep performance insights into multiple tiers of
> your business applications. It resolves application problems quickly and
> reduces your MTTR. Get your free trial!
> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
> _______________________________________________
> tpmdd-devel mailing list
> tpmdd-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tpmdd-devel

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z

Patch
diff mbox

diff --git a/Documentation/devicetree/bindings/i2c/trivial-devices.txt b/Documentation/devicetree/bindings/i2c/trivial-devices.txt
index 53987449..0a07cbc 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 (TPM) 6xx series
 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 847f159..215a2b4 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
  *
@@ -163,7 +163,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
  */
@@ -601,10 +601,28 @@  static int i2c_nuvoton_probe(struct i2c_client *client,
                }
        }

+       rc = tpm2_probe(chip);
+       if (rc)
+               return rc;
+
        if (tpm_get_timeouts(chip))
                return -ENODEV;

-       if (tpm_do_selftest(chip))
+       if (chip->flags & TPM_CHIP_FLAG_TPM2) {
+
+               rc = tpm2_do_selftest(chip);
+               if (rc == TPM2_RC_INITIALIZE) {
+                       if (tpm2_startup(chip, TPM2_SU_CLEAR))
+                               return -ENODEV;
+
+                       rc = tpm2_do_selftest(chip);
+               }
+
+       } else {
+               rc = tpm_do_selftest(chip);
+       }
+
+       if (rc)
                return -ENODEV;

        return tpm_chip_register(chip);
@@ -628,6 +646,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"},
        {},
 };
 MODULE_DEVICE_TABLE(of, i2c_nuvoton_of_match);