tpm: merge duplicate transmit_cmd() functions

Replaced transmit_cmd() functions in tpm-interface.c and tpm-sysfs.c
with a single tpm_transmit_cmd() that can be used in both files.

This patch is preliminary clean up work for the TPM2 support. This
function is needed for implementing TPM2 versions of the in-kernel
TPM utility functions.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
tpm: baseline for TPM2

This patch adds a flag called 'tpm2' to struct tpm_chip, which tells
whether the given device uses TPM2 protocol or not. This variable is
also exported through sysfs so that the user space software knows which
protocol to use.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
tpm: TPM2 support for tpm_calc_ordinal_durations()

Implemented TPM2 support for tpm_calc_ordinal_duration(). TPM2 version
is encapsulated into tpm2_calc_ordinal_duration() that is called by
tpm_calc_ordinal_duration() for TPM2 chips.

[jarkko.sakkinen: created tpm2-commands.c for TPM2 versions of the
 internal functions and refactored Wills changes into
 tpm2_calc_ordinal_duration()]

Signed-off-by: Will Arthur <will.c.arthur@intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
tpm: TPM2 support for tpm_pcr_read_dev()

Implemented TPM2 support for tpm_pcr_read_dev() and 'pcrs' sysfs
file.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
tpm: TPM2 support for tpm_do_selftest()

Implemented TPM2 support for tpm_do_selftest().

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
tpm: TPM2 support for tpm_getcap

This patch adds TPM2 protocol support for tpm_getcap(). A new
parameter 'property_id' was added to the function definition
in order to select a property.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
tpm: TPM2 support for tpm_pcr_extend()

Implemented TPM2 protocol support for tpm_pcr_extend().

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
tpm: TPM2 support for tpm_get_random().

Implemented TPM2 support for tpm_get_random().

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
tpm: TPM2 support for tpm_startup()

This patch implements TPM2 support for tpm_startup().

Signed-off-by: Will Arthur <will.c.arthur@intel.com>
tpm: TPM2 support for tpm_gen_interrupt().

This patch adds TPM2 support for tpm_gen_interrupt().

Signed-off-by: Will Arthur <will.c.arthur@intel.com>
tpm: enable TPM2 in the existing TIS driver

Added support for extended STS register.  This allows driver
to access the bits for detecting TPM 1.2 vs 2.0 and for
sending cancel and resetEstBit commands.

Signed-off-by: Will Arthur <will.c.arthur@intel.com>
tpm: workaround for selftest when firmware does not execute TPM2_Startup

This patch adds a workaround to tpm_do_selftest() for the situation
when firmware does not execute TPM2_Startup. This does not happen
usually in production hardware but is sometimes case with development
hardware.

Signed-off-by: Will Arthur <will.c.arthur@intel.com>
tpm: update tpm_get_timeouts() to support TPM v2.0

Encapsulated TPM1 v1.0 commands to the following internal helpers:

- tpm1_get_timeouts()
- tpm1_get_durations()

When the chip uses TPM v1.0 tpm_get_timeouts() calls these functions
to get the needed data. For TPM v2.0 constants defined in the TPM PTP
specification are simply assigned to the corresponding fields of the
struct tpm_chip instance.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
tpm: add copyright statements

Added Intel copyright statements to tpm-interface.c and tpm-sysfs.c

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
tpm: TPM 2.0 CRB Interface

This patch adds a driver for TPM security chips that are compliant
with TCG CRB 2.0 TPM specification.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>