JUNK: Provide a vio.h good enough to compile tpm_ibmvtpm.c on x86

This way I can easily compile test all TPM drivers
tpm: Add support for the Nuvoton NPCT501 I2C TPM

This chip is/was also branded as a Winbond WPCT301.

Originally written by Dan Morav <dmorav@nuvoton.com> and posted to LKML:
https://lkml.org/lkml/2011/9/7/206

The original posting was not merged, I have taken it as a
starting point, forward ported, tested and revised the driver:
 - Rework interrupt handling to work properly with level triggered
   interrupts. The old version just locked up.
 - Synchronize various items with Peter Huewe's Infineon driver:
    * Add durations/timeouts sysfs calls
    * Remove I2C device auto-detection
    * Don't fiddle with chip->release
    * Call tpm_dev_vendor_release in the probe error path
    * Use MODULE_DEVICE_TABLE for the I2C ids
    * Provide OF compatible strings for DT support
    * Use SIMPLE_DEV_PM_OPS
    * Use module_i2c_driver
 - checkpatch cleanups
 - Testing on ARM Kirkwood with GPIO interrupts, with this device tree:
	tpm@57 {
                compatible = "nuvoton,npct501";
                reg = <0x57>;
                interrupt-parent = <&gpio1>;
                interrupts = <6 IRQ_TYPE_LEVEL_LOW>;
        };

Signed-off-by: Dan Morav <dmorav@nuvoton.com>
[jgg: revised and tested]
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
tpm: Add support for Atmel I2C TPMs

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 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_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>
TPM: STMicroelectronics st33 driver SPI

 * STMicroelectronics version 1.2.0, Copyright (C) 2013
 * STMicroelectronics comes with ABSOLUTELY NO WARRANTY.
 * This is free software, and you are welcome to redistribute it
 * under certain conditions.

This is the driver for TPM chip from ST Microelectronics.

If you have a TPM security chip from STMicroelectronics working with
an SPI, in menuconfig or .config choose the tpm driver on
device --> tpm and activate the protocol of your choice before compiling
the kernel.
The driver will be accessible from within Linux.

Tested on linux x86/x64 and beagleboard REV B & XM REV C

Signed-off-by: Mathias Leblanc <mathias.leblanc@st.com>
tpm: ibmvtpm: Use %zd formatting for size_t format arguments

This suppresses compile warnings on 32 bit builds.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
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@obsidianresearch.com>
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@obsidianresearch.com>
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@obsidianresearch.com>
tpm: Use container_of to locate the tpm_chip in tpm_open

misc_open sets the file->private_date to the misc_dev when calling
open. We can use container_of to go from the misc_dev back to the
tpm_chip.

Future clean ups will move tpm_open into a new file and this change
means we do not have to export the tpm_chip list.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
tpm: xen-tpmfront: Remove redundant dev_set_drvdata

TPM drivers should not call dev_set_drvdata, only the core code
is allowed to call dev_set_drvdata.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
tpm: i2c-infineon: Remove dev_set_drvdata

TPM drivers should not call dev_set_drvdata, only the core code
is allowed to call dev_set_drvdata.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
tpm: spi_stm_st33: Remove redundant dev_set_drvdata

TPM drivers should not call dev_set_drvdata, only the core code
is allowed to call dev_set_drvdata.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
tpm: spi_i2c_stm_st33: Remove redundant dev_set_drvdata

TPM drivers should not call dev_set_drvdata, only the core code
is allowed to call dev_set_drvdata.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
tpm: kfree(chip) should never appear in a driver

The core manages the lifetime of the chip object.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
tpm: tpm_tis: Use devm_ for all resources

This lays the ground work for fixing the lifetime issues in the TPM
core.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
tpm: tpm_tis: Cleanup platform device handling

No driver should be maintaining a list of devices, the device
core does that for us. Remove tis_chips and tis_lock.

Move the interrupt disable and locality release into a devm action,
this ensures they are called at the proper time.

Do not unregister devices if the next step is to unregister the driver,
the device core will take care of it for us.

Module unload should only unregister the drivers.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
tpm: tpm_nsc: Use devm_ for all resources

This lays the ground work for fixing the lifetime issues in the TPM
core.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
tpm: tpm_nsc: Repair use of platform devices in this driver

We need to have a driver remove method for things to work properly,
make one and move all the removal path code into there. Rely
on platform_driver_unregister to remove all devices and call the
remove function instead of doing so explicitly.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
tpm: tpm_i2c_stm_st33: Use devm_ for all resources

This lays the ground work for fixing the lifetime issues in the TPM
core.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
tpm: tpm_ibmvtpm: Use devm_ for all resources

This lays the ground work for fixing the lifetime issues in the TPM
core.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>