[PATCH 1/1] tpm: Add Kconfig option to avoid disabling LPC CLKRUN unconditionally

From: Javier Martinez Canillas
Date: Mon Dec 18 2017 - 05:10:01 EST


Commit 5e572cab92f0 ("tpm: Enable CLKRUN protocol for Braswell systems")
added logic in the TPM TIS driver to disable the Low Pin Count CLKRUN
signal during TPM transations.

Unfortunately this breaks other devices that are attached into the LPC
bus (e.g: PS/2 mouse and keyboards), so the CLKRUN signal shouldn't be
disabled unconditionally.

Until a proper solution is found, add a Kconfig option to explicitly
enable that behavior if needed instead of doing it unconditionally on
all Braswell machines.

Fixes: 5e572cab92f0 ("tpm: Enable CLKRUN protocol for Braswell systems")
Signed-off-by: Javier Martinez Canillas <javierm@xxxxxxxxxx>
---
drivers/char/tpm/Kconfig | 10 ++++++++++
drivers/char/tpm/tpm_tis_core.c | 2 +-
2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/Kconfig b/drivers/char/tpm/Kconfig
index a30352202f1f..220bd24e399f 100644
--- a/drivers/char/tpm/Kconfig
+++ b/drivers/char/tpm/Kconfig
@@ -43,6 +43,16 @@ config TCG_TIS
within Linux. To compile this driver as a module, choose M here;
the module will be called tpm_tis.

+config TCG_TIS_ENABLE_CLKRUN_QUIRK
+ bool "Enable LPC CLKRUN workaround for Braswell systems TPM" if EXPERT
+ depends on TCG_TIS_CORE && X86
+ default n
+ ---help---
+ On Intel Braswell systems, the Low Pin Count bus CLKRUN signal has to
+ be disabled during TPM devices transactions to operate correctly. This
+ could break other devices attached to the LPC bus (i.e: PS/2 mouse and
+ keyboards) so only enable if the TPM is the only device in the LPC bus.
+
config TCG_TIS_SPI
tristate "TPM Interface Specification 1.3 Interface / TPM 2.0 FIFO Interface - (SPI)"
depends on SPI
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index e7bd2e750f69..0858c08b3b89 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -688,7 +688,7 @@ static void tpm_tis_clkrun_enable(struct tpm_chip *chip, bool value)
struct tpm_tis_data *data = dev_get_drvdata(&chip->dev);
u32 clkrun_val;

- if (!IS_ENABLED(CONFIG_X86) || !is_bsw())
+ if (!IS_ENABLED(TCG_TIS_ENABLE_CLKRUN_QUIRK) || !is_bsw())
return;

if (value) {
--
2.14.3