From ff7725e74281a4ae9c776525891d45233599bce4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20=C5=BBygowski?= <michal.zygowski@3mdeb.com>
Date: Sat, 23 Apr 2022 01:06:21 +0200
Subject: drivers/intel/ptt: Use the correct detection method
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On some platforms the HFSTS4 bit 19 does not indicate active PTT.
Instead of ME HFSTS4, use TXT FTIF register to check active TPM for
the current boot. Discrete TPM shall be deactivated when PTT is
enabled so this always should return true value of PTT state.

Leave the old method for backwards compatibility if TXT FTIF would not
be applicable for older microarchitectures.

Based on DOC #560297.

TEST=Check if PTT is detected as active on MSI PRO Z690-A DDR4 WIFI

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Change-Id: I3a55c9f38f5bb94fb1186592446a28e675c1207c
Reviewed-on: https://review.coreboot.org/c/coreboot/+/63956
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Krystian Hebel <krystian.hebel@3mdeb.com>
---
 src/security/intel/txt/txt_register.h | 5 +++++
 1 file changed, 5 insertions(+)

(limited to 'src/security/intel')

diff --git a/src/security/intel/txt/txt_register.h b/src/security/intel/txt/txt_register.h
index 2137715edb..95f2a680d9 100644
--- a/src/security/intel/txt/txt_register.h
+++ b/src/security/intel/txt/txt_register.h
@@ -95,6 +95,11 @@
 #define TXT_ACM_KEY_HASH (TXT_BASE + 0x400)
 #define  TXT_ACM_KEY_HASH_LEN 0x4
 
+#define TXT_STS_FTIF (TXT_BASE + 0x800)
+#define   TXT_LPC_TPM_PRESENT	0x10000 /* Location of TPM: 001b - LPC TPM */
+#define   TXT_SPI_TPM_PRESENT	0x50000 /* Location of TPM: 101b - SPI TPM */
+#define   TXT_PTT_PRESENT	0x70000 /* Location of TPM: 111b - PTT present and active */
+
 #define TXT_E2STS (TXT_BASE + 0x8f0)
 #define  TXT_E2STS_SECRET_STS (1ull << 1)
 
-- 
cgit v1.2.3