Commit 82cc1a49 authored by Jason Gunthorpe's avatar Jason Gunthorpe Committed by Jarkko Sakkinen

tpm: Add TPM 2.0 support to the Nuvoton i2c driver (NPCT6xx family)

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: default avatarAndrew Azmansky <andrew.zamansky@nuvoton.com>
Tested-by: default avatarAndrew Zamansky <andrew.zamansky@nuvoton.com>
Signed-off-by: default avatarJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Acked-by: default avatarRob Herring <robh@kernel.org>
Reviewed-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
parent cae8b441
...@@ -62,6 +62,7 @@ national,lm80 Serial Interface ACPI-Compatible Microprocessor System Hardware M ...@@ -62,6 +62,7 @@ national,lm80 Serial Interface ACPI-Compatible Microprocessor System Hardware M
national,lm85 Temperature sensor with integrated fan control 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 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,npct501 i2c trusted platform module (TPM)
nuvoton,npct601 i2c trusted platform module (TPM2)
nxp,pca9556 Octal SMBus and I2C registered interface nxp,pca9556 Octal SMBus and I2C registered interface
nxp,pca9557 8-bit I2C-bus and SMBus I/O port with reset nxp,pca9557 8-bit I2C-bus and SMBus I/O port with reset
nxp,pcf8563 Real-time clock/calendar nxp,pcf8563 Real-time clock/calendar
......
/****************************************************************************** /******************************************************************************
* 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. * based on the TCG TPM Interface Spec version 1.2.
* Specifications at www.trustedcomputinggroup.org * Specifications at www.trustedcomputinggroup.org
* *
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/of_device.h>
#include "tpm.h" #include "tpm.h"
/* I2C interface offsets */ /* I2C interface offsets */
...@@ -52,7 +53,8 @@ ...@@ -52,7 +53,8 @@
#define TPM_I2C_RETRY_DELAY_SHORT 2 /* msec */ #define TPM_I2C_RETRY_DELAY_SHORT 2 /* msec */
#define TPM_I2C_RETRY_DELAY_LONG 10 /* 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 { struct priv_data {
int irq; int irq;
...@@ -165,7 +167,7 @@ static int i2c_nuvoton_get_burstcount(struct i2c_client *client, ...@@ -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 * any call to this function which is not waiting for dataAvail will
* set queue to NULL to avoid waiting for interrupt * set queue to NULL to avoid waiting for interrupt
*/ */
...@@ -545,6 +547,16 @@ static int i2c_nuvoton_probe(struct i2c_client *client, ...@@ -545,6 +547,16 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
if (dev->of_node) {
const struct of_device_id *of_id;
of_id = of_match_device(dev->driver->of_match_table, 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); init_waitqueue_head(&priv->read_queue);
/* Default timeouts */ /* Default timeouts */
...@@ -620,7 +632,8 @@ static int i2c_nuvoton_remove(struct i2c_client *client) ...@@ -620,7 +632,8 @@ static int i2c_nuvoton_remove(struct i2c_client *client)
} }
static const struct i2c_device_id i2c_nuvoton_id[] = { 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); MODULE_DEVICE_TABLE(i2c, i2c_nuvoton_id);
...@@ -629,6 +642,7 @@ MODULE_DEVICE_TABLE(i2c, i2c_nuvoton_id); ...@@ -629,6 +642,7 @@ MODULE_DEVICE_TABLE(i2c, i2c_nuvoton_id);
static const struct of_device_id i2c_nuvoton_of_match[] = { static const struct of_device_id i2c_nuvoton_of_match[] = {
{.compatible = "nuvoton,npct501"}, {.compatible = "nuvoton,npct501"},
{.compatible = "winbond,wpct301"}, {.compatible = "winbond,wpct301"},
{.compatible = "nuvoton,npct601", .data = OF_IS_TPM2},
{}, {},
}; };
MODULE_DEVICE_TABLE(of, i2c_nuvoton_of_match); MODULE_DEVICE_TABLE(of, i2c_nuvoton_of_match);
...@@ -641,7 +655,7 @@ static struct i2c_driver i2c_nuvoton_driver = { ...@@ -641,7 +655,7 @@ static struct i2c_driver i2c_nuvoton_driver = {
.probe = i2c_nuvoton_probe, .probe = i2c_nuvoton_probe,
.remove = i2c_nuvoton_remove, .remove = i2c_nuvoton_remove,
.driver = { .driver = {
.name = I2C_DRIVER_NAME, .name = "tpm_i2c_nuvoton",
.pm = &i2c_nuvoton_pm_ops, .pm = &i2c_nuvoton_pm_ops,
.of_match_table = of_match_ptr(i2c_nuvoton_of_match), .of_match_table = of_match_ptr(i2c_nuvoton_of_match),
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment