devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tpm: Add support for Atmel I2C TPMs
@ 2013-09-11 20:58 Jason Gunthorpe
  2013-09-11 22:44 ` [tpmdd-devel] " Peter Hüwe
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jason Gunthorpe @ 2013-09-11 20:58 UTC (permalink / raw)
  To: tpmdd-devel, Teddy Reed, Teddy Reed, Leonidas Da Silva Barbosa,
	Ashley Lai, Rajiv Andrade, Peter Huewe, devicetree

This is based on the work of Teddy Reed <teddy@prosauce.org> published
on GitHub:
 https://github.com/theopolis/tpm-i2c-atmel.git
 34894b988b67e0ae55088d6388e77b0dbf10c07d

That driver was never merged, I have taken it as a starting point,
forward ported, tested and revised the driver:
 - Make it broadly textually similar to the Infineon and Nuvoton I2C
   driver
 - Place everything in a format suitable for mainline inclusion
 - Use high level I2C functions i2c_smbus_write_i2c_block_data and
   i2c_master_recv for data xfer
 - Use the timeout system from the core code, by faking out a status
   register
 - checkpatch cleanups
 - Testing on ARM Kirkwood, with this device tree, using a
   AT97SC3204T-X1A180
        tpm@29 {
                compatible = "atmel,at97sc3204t";
                reg = <0x29>;
        };

PENDING: Teddy will need to provide a Signed-Off line for this driver,
although very little of his original text remained unchanged, the
work to discover the protocol is entirely his and he will need to
certify the Developer Certification of Origin that it is suitable
for mainline inclusion.

[jgg: revised and tested]
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
---
 .../devicetree/bindings/i2c/trivial-devices.txt    |   1 +
 drivers/char/tpm/Kconfig                           |   9 +
 drivers/char/tpm/Makefile                          |   1 +
 drivers/char/tpm/tpm_i2c_atmel.c                   | 276 +++++++++++++++++++++
 4 files changed, 287 insertions(+)
 create mode 100644 drivers/char/tpm/tpm_i2c_atmel.c

This has been compile tested on 3.11 x86-64 and runtime tested on 3.7 ARM

I'm not yet 100% certain this driver works perfectly, for some reason
my TPM will not create an EK, which is either due to a larger sent TPM
messages becoming corrupt (combined with a TPM bug to not report an
error code) or something wrong with the TPM itself.

There is already evidence that this TPM has non-compliant firmware,
since several other commands do not work as the spec defines them to
(eg something as simple as reading TPM_PERMANENT_FLAGS has problems).

I have chips with newer firmware, and will test with those soon...

diff --git a/Documentation/devicetree/bindings/i2c/trivial-devices.txt b/Documentation/devicetree/bindings/i2c/trivial-devices.txt
index c389465..de6ceb5 100644
--- a/Documentation/devicetree/bindings/i2c/trivial-devices.txt
+++ b/Documentation/devicetree/bindings/i2c/trivial-devices.txt
@@ -15,6 +15,7 @@ adi,adt7461		+/-1C TDM Extended Temp Range I.C
 adt7461			+/-1C TDM Extended Temp Range I.C
 at,24c08		i2c serial eeprom  (24cxx)
 atmel,24c02		i2c serial eeprom  (24cxx)
+atmel,at97sc3204t       i2c trusted platform module (TPM)
 catalyst,24c32		i2c serial eeprom
 dallas,ds1307		64 x 8, Serial, I2C Real-Time Clock
 dallas,ds1338		I2C RTC with 56-Byte NV RAM
diff --git a/drivers/char/tpm/Kconfig b/drivers/char/tpm/Kconfig
index 5853712..171fa89 100644
--- a/drivers/char/tpm/Kconfig
+++ b/drivers/char/tpm/Kconfig
@@ -33,6 +33,15 @@ config TCG_TIS
 	  from within Linux.  To compile this driver as a module, choose
 	  M here; the module will be called tpm_tis.
 
+config TCG_TIS_I2C_ATMEL
+	tristate "TPM Interface Specification 1.2 Interface (I2C - Atmel)"
+	depends on I2C
+	---help---
+	  If you have an Atmel I2C TPM security chip 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_atmel.
+
 config TCG_TIS_I2C_INFINEON
 	tristate "TPM Interface Specification 1.2 Interface (I2C - Infineon)"
 	depends on I2C
diff --git a/drivers/char/tpm/Makefile b/drivers/char/tpm/Makefile
index 468a6aa..c328aa9 100644
--- a/drivers/char/tpm/Makefile
+++ b/drivers/char/tpm/Makefile
@@ -12,6 +12,7 @@ ifdef CONFIG_TCG_IBMVTPM
 endif
 endif
 obj-$(CONFIG_TCG_TIS) += tpm_tis.o
+obj-$(CONFIG_TCG_TIS_I2C_ATMEL) += tpm_i2c_atmel.o
 obj-$(CONFIG_TCG_TIS_I2C_INFINEON) += tpm_i2c_infineon.o
 obj-$(CONFIG_TCG_NUVOTON_I2C) += tpm_nuvoton_i2c.o
 obj-$(CONFIG_TCG_NSC) += tpm_nsc.o
diff --git a/drivers/char/tpm/tpm_i2c_atmel.c b/drivers/char/tpm/tpm_i2c_atmel.c
new file mode 100644
index 0000000..203ccfa
--- /dev/null
+++ b/drivers/char/tpm/tpm_i2c_atmel.c
@@ -0,0 +1,276 @@
+/*
+ * ATMEL I2C TPM AT97SC3204T
+ *
+ * Copyright (C) 2012 V Lab Technologies
+ *  Teddy Reed <teddy@prosauce.org>
+ * Copyright (C) 2013, Obsidian Research Corp.
+ *  Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
+ * Device driver for ATMEL I2C TPMs.
+ *
+ * Teddy Reed determined the basic I2C command flow, unlike other I2C TPM
+ * devices the raw TCG formatted TPM command data is written via I2C and then
+ * raw TCG formatted TPM command data is returned via I2C.
+ *
+ * TGC status/locality/etc functions seen in the LPC implementation do not
+ * seem to be present.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see http://www.gnu.org/licenses/>.
+ */
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include "tpm.h"
+
+#define I2C_DRIVER_NAME "tpm_i2c_atmel"
+
+#define TPM_I2C_SHORT_TIMEOUT  750     /* ms */
+#define TPM_I2C_LONG_TIMEOUT   2000    /* 2 sec */
+
+#define ATMEL_STS_OK 1
+
+struct priv_data {
+	size_t len;
+	u8 buffer[TPM_BUFSIZE];
+};
+
+static int i2c_atmel_send(struct tpm_chip *chip, u8 *buf, size_t len)
+{
+	struct priv_data *priv = chip->vendor.priv;
+	struct i2c_client *client = to_i2c_client(chip->dev);
+	s32 status;
+
+	priv->len = 0;
+
+	if (len <= 2)
+		return -EIO;
+
+	status = i2c_smbus_write_i2c_block_data(client, buf[0], len - 1,
+						buf + 1);
+	dev_dbg(chip->dev,
+		"%s(buf=%*ph len=%0zx) -> sts=%d\n", __func__,
+		(int)max_t(size_t, 64, len), buf, len, status);
+	return status;
+}
+
+static int i2c_atmel_recv(struct tpm_chip *chip, u8 *buf, size_t count)
+{
+	struct priv_data *priv = chip->vendor.priv;
+
+	if (priv->len == 0)
+		return -EIO;
+	if (priv->len > count)
+		return -ENOMEM;
+
+	memcpy(buf, priv->buffer, priv->len);
+	dev_dbg(chip->dev,
+		"%s(buf=%*ph count=%0zx) -> ret=%zd\n", __func__,
+		(int)max_t(size_t, 64, priv->len), buf, count, priv->len);
+	return priv->len;
+}
+
+static void i2c_atmel_cancel(struct tpm_chip *chip)
+{
+	dev_err(chip->dev, "TPM operation cancellation was requested, but is not supported");
+}
+
+static u8 i2c_atmel_read_status(struct tpm_chip *chip)
+{
+	struct priv_data *priv = chip->vendor.priv;
+	struct i2c_client *client = to_i2c_client(chip->dev);
+	int rc;
+
+	/* The TPM fails the I2C read until it is ready, so we do the entire
+	 * transfer here and buffer it locally. This way the common code can
+	 * properly handle the timeouts. */
+	priv->len = 0;
+	memset(priv->buffer, 0, sizeof(priv->buffer));
+
+	/* The TPM returns bytes and then signals stop. There is no way to
+	 * know in advance how many bytes it will return. The I2C layer will
+	 * read until it sees the stop. */
+	rc = i2c_master_recv(client, priv->buffer, sizeof(priv->buffer));
+	dev_dbg(chip->dev,
+		"%s: sts=%d", __func__, rc);
+	if (rc <= 0)
+		return 0;
+
+	priv->len = rc;
+
+	/* FIXME: The I2C layer is broken (see REVISIT comment in
+	 * i2c_transfer) and does not report the number of bytes actually
+	 * transfered. So rc is either error or sizeof(priv->buffer). TPM
+	 * messages are well structured, so we assume the length transfered
+	 * matches the length in the message. If I2C is ever fixed then this
+	 * should be removed. */
+	if (rc >= sizeof(priv->buffer)) {
+		const struct tpm_input_header *hdr = priv->buffer;
+		priv->len = be32_to_cpu(hdr->length);
+		if (priv->len > sizeof(priv->buffer))
+			priv->len = 0;
+	}
+
+	return ATMEL_STS_OK;
+}
+
+static const struct file_operations i2c_atmel_ops = {
+	.owner = THIS_MODULE,
+	.llseek = no_llseek,
+	.open = tpm_open,
+	.read = tpm_read,
+	.write = tpm_write,
+	.release = tpm_release,
+};
+
+static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL);
+static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL);
+static DEVICE_ATTR(enabled, S_IRUGO, tpm_show_enabled, NULL);
+static DEVICE_ATTR(active, S_IRUGO, tpm_show_active, NULL);
+static DEVICE_ATTR(owned, S_IRUGO, tpm_show_owned, NULL);
+static DEVICE_ATTR(temp_deactivated, S_IRUGO, tpm_show_temp_deactivated, NULL);
+static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps_1_2, NULL);
+static DEVICE_ATTR(cancel, S_IWUSR | S_IWGRP, NULL, tpm_store_cancel);
+static DEVICE_ATTR(durations, S_IRUGO, tpm_show_durations, NULL);
+static DEVICE_ATTR(timeouts, S_IRUGO, tpm_show_timeouts, NULL);
+
+static struct attribute *i2c_atmel_attrs[] = {
+	&dev_attr_pubek.attr,
+	&dev_attr_pcrs.attr,
+	&dev_attr_enabled.attr,
+	&dev_attr_active.attr,
+	&dev_attr_owned.attr,
+	&dev_attr_temp_deactivated.attr,
+	&dev_attr_caps.attr,
+	&dev_attr_cancel.attr,
+	&dev_attr_durations.attr,
+	&dev_attr_timeouts.attr,
+	NULL,
+};
+
+static struct attribute_group i2c_atmel_attr_grp = {
+	.attrs = i2c_atmel_attrs
+};
+
+static bool i2c_atmel_req_canceled(struct tpm_chip *chip, u8 status)
+{
+	return 0;
+}
+
+static const struct tpm_vendor_specific i2c_atmel = {
+	.status = i2c_atmel_read_status,
+	.recv = i2c_atmel_recv,
+	.send = i2c_atmel_send,
+	.cancel = i2c_atmel_cancel,
+	.req_complete_mask = ATMEL_STS_OK,
+	.req_complete_val = ATMEL_STS_OK,
+	.req_canceled = i2c_atmel_req_canceled,
+	.attr_group = &i2c_atmel_attr_grp,
+	.miscdev.fops = &i2c_atmel_ops,
+};
+
+static int i2c_atmel_probe(struct i2c_client *client,
+			   const struct i2c_device_id *id)
+{
+	int rc;
+	struct tpm_chip *chip;
+	struct device *dev = &client->dev;
+
+	if (!i2c_check_functionality(client->adapter,
+				     I2C_FUNC_I2C |
+				     I2C_FUNC_SMBUS_WRITE_BLOCK_DATA))
+		return -ENODEV;
+
+	chip = tpm_register_hardware(dev, &i2c_atmel);
+	if (!chip) {
+		dev_err(dev, "%s() error in tpm_register_hardware\n", __func__);
+		return -ENODEV;
+	}
+
+	chip->vendor.priv = devm_kzalloc(dev, sizeof(struct priv_data),
+					 GFP_KERNEL);
+
+	/* Default timeouts */
+	chip->vendor.timeout_a = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
+	chip->vendor.timeout_b = msecs_to_jiffies(TPM_I2C_LONG_TIMEOUT);
+	chip->vendor.timeout_c = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
+	chip->vendor.timeout_d = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
+	chip->vendor.irq = 0;
+
+	/* There is no known way to probe for this device, and all version
+	 * information seems to be read via TPM commands. Thus we rely on the
+	 * TPM startup process in the common code to detect the device. */
+	if (tpm_get_timeouts(chip)) {
+		rc = -ENODEV;
+		goto out_err;
+	}
+
+	if (tpm_do_selftest(chip)) {
+		rc = -ENODEV;
+		goto out_err;
+	}
+
+	return 0;
+
+out_err:
+	tpm_dev_vendor_release(chip);
+	tpm_remove_hardware(chip->dev);
+	return rc;
+}
+
+static int i2c_atmel_remove(struct i2c_client *client)
+{
+	struct device *dev = &(client->dev);
+	struct tpm_chip *chip = dev_get_drvdata(dev);
+
+	if (chip)
+		tpm_dev_vendor_release(chip);
+	tpm_remove_hardware(dev);
+	kfree(chip);
+	return 0;
+}
+
+static const struct i2c_device_id i2c_atmel_id[] = {
+	{I2C_DRIVER_NAME, 0},
+	{}
+};
+MODULE_DEVICE_TABLE(i2c, i2c_atmel_id);
+
+#ifdef CONFIG_OF
+static const struct of_device_id i2c_atmel_of_match[] = {
+	{.compatible = "atmel,at97sc3204t"},
+	{},
+};
+MODULE_DEVICE_TABLE(of, i2c_atmel_of_match);
+#endif
+
+static SIMPLE_DEV_PM_OPS(i2c_atmel_pm_ops, tpm_pm_suspend, tpm_pm_resume);
+
+static struct i2c_driver i2c_atmel_driver = {
+	.id_table = i2c_atmel_id,
+	.probe = i2c_atmel_probe,
+	.remove = i2c_atmel_remove,
+	.driver = {
+		.name = I2C_DRIVER_NAME,
+		.owner = THIS_MODULE,
+		.pm = &i2c_atmel_pm_ops,
+		.of_match_table = of_match_ptr(i2c_atmel_of_match),
+	},
+};
+
+module_i2c_driver(i2c_atmel_driver);
+
+MODULE_AUTHOR("Jason Gunthorpe <jgunthorpe@obsidianresearch.com>");
+MODULE_DESCRIPTION("Atmel TPM I2C Driver");
+MODULE_LICENSE("GPL");
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [tpmdd-devel] [PATCH] tpm: Add support for Atmel I2C TPMs
  2013-09-11 20:58 [PATCH] tpm: Add support for Atmel I2C TPMs Jason Gunthorpe
@ 2013-09-11 22:44 ` Peter Hüwe
  2013-09-11 23:08 ` Jason Gunthorpe
       [not found] ` <CADUykeorCx+YY1mF4DazXAmmnS=ocjdxeT2mHRsRxmJv04LFSQ@mail.gmail.com>
  2 siblings, 0 replies; 7+ messages in thread
From: Peter Hüwe @ 2013-09-11 22:44 UTC (permalink / raw)
  To: tpmdd-devel
  Cc: Jason Gunthorpe, Teddy Reed, Teddy Reed,
	Leonidas Da Silva Barbosa, Ashley Lai, Rajiv Andrade, Peter Huewe,
	devicetree

Am Mittwoch, 11. September 2013, 22:58:07 schrieb Jason Gunthorpe:
> This is based on the work of Teddy Reed <teddy@prosauce.org> published
> on GitHub:
>  https://github.com/theopolis/tpm-i2c-atmel.git
>  34894b988b67e0ae55088d6388e77b0dbf10c07d
> 
> That driver was never merged, I have taken it as a starting point,
> forward ported, tested and revised the driver:
>  - Make it broadly textually similar to the Infineon and Nuvoton I2C
>    driver
>  - Place everything in a format suitable for mainline inclusion
>  - Use high level I2C functions i2c_smbus_write_i2c_block_data and
>    i2c_master_recv for data xfer
>  - Use the timeout system from the core code, by faking out a status
>    register
>  - checkpatch cleanups
>  - Testing on ARM Kirkwood, with this device tree, using a
>    AT97SC3204T-X1A180
>         tpm@29 {
>                 compatible = "atmel,at97sc3204t";
>                 reg = <0x29>;
>         };
> 
> PENDING: Teddy will need to provide a Signed-Off line for this driver,
> although very little of his original text remained unchanged, the
> work to discover the protocol is entirely his and he will need to
> certify the Developer Certification of Origin that it is suitable
> for mainline inclusion.
> 
> [jgg: revised and tested]
> Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>


Hi Jason,

thanks for porting yet another driver.
I think I'll stage them (nuvoton, st and atmel) all in a temporary branch 
"testing-and-review" so it's easier for people to try them out.

Thanks,
Peter

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tpm: Add support for Atmel I2C TPMs
  2013-09-11 20:58 [PATCH] tpm: Add support for Atmel I2C TPMs Jason Gunthorpe
  2013-09-11 22:44 ` [tpmdd-devel] " Peter Hüwe
@ 2013-09-11 23:08 ` Jason Gunthorpe
  2013-09-11 23:23   ` [tpmdd-devel] " Peter Hüwe
       [not found] ` <CADUykeorCx+YY1mF4DazXAmmnS=ocjdxeT2mHRsRxmJv04LFSQ@mail.gmail.com>
  2 siblings, 1 reply; 7+ messages in thread
From: Jason Gunthorpe @ 2013-09-11 23:08 UTC (permalink / raw)
  To: tpmdd-devel, Teddy Reed, Teddy Reed, Leonidas Da Silva Barbosa,
	Ashley Lai, Rajiv Andrade, Peter Huewe, devicetree

On Wed, Sep 11, 2013 at 02:58:07PM -0600, Jason Gunthorpe wrote:

> I'm not yet 100% certain this driver works perfectly, for some reason
> my TPM will not create an EK, which is either due to a larger sent TPM
> messages becoming corrupt (combined with a TPM bug to not report an
> error code) or something wrong with the TPM itself.

> +
> +	status = i2c_smbus_write_i2c_block_data(client, buf[0], len - 1,
> +						buf + 1);

Thankfully Peter pointed out that these calls only transfer 32 bytes,
which causes the problem I observed. The TPM returns success with a
corrupted response when you truncate the request, apparently.

Fixing it with:

+	status = i2c_master_send(client, buf, len);

Has the driver pass all my tests. I will post a v1 after a few days
and collect any other comments.

Jason

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [tpmdd-devel] [PATCH] tpm: Add support for Atmel I2C TPMs
  2013-09-11 23:08 ` Jason Gunthorpe
@ 2013-09-11 23:23   ` Peter Hüwe
  2013-09-11 23:52     ` Peter Hüwe
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Hüwe @ 2013-09-11 23:23 UTC (permalink / raw)
  To: tpmdd-devel
  Cc: Jason Gunthorpe, Teddy Reed, Teddy Reed,
	Leonidas Da Silva Barbosa, Ashley Lai, Rajiv Andrade, Peter Huewe,
	devicetree

Hi Jason,

Am Donnerstag, 12. September 2013, 01:08:41 schrieb Jason Gunthorpe:
> On Wed, Sep 11, 2013 at 02:58:07PM -0600, Jason Gunthorpe wrote:
> > I'm not yet 100% certain this driver works perfectly, for some reason
> > my TPM will not create an EK, which is either due to a larger sent TPM
> > messages becoming corrupt (combined with a TPM bug to not report an
> > error code) or something wrong with the TPM itself.
> > 
> > +
> > +	status = i2c_smbus_write_i2c_block_data(client, buf[0], len - 1,
> > +						buf + 1);
> 
> Thankfully Peter pointed out that these calls only transfer 32 bytes,
> which causes the problem I observed. The TPM returns success with a
> corrupted response when you truncate the request, apparently.
> 
> Fixing it with:
> 
> +	status = i2c_master_send(client, buf, len);
> 
> Has the driver pass all my tests. I will post a v1 after a few days
> and collect any other comments.

Yes this should probably do the thing ;)


Thanks for porting yet another driver.

I think I'll stage them (nuvoton, st and atmel) all in a temporary branch 
"testing-and-review" so it's easier for people to try them out.
This branch might rebase and change all the time, but maybe it makes things 
easier (and patches can be squashed afterwards easily if needed).


But since you'll be sending a v2, I'll wait until the v2.

Thanks,
Peter



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [tpmdd-devel] [PATCH] tpm: Add support for Atmel I2C TPMs
  2013-09-11 23:23   ` [tpmdd-devel] " Peter Hüwe
@ 2013-09-11 23:52     ` Peter Hüwe
       [not found]       ` <201309120152.36878.PeterHuewe-Mmb7MZpHnFY@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Hüwe @ 2013-09-11 23:52 UTC (permalink / raw)
  To: tpmdd-devel
  Cc: Leonidas Da Silva Barbosa, Rajiv Andrade, devicetree, Ashley Lai,
	Peter Huewe, Teddy Reed

Hi,


> I think I'll stage them (nuvoton, st and atmel) all in a temporary branch
> "testing-and-review" so it's easier for people to try them out.
> This branch might rebase and change all the time, but maybe it makes things
> easier (and patches can be squashed afterwards easily if needed).
> 
> 
> But since you'll be sending a v2, I'll wait until the v2.
I staged everything here for the moment
https://github.com/PeterHuewe/linux-tpmdd/tree/testing-and-review

All three are not ready yet though.
Will rebase/update when the new versions come up.

Thanks,
Peter

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [tpmdd-devel] [PATCH] tpm: Add support for Atmel I2C TPMs
       [not found]       ` <201309120152.36878.PeterHuewe-Mmb7MZpHnFY@public.gmane.org>
@ 2013-09-17 23:56         ` Jason Gunthorpe
  0 siblings, 0 replies; 7+ messages in thread
From: Jason Gunthorpe @ 2013-09-17 23:56 UTC (permalink / raw)
  To: Peter H?we
  Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	Leonidas Da Silva Barbosa, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Ashley Lai, Rajiv Andrade, Peter Huewe, Teddy Reed

On Thu, Sep 12, 2013 at 01:52:36AM +0200, Peter H?we wrote:
> Hi,
> 
> 
> > I think I'll stage them (nuvoton, st and atmel) all in a temporary branch
> > "testing-and-review" so it's easier for people to try them out.
> > This branch might rebase and change all the time, but maybe it makes things
> > easier (and patches can be squashed afterwards easily if needed).
> > 
> > 
> > But since you'll be sending a v2, I'll wait until the v2.
> I staged everything here for the moment
> https://github.com/PeterHuewe/linux-tpmdd/tree/testing-and-review

I put up a branch on my github that has the drivers as well as parts
of a major cleanup as we both vaugely discussed.

Not finished yet, but maybe by the time you get back. It is big, I'm
just going to keep it on github for the moment.

commit dfd68b37beb8806b0a061af71436017d0b6c577e
Author: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Date:   Sat Sep 14 19:21:12 2013 -0600

    tpm: Pull everything related to /dev/tpmX into tpm-dev.c
    
    This cleans up all the identical file_operations sprinkled about in
    the drivers.
    
    To support this the way the chip structure is recovered in tpm_open
    is switched to use container_of rather than searching, otherwise this
    is just a copy of function content from tpm.c to tpm-dev.c and the
    resulting cleanup from making the functions static.
    
    Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

commit 9d83865080be4fce23c3247754c640aacd30c25e
Author: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Date:   Sat Sep 14 18:51:54 2013 -0600

    tpm: Store devname in the tpm_chip
    
    Just put the memory directly in the chip structure, rather than
    a 2nd dedicated kalloc.
    
    Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

commit 4b05342eb38db16afb5698dd7b79ce21b56e669b
Author: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Date:   Sat Sep 14 18:47:43 2013 -0600

    tpm: Create a tpm_class_ops structure and use it
    
    This replaces the static initialization of a tpm_vendor_specific
    structure in the drivers with the standard Linux idiom of providing
    a const structure of function pointers.
    
    As the first clean up step this just changes the names and copies
    ops into chip->vendor exactly as before.
    
    Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

commit 4e1a392500e4f588ec685703d0c1066c93135eaa
Author: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Date:   Sat Sep 14 17:55:30 2013 -0600

    tpm: xen-tpmfront: Fix default durations
    
    All the default durations were being set to 10 minutes which is
    way too long for the timeouts. Normal values for the longest
    duration are around 5 mins, and short duration ar around .5s.
    
    Further, these are just the default, tpm_get_timeouts will set
    them to values from the TPM (or throw an error).
    
    Just remove them.
    
    Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

commit 181416f763b9adf2cf8f9cf0ca4d377a16b255d7
Author: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Date:   Sat Sep 14 17:36:29 2013 -0600

    tpm atmel: Call request_region with the correct base
    
    Commit e0dd03caf20d040a0a86b6bd74028ec9bda545f5
    changed the code path here so that ateml_get_base_addr
    no longer directly altered the tpm_vendor_specific
    structure, and instead placed the base address on the stack.
    
    The commit missed updating the request_region call, which
    would have resulted in request_region being called with 0
    as the base address.
    
    I don't know if request_region(0, ..) will fail, if so the
    driver has been broken since 2006 and we should remove it
    from the tree as it has no users.
    
    Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

commit c41042057dc3fd156c8cb264a18dac1ce2bdf90a
Author: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Date:   Sat Sep 14 16:57:58 2013 -0600

    tpm: ibmvtpm: Use %zd formatting for size_t format arguments
    
    This suppresses compile warnings on 32 bit builds.
    
    Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tpm: Add support for Atmel I2C TPMs
       [not found]   ` <CADUykeorCx+YY1mF4DazXAmmnS=ocjdxeT2mHRsRxmJv04LFSQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2013-10-01 18:00     ` Jason Gunthorpe
  0 siblings, 0 replies; 7+ messages in thread
From: Jason Gunthorpe @ 2013-10-01 18:00 UTC (permalink / raw)
  To: Teddy Reed
  Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	Leonidas Da Silva Barbosa, Ashley Lai, Rajiv Andrade, Peter Huewe,
	devicetree-u79uwXL29TY76Z2rM5mHXA

On Tue, Oct 01, 2013 at 12:43:42AM -0600, Teddy Reed wrote:
>    Looks great, thanks again Jason!
>    Also, if anyone would like some TSSOP AT97SC3204T's, please email me
>    and I will send you a few along with breakouts and programmable crystal
>    so you can test/play/break/etc, no charge, but I'd rather only ship
>    within the USA.
>    Signed-off-by: Teddy Reed <teddy-KaFzXBG2u9Ng9hUCZPvPmw@public.gmane.org>

Thanks Teddy,

I've updated the series with the revised commit message:
https://github.com/jgunthorpe/linux/commit/4378757fbf7771ffecc3b8779856dcc938f45234

tpm: Add support for Atmel I2C TPMs
This is based on the work of Teddy Reed <teddy-KaFzXBG2u9Ng9hUCZPvPmw@public.gmane.org> published
on GitHub:
 https://github.com/theopolis/tpm-i2c-atmel.git
 34894b9

That driver was never merged, I have taken it as a starting port,
forward ported, tested and revised the driver:
 - Make it broadly textually similar to the Infineon and Nuvoton I2C
   driver
 - Place everything in a format suitable for mainline inclusion
 - Use high level I2C functions i2c_master_send and
   i2c_master_recv for data xfer
 - Use the timeout system from the core code, by faking out a status
   register
 - Only I2C transfer the number of bytes in the reply, not a fixed
   message size.
 - checkpatch cleanups
 - Testing on ARM Kirkwood, with this device tree, using a
   AT97SC3204T-X1A180
        tpm@29 {
                compatible = "atmel,at97sc3204t";
                reg = <0x29>;
        };

Signed-off-by: Teddy Reed <teddy-KaFzXBG2u9Ng9hUCZPvPmw@public.gmane.org>
[jgg: revised and tested]
Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

Jason
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-10-01 18:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-11 20:58 [PATCH] tpm: Add support for Atmel I2C TPMs Jason Gunthorpe
2013-09-11 22:44 ` [tpmdd-devel] " Peter Hüwe
2013-09-11 23:08 ` Jason Gunthorpe
2013-09-11 23:23   ` [tpmdd-devel] " Peter Hüwe
2013-09-11 23:52     ` Peter Hüwe
     [not found]       ` <201309120152.36878.PeterHuewe-Mmb7MZpHnFY@public.gmane.org>
2013-09-17 23:56         ` Jason Gunthorpe
     [not found] ` <CADUykeorCx+YY1mF4DazXAmmnS=ocjdxeT2mHRsRxmJv04LFSQ@mail.gmail.com>
     [not found]   ` <CADUykeorCx+YY1mF4DazXAmmnS=ocjdxeT2mHRsRxmJv04LFSQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-10-01 18:00     ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).