summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMike Baiocchi <mbaiocch@us.ibm.com>2019-01-10 10:30:22 -0600
committerDaniel M. Crowell <dcrowell@us.ibm.com>2019-01-17 15:50:15 -0600
commitb5c6e0b3b0d4d570246cdb6215d93de955da474f (patch)
tree8ee3420271838e594655efca8347f6d810e0fb14 /src
parentfba889a1a092467ff83e8540b399c6a7f0d3e748 (diff)
downloadtalos-hostboot-b5c6e0b3b0d4d570246cdb6215d93de955da474f.tar.gz
talos-hostboot-b5c6e0b3b0d4d570246cdb6215d93de955da474f.zip
Add Support for Nuvoton 75x Model of TPMs
This commit adds the ability for hostboot code to support the Nuvoton 75x TPMs along with the current support of the 65x models. A new attribute TPM_MODEL is used to configure the appropriate settings for each model. Change-Id: I14b0f6606a1a94d0ed300fd51bbf3f50e63dfb01 RTC:202356 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/70464 Reviewed-by: Ilya Smirnov <ismirno@us.ibm.com> Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/include/usr/i2c/tpmddif.H35
-rw-r--r--src/include/usr/i2c/tpmddreasoncodes.H4
-rwxr-xr-xsrc/usr/i2c/test/tpmddtest.H5
-rwxr-xr-xsrc/usr/i2c/tpmdd.C399
-rwxr-xr-xsrc/usr/i2c/tpmdd.H41
-rwxr-xr-xsrc/usr/targeting/common/xmltohb/attribute_types_hb.xml17
-rw-r--r--src/usr/targeting/common/xmltohb/target_types_hb.xml3
7 files changed, 377 insertions, 127 deletions
diff --git a/src/include/usr/i2c/tpmddif.H b/src/include/usr/i2c/tpmddif.H
index d9ff469b8..0f57e4797 100644
--- a/src/include/usr/i2c/tpmddif.H
+++ b/src/include/usr/i2c/tpmddif.H
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2015,2018 */
+/* Contributors Listed Below - COPYRIGHT 2015,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -63,6 +63,20 @@ enum tpm_locality_t
};
/**
+ * @brief TPM Models that are supported
+ *
+ * @note Must stay in sync with TPM_MODEL in attribute_types_hb.xml
+ * @note Not using Attribute Enums since FSP does not currently support
+ * overriding enum values
+ */
+enum tpm_model_t : uint8_t
+{
+ TPM_MODEL_UNDETERMINED = 0x00,
+ TPM_MODEL_65x = 0x01,
+ TPM_MODEL_75x = 0x02,
+};
+
+/**
* @brief Structure of common parameters needed by different parts of
* the code.
*/
@@ -84,6 +98,15 @@ struct tpm_info_t
uint8_t i2cMuxBusSelector; ///< The Selector for the I2C MUX
TARGETING::EntityPath i2cMuxPath; ///< I2C MUX path
+ uint8_t model; ///< TPM Model
+ uint8_t sts; ///< STS
+ uint8_t burstCount; ///< burstCount
+ uint8_t tpmHash; ///< TPM Hash
+ uint8_t wrFifo; ///< Write FIFO
+ uint8_t rdFifo; ///< Read FIFO
+ uint8_t vendorIdOffset; ///< Vendor ID Offset
+ uint32_t vendorId; ///< Vendor ID
+
/**
* @brief Construct a default tpm_info_t
*/
@@ -100,7 +123,15 @@ struct tpm_info_t
offset(0),
addrSize(LAST_DEVICE_TYPE),
i2cMuxBusSelector(I2C_MUX::NOT_APPLICABLE),
- i2cMuxPath()
+ i2cMuxPath(),
+ model(TPM_MODEL_UNDETERMINED),
+ sts(0),
+ burstCount(0),
+ tpmHash(0),
+ wrFifo(0),
+ rdFifo(0),
+ vendorIdOffset(0),
+ vendorId(0)
{
}
};
diff --git a/src/include/usr/i2c/tpmddreasoncodes.H b/src/include/usr/i2c/tpmddreasoncodes.H
index 9041391fb..6099d66e0 100644
--- a/src/include/usr/i2c/tpmddreasoncodes.H
+++ b/src/include/usr/i2c/tpmddreasoncodes.H
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2011,2018 */
+/* Contributors Listed Below - COPYRIGHT 2011,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -87,6 +87,8 @@ enum tpmReasonCode
TPM_RC_TPM_NOT_DETECTED = TPMDD_COMP_ID | 0x0D,
TPM_RC_UNEXPECTED_VENDOR_ID = TPMDD_COMP_ID | 0x0E,
TPM_RC_UNEXPECTED_FAMILY_ID = TPMDD_COMP_ID | 0x0F,
+ TPM_ATTR_MODEL_NOT_FOUND = TPMDD_COMP_ID | 0x10,
+ TPM_ATTR_INVALID_MODEL = TPMDD_COMP_ID | 0x11,
};
}; // end TPMDD
diff --git a/src/usr/i2c/test/tpmddtest.H b/src/usr/i2c/test/tpmddtest.H
index fe1c0f703..9d68d2168 100755
--- a/src/usr/i2c/test/tpmddtest.H
+++ b/src/usr/i2c/test/tpmddtest.H
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2015,2017 */
+/* Contributors Listed Below - COPYRIGHT 2015,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -142,7 +142,8 @@ class TPMDDTest: public CxxTest::TestSuite
continue;
}
else if ((data & TPMDD::TPM_VENDORID_MASK)
- != TPMDD::TPM_VENDORID)
+ // Only 65x supported in simics for now:
+ != TPMDD::TPM_VENDORID_65x)
{
fails++;
TS_FAIL( "testTPMReadVendorID - Failed to read "
diff --git a/src/usr/i2c/tpmdd.C b/src/usr/i2c/tpmdd.C
index e782faf13..0894653b3 100755
--- a/src/usr/i2c/tpmdd.C
+++ b/src/usr/i2c/tpmdd.C
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2011,2018 */
+/* Contributors Listed Below - COPYRIGHT 2011,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -237,8 +237,7 @@ errlHndl_t tpmPerformOp( DeviceFW::OperationType i_opType,
// Set the offset for the vendor reg
- tpmInfo.offset = TPMDD::I2C_REG_VENDOR;
-
+ tpmInfo.offset = tpmInfo.vendorIdOffset;
err = tpmRead( io_buffer,
io_buflen,
@@ -427,7 +426,9 @@ bool tpmPresence (TARGETING::Target* i_pTpm)
// comparing the vendor ID
uint32_t vendorId = 0;
const size_t vendorIdSize = sizeof(vendorId);
- tpmInfo.offset = TPMDD::I2C_REG_VENDOR;
+
+ // Set the offset for the vendor reg
+ tpmInfo.offset = tpmInfo.vendorIdOffset;
pError = tpmRead(&vendorId,
vendorIdSize,
@@ -450,8 +451,8 @@ bool tpmPresence (TARGETING::Target* i_pTpm)
break;
}
- else if ( (TPMDD::TPM_VENDORID_MASK & vendorId)
- != (TPMDD::TPM_VENDORID))
+ else if ((TPMDD::TPM_VENDORID_MASK & vendorId)
+ != tpmInfo.vendorId)
{
if(verbose)
{
@@ -465,7 +466,7 @@ bool tpmPresence (TARGETING::Target* i_pTpm)
tpmInfo.port,
static_cast<uint64_t>(tpmInfo.devAddr),
vendorId,
- TPMDD::TPM_VENDORID);
+ tpmInfo.vendorId);
// Printing mux info separately, if combined, nothing is displayed
char* l_muxPath = tpmInfo.i2cMuxPath.toString();
@@ -492,109 +493,27 @@ bool tpmPresence (TARGETING::Target* i_pTpm)
ERRORLOG::ERRL_SEV_UNRECOVERABLE,
TPMDD_TPMPRESENCE,
TPM_RC_UNEXPECTED_VENDOR_ID,
- TWO_UINT32_TO_UINT64(TPMDD::TPM_VENDORID,vendorId),
+ TWO_UINT32_TO_UINT64(tpmInfo.vendorId,vendorId),
get_huid(i_pTpm),
ERRORLOG::ErrlEntry::NO_SW_CALLOUT);
break;
}
- // Verify the TPM is supported by this driver by reading and
- // comparing the family ID
- uint8_t familyId = 0;
- const size_t familyIdSize = sizeof(familyId);
- tpmInfo.offset = TPMDD::I2C_REG_FAMILYID;
-
- pError = tpmRead(&familyId,
- familyIdSize,
- tpmInfo,
- true /* silent */);
- if (pError)
- {
- if(verbose)
- {
- TRACFCOMP(g_trac_tpmdd,ERR_MRK
- "tpmPresence: tpmRead: Failed to read TPM family ID! "
- "TPM HUID=0x%08X, e/p/dA=%d/%d/0x%02X",
- TRACE_ERR_FMT,
- TARGETING::get_huid(i_pTpm),
- tpmInfo.engine,
- tpmInfo.port,
- static_cast<uint64_t>(tpmInfo.devAddr),
- TRACE_ERR_ARGS(pError));
- // Printing mux info separately, if combined, nothing is displayed
- char* l_muxPath = tpmInfo.i2cMuxPath.toString();
- TRACFCOMP(g_trac_tpmdd,
- ERR_MRK"tpmPresence: "
- "muxSelector=0x%X, muxPath=%s",
- tpmInfo.i2cMuxBusSelector,
- l_muxPath);
- free(l_muxPath);
- l_muxPath = nullptr;
- }
- break;
- }
- else if ( (TPMDD::TPM_FAMILYID_MASK & familyId)
- != (TPMDD::TPM_FAMILYID))
- {
- if(verbose)
- {
- TRACFCOMP(g_trac_tpmdd,ERR_MRK
- "tpmPresence: Sampled family ID did not match expected "
- "family ID! "
- "TPM HUID=0x%08X, e/p/dA=%d/%d/0x%02X, "
- "actual family ID=0x%02X, expected family ID=0x%02X.",
- TARGETING::get_huid(i_pTpm),
- tpmInfo.engine,
- tpmInfo.port,
- static_cast<uint64_t>(tpmInfo.devAddr),
- familyId,
- TPMDD::TPM_FAMILYID);
-
- // Printing mux info separately, if combined, nothing is displayed
- char* l_muxPath = tpmInfo.i2cMuxPath.toString();
- TRACFCOMP(g_trac_tpmdd,
- ERR_MRK"tpmPresence: "
- "muxSelector=0x%X, muxPath=%s",
- tpmInfo.i2cMuxBusSelector,
- l_muxPath);
- free(l_muxPath);
- l_muxPath = nullptr;
- }
-
- /*@
- * @errortype
- * @moduleid TPMDD_TPMPRESENCE
- * @reasoncode TPM_RC_UNEXPECTED_FAMILY_ID
- * @userdata1[24:31] Expected family ID
- * @userdata1[56:63] Actual family ID
- * @userdata2 TPM HUID
- * @devdesc Unexpected family ID read from TPM
- * @custdesc Trusted boot problem detected
- */
- pError = new ERRORLOG::ErrlEntry(
- ERRORLOG::ERRL_SEV_UNRECOVERABLE,
- TPMDD_TPMPRESENCE,
- TPM_RC_UNEXPECTED_FAMILY_ID,
- TWO_UINT32_TO_UINT64(TPMDD::TPM_FAMILYID,familyId),
- get_huid(i_pTpm),
- ERRORLOG::ErrlEntry::NO_SW_CALLOUT);
-
- break;
- }
- else
+ // TPM Nuvoton Model 75x does not support the familyId, and requires
+ // some additional setup for locality
+ if (tpmInfo.model == TPM_MODEL_75x)
{
TRACFCOMP(g_trac_tpmdd,INFO_MRK
"tpmPresence: TPM Detected! "
"TPM HUID=0x%08X, e/p/dA=%d/%d/0x%02X, "
- "vendor ID=0x%08X, family ID=0x%02X.",
+ "vendor ID=0x%08X (no family ID for model 75x)",
TARGETING::get_huid(i_pTpm),
tpmInfo.engine,
tpmInfo.port,
static_cast<uint64_t>(tpmInfo.devAddr),
- vendorId,
- familyId);
+ vendorId);
// Printing mux info separately, if combined, nothing is displayed
char* l_muxPath = tpmInfo.i2cMuxPath.toString();
@@ -606,8 +525,157 @@ bool tpmPresence (TARGETING::Target* i_pTpm)
free(l_muxPath);
l_muxPath = nullptr;
+ // Commands to enable locality 0
+ uint8_t locality = 0;
+ size_t locSize = 1;
+ // Set the offset for the loc_sel reg
+ tpmInfo.offset = TPM_REG_75x_LOC_SEL;
+ pError = tpmWrite( &locality,
+ locSize,
+ tpmInfo);
+ if (pError)
+ {
+ TRACFCOMP(g_trac_tpmdd,ERR_MRK
+ "tpmPresence: Error on 1st cmd to set up Locality for 75x "
+ "TPM HUID=0x%08X. Treat TPM as not present",
+ TARGETING::get_huid(i_pTpm));
+ break;
+ }
+
+ uint8_t val = 0x02;
+ size_t valSize = 1;
+ // Set the offset for the loc_sel reg
+ tpmInfo.offset = TPM_REG_75x_TPM_ACCESS;
+ pError = tpmWrite( &val,
+ valSize,
+ tpmInfo);
+ if (pError)
+ {
+ TRACFCOMP(g_trac_tpmdd,ERR_MRK
+ "tpmPresence: Error on 2nd cmd to set up Locality for 75x "
+ "TPM HUID=0x%08X. Treat TPM as not present",
+ TARGETING::get_huid(i_pTpm));
+ break;
+ }
+
present = true;
}
+ else
+ {
+ // Verify the TPM is supported by this driver by reading and
+ // comparing the family ID
+ uint8_t familyId = 0;
+ const size_t familyIdSize = sizeof(familyId);
+ tpmInfo.offset = TPM_REG_65x_FAMILYID_OFFSET;
+
+ pError = tpmRead(&familyId,
+ familyIdSize,
+ tpmInfo,
+ true /* silent */);
+ if (pError)
+ {
+ if(verbose)
+ {
+ TRACFCOMP(g_trac_tpmdd,ERR_MRK
+ "tpmPresence: tpmRead: Failed to read TPM family ID! "
+ "TPM HUID=0x%08X, e/p/dA=%d/%d/0x%02X"
+ TRACE_ERR_FMT,
+ TARGETING::get_huid(i_pTpm),
+ tpmInfo.engine,
+ tpmInfo.port,
+ static_cast<uint64_t>(tpmInfo.devAddr),
+ TRACE_ERR_ARGS(pError));
+
+ // Printing mux info separately, if combined,
+ // nothing is displayed
+ char* l_muxPath = tpmInfo.i2cMuxPath.toString();
+ TRACFCOMP(g_trac_tpmdd,
+ ERR_MRK"tpmPresence: "
+ "muxSelector=0x%X, muxPath=%s",
+ tpmInfo.i2cMuxBusSelector,
+ l_muxPath);
+ free(l_muxPath);
+ l_muxPath = nullptr;
+ }
+ break;
+
+ }
+ else if ( (TPMDD::TPM_FAMILYID_MASK & familyId)
+ != (TPMDD::TPM_FAMILYID_65x))
+ {
+ if(verbose)
+ {
+ TRACFCOMP(g_trac_tpmdd,ERR_MRK
+ "tpmPresence: Sampled family ID did not match expected "
+ "family ID! "
+ "TPM HUID=0x%08X, e/p/dA=%d/%d/0x%02X, "
+ "actual family ID=0x%02X, expected family ID=0x%02X.",
+ TARGETING::get_huid(i_pTpm),
+ tpmInfo.engine,
+ tpmInfo.port,
+ static_cast<uint64_t>(tpmInfo.devAddr),
+ familyId,
+ TPMDD::TPM_FAMILYID_65x);
+
+ // Printing mux info separately, if combined,
+ // nothing is displayed
+ char* l_muxPath = tpmInfo.i2cMuxPath.toString();
+ TRACFCOMP(g_trac_tpmdd,
+ ERR_MRK"tpmPresence: "
+ "muxSelector=0x%X, muxPath=%s",
+ tpmInfo.i2cMuxBusSelector,
+ l_muxPath);
+ free(l_muxPath);
+ l_muxPath = nullptr;
+ }
+
+ /*@
+ * @errortype
+ * @moduleid TPMDD_TPMPRESENCE
+ * @reasoncode TPM_RC_UNEXPECTED_FAMILY_ID
+ * @userdata1[24:31] Expected family ID
+ * @userdata1[56:63] Actual family ID
+ * @userdata2 TPM HUID
+ * @devdesc Unexpected family ID read from TPM
+ * @custdesc Trusted boot problem detected
+ */
+ pError = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ TPMDD_TPMPRESENCE,
+ TPM_RC_UNEXPECTED_FAMILY_ID,
+ TWO_UINT32_TO_UINT64(TPMDD::TPM_FAMILYID_65x,familyId),
+ get_huid(i_pTpm),
+ ERRORLOG::ErrlEntry::NO_SW_CALLOUT);
+
+ break;
+ }
+ else
+ {
+ TRACFCOMP(g_trac_tpmdd,INFO_MRK
+ "tpmPresence: TPM Detected! "
+ "TPM HUID=0x%08X, e/p/dA=%d/%d/0x%02X, "
+ "vendor ID=0x%08X, family ID=0x%02X.",
+ TARGETING::get_huid(i_pTpm),
+ tpmInfo.engine,
+ tpmInfo.port,
+ static_cast<uint64_t>(tpmInfo.devAddr),
+ vendorId,
+ familyId);
+
+ // Printing mux info separately, if combined,
+ // nothing is displayed
+ char* l_muxPath = tpmInfo.i2cMuxPath.toString();
+ TRACFCOMP(g_trac_tpmdd,
+ INFO_MRK"tpmPresence: "
+ "muxSelector=0x%X, muxPath=%s",
+ tpmInfo.i2cMuxBusSelector,
+ l_muxPath);
+ free(l_muxPath);
+ l_muxPath = nullptr;
+
+ present = true;
+ }
+ }
} while( 0 );
@@ -1383,7 +1451,7 @@ errlHndl_t tpmDrtmReset (tpm_info_t i_tpmInfo)
ENTER_MRK"tpmDrtmReset()" );
do
{
- i_tpmInfo.offset = I2C_REG_TPM_HASH;
+ i_tpmInfo.offset = TPM_REG_TPM_HASH;
regData = TPM_HASH_START;
err = tpmWrite ( &regData,
@@ -1498,6 +1566,7 @@ errlHndl_t tpmReadAttributes ( TARGETING::Target * i_target,
// These variables will be used to hold the TPM attribute data
TARGETING::TpmInfo tpmData;
+ uint8_t tpmModel = TPM_MODEL_UNDETERMINED;
do
{
@@ -1507,8 +1576,7 @@ errlHndl_t tpmReadAttributes ( TARGETING::Target * i_target,
( tpmData ) ) )
{
- const auto type = i_target ?
- i_target->getAttr<TARGETING::ATTR_TYPE>() : 0;
+ const auto type = i_target->getAttr<TARGETING::ATTR_TYPE>();
TRACFCOMP(g_trac_tpmdd,ERR_MRK
"tpmReadAttributes: Failed to read TPM_INFO "
@@ -1546,7 +1614,111 @@ errlHndl_t tpmReadAttributes ( TARGETING::Target * i_target,
}
- // Successful reading of Attribute, so extract the data
+
+ if( !( i_target->
+ tryGetAttr<TARGETING::ATTR_TPM_MODEL>
+ ( tpmModel ) ) )
+
+ {
+ const auto type = i_target->getAttr<TARGETING::ATTR_TYPE>();
+
+ TRACFCOMP(g_trac_tpmdd,ERR_MRK
+ "tpmReadAttributes: Failed to read TPM_MODEL "
+ "attribute from target HUID=0x%08X of type=0x%08X.",
+ TARGETING::get_huid(i_target),
+ type);
+
+ /*@
+ * @errortype
+ * @reasoncode TPM_ATTR_MODEL_NOT_FOUND
+ * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE
+ * @moduleid TPMDD_READATTRIBUTES
+ * @userdata1 HUID of target
+ * @userdata2 Type of target
+ * @devdesc TPM_MODEL attribute was not found for the
+ * requested target
+ * @custdesc Unexpected trusted boot related failure
+ */
+ err = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ TPMDD_READATTRIBUTES,
+ TPM_ATTR_MODEL_NOT_FOUND,
+ TARGETING::get_huid(i_target),
+ type);
+
+ // Could be FSP or HB code's fault
+ err->addProcedureCallout(HWAS::EPUB_PRC_HB_CODE,
+ HWAS::SRCI_PRIORITY_MED);
+ err->addProcedureCallout(HWAS::EPUB_PRC_SP_CODE,
+ HWAS::SRCI_PRIORITY_LOW);
+
+ err->collectTrace( TPMDD_COMP_NAME );
+
+ break;
+ }
+
+ // Hostboot code only supports Nuvoton 65x and 75x Models at this time
+ // so set model-specific attributes appropriately
+ if (tpmModel == TPM_MODEL_65x)
+ {
+ io_tpmInfo.model = tpmModel;
+ io_tpmInfo.sts = TPM_REG_65x_STS;
+ io_tpmInfo.burstCount = TPM_REG_65x_BURSTCOUNT;
+ io_tpmInfo.tpmHash = TPM_REG_65x_TPM_HASH;
+ io_tpmInfo.wrFifo = TPM_REG_65x_WR_FIFO;
+ io_tpmInfo.rdFifo = TPM_REG_65x_RD_FIFO;
+ io_tpmInfo.vendorIdOffset = TPM_REG_65x_VENDOR_ID_OFFSET;
+ io_tpmInfo.vendorId = TPM_VENDORID_65x;
+ }
+ else if (tpmModel == TPM_MODEL_75x)
+ {
+ io_tpmInfo.model = tpmModel;
+ io_tpmInfo.sts = TPM_REG_75x_STS;
+ io_tpmInfo.burstCount = TPM_REG_75x_BURSTCOUNT;
+ io_tpmInfo.tpmHash = TPM_REG_75x_TPM_HASH;
+ io_tpmInfo.wrFifo = TPM_REG_75x_WR_FIFO;
+ io_tpmInfo.rdFifo = TPM_REG_75x_RD_FIFO;
+ io_tpmInfo.vendorIdOffset = TPM_REG_75x_VENDOR_ID_OFFSET;
+ io_tpmInfo.vendorId = TPM_VENDORID_75x;
+ }
+ else
+ {
+ // Fail since invalid/unsupported TPM model is found
+ TRACFCOMP(g_trac_tpmdd,ERR_MRK
+ "tpmReadAttributes: Invalid TPM_MODEL %d from "
+ "attribute from target HUID=0x%08X",
+ tpmModel, TARGETING::get_huid(i_target));
+
+ /*@
+ * @errortype
+ * @reasoncode TPM_ATTR_INVALID_MODEL
+ * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE
+ * @moduleid TPMDD_READATTRIBUTES
+ * @userdata1 TPM Model of target
+ * @userdata2 HUID of target
+ * @devdesc TPM_MODEL attribute was set to a value that
+ * is not currently supported
+ * @custdesc Unexpected trusted boot related failure
+ */
+ err = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ TPMDD_READATTRIBUTES,
+ TPM_ATTR_INVALID_MODEL,
+ tpmModel,
+ TARGETING::get_huid(i_target));
+
+ // Could be FSP or HB code's fault
+ err->addProcedureCallout(HWAS::EPUB_PRC_HB_CODE,
+ HWAS::SRCI_PRIORITY_MED);
+ err->addProcedureCallout(HWAS::EPUB_PRC_SP_CODE,
+ HWAS::SRCI_PRIORITY_LOW);
+
+ err->collectTrace( TPMDD_COMP_NAME );
+
+ break;
+ }
+
+ // Successful reading of the Attributes, so extract the data
io_tpmInfo.port = tpmData.port;
switch(i_locality)
{
@@ -1564,6 +1736,13 @@ errlHndl_t tpmReadAttributes ( TARGETING::Target * i_target,
i_locality);
}
+ // Nuvoton 75x only supports one locality i2c address
+ // (i.e. locality is handled differently)
+ if (tpmModel == TPM_MODEL_75x)
+ {
+ io_tpmInfo.devAddr = tpmData.devAddrLocality0;
+ }
+
io_tpmInfo.engine = tpmData.engine;
io_tpmInfo.i2cMasterPath = tpmData.i2cMasterPath;
io_tpmInfo.tpmEnabled = tpmData.tpmEnabled;
@@ -1645,7 +1824,7 @@ errlHndl_t tpmReadAttributes ( TARGETING::Target * i_target,
* @moduleid TPMDD_READATTRIBUTES
* @userdata1 HUID of target
* @userdata2 Address Offset Size
- * @devdesc Invalid address offset size
+ * @devdesc Can't find TPM in ATTR_I2C_BUS_SPEED_ARRAY
*/
err = new ERRORLOG::ErrlEntry(
ERRORLOG::ERRL_SEV_UNRECOVERABLE,
@@ -1851,7 +2030,8 @@ errlHndl_t tpmReadReg ( tpm_info_t i_tpmInfo,
errlHndl_t tpmReadSTSReg ( tpm_info_t i_tpmInfo,
tpm_sts_reg_t & o_stsReg)
{
- i_tpmInfo.offset = TPMDD::I2C_REG_STS;
+ i_tpmInfo.offset = i_tpmInfo.sts;
+
return tpmRead(reinterpret_cast<void*>(&o_stsReg),
1,
i_tpmInfo);
@@ -1862,7 +2042,8 @@ errlHndl_t tpmReadSTSRegValid ( tpm_info_t i_tpmInfo,
{
errlHndl_t err = NULL;
- i_tpmInfo.offset = TPMDD::I2C_REG_STS;
+ i_tpmInfo.offset = i_tpmInfo.sts;
+
size_t polls = 0;
do
{
@@ -2158,7 +2339,7 @@ errlHndl_t tpmReadBurstCount( const tpm_info_t & i_tpmInfo,
if (NULL == err)
{
err = tpmReadReg(i_tpmInfo,
- TPMDD::I2C_REG_BURSTCOUNT,
+ i_tpmInfo.burstCount,
2,
reinterpret_cast<void*>(&burstCount));
}
@@ -2186,7 +2367,7 @@ errlHndl_t tpmWriteCommandReady( const tpm_info_t & i_tpmInfo)
stsReg.isCommandReady = 1;
return tpmWriteReg(i_tpmInfo,
- TPMDD::I2C_REG_STS,
+ i_tpmInfo.sts,
1,
reinterpret_cast<void*>(&stsReg));
@@ -2199,7 +2380,7 @@ errlHndl_t tpmWriteTpmGo( const tpm_info_t & i_tpmInfo)
stsReg.tpmGo = 1;
return tpmWriteReg(i_tpmInfo,
- TPMDD::I2C_REG_STS,
+ i_tpmInfo.sts,
1,
reinterpret_cast<void*>(&stsReg));
@@ -2212,7 +2393,7 @@ errlHndl_t tpmWriteResponseRetry( const tpm_info_t & i_tpmInfo)
stsReg.responseRetry = 1;
return tpmWriteReg(i_tpmInfo,
- TPMDD::I2C_REG_STS,
+ i_tpmInfo.sts,
1,
reinterpret_cast<void*>(&stsReg));
@@ -2259,7 +2440,7 @@ errlHndl_t tpmWriteFifo( const tpm_info_t & i_tpmInfo,
(length - curByte) :
burstCount);
err = tpmWriteReg(i_tpmInfo,
- TPMDD::I2C_REG_WR_FIFO,
+ i_tpmInfo.wrFifo,
tx_len,
curBytePtr);
if (err)
@@ -2356,7 +2537,7 @@ errlHndl_t tpmWriteFifo( const tpm_info_t & i_tpmInfo,
delay = 0;
curBytePtr = &(bytePtr[curByte]);
err = tpmWriteReg(i_tpmInfo,
- TPMDD::I2C_REG_WR_FIFO,
+ i_tpmInfo.wrFifo,
1,
curBytePtr);
// done
@@ -2556,7 +2737,7 @@ errlHndl_t tpmReadFifo( const tpm_info_t & i_tpmInfo,
delay = 0;
curBytePtr = &(bytePtr[curByte]);
err = tpmReadReg(i_tpmInfo,
- TPMDD::I2C_REG_RD_FIFO,
+ i_tpmInfo.rdFifo,
burstCount,
curBytePtr);
if (err)
diff --git a/src/usr/i2c/tpmdd.H b/src/usr/i2c/tpmdd.H
index be184e921..240bbc46c 100755
--- a/src/usr/i2c/tpmdd.H
+++ b/src/usr/i2c/tpmdd.H
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2015,2018 */
+/* Contributors Listed Below - COPYRIGHT 2015,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -67,20 +67,35 @@ enum
*/
enum nuvo_20_defs_t
{
- I2C_REG_STS = 0x0,
- I2C_REG_BURSTCOUNT = 0x1,
- I2C_REG_BURSTCOUNT_HIGH = 0x2,
- I2C_REG_FAMILYID = 0x3,
- I2C_REG_TPM_HASH = 0x4,
- I2C_REG_WR_FIFO = 0x20,
- I2C_REG_RD_FIFO = 0x40,
- I2C_REG_VENDOR = 0x60,
-
- TPM_VENDORID = 0x5010FE00,
+ // Values for Nuvoton 65x Support
+ TPM_REG_65x_STS = 0x0,
+ TPM_REG_65x_BURSTCOUNT = 0x1,
+ TPM_REG_65x_BURSTCOUNT_HIGH = 0x2,
+ TPM_REG_65x_FAMILYID_OFFSET = 0x3,
+ TPM_REG_65x_TPM_HASH = 0x4,
+ TPM_REG_65x_WR_FIFO = 0x20,
+ TPM_REG_65x_RD_FIFO = 0x40,
+ TPM_REG_65x_VENDOR_ID_OFFSET = 0x60,
+ TPM_VENDORID_65x = 0x5010FE00,
+ TPM_FAMILYID_65x = 0x04,
+
+ // Values for Nuvoton 75x Support
+ TPM_REG_75x_LOC_SEL = 0x00,
+ TPM_REG_75x_TPM_ACCESS = 0x04,
+ TPM_REG_75x_STS = 0x18,
+ TPM_REG_75x_BURSTCOUNT = 0x19,
+ // BUSTCOUNT_HIGH - unused
+ TPM_REG_75x_TPM_HASH = 0x4,
+ TPM_REG_75x_WR_FIFO = 0x24,
+ TPM_REG_75x_RD_FIFO = 0x24,
+ TPM_REG_75x_VENDOR_ID_OFFSET = 0x48,
+ TPM_VENDORID_75x = 0x5010FC00,
+ // 75X does not use a Family ID
+
+ // Common values
TPM_VENDORID_MASK = 0xFFFFFF00,
- TPM_MAXBURSTSIZE = 0xFFFF,
- TPM_FAMILYID = 0x04,
TPM_FAMILYID_MASK = 0x0C,
+ TPM_MAXBURSTSIZE = 0xFFFF,
TPM_HASH_START = 0x01,
TPM_HASH_END = 0x02,
};
diff --git a/src/usr/targeting/common/xmltohb/attribute_types_hb.xml b/src/usr/targeting/common/xmltohb/attribute_types_hb.xml
index 349d04273..c0cd729ed 100755
--- a/src/usr/targeting/common/xmltohb/attribute_types_hb.xml
+++ b/src/usr/targeting/common/xmltohb/attribute_types_hb.xml
@@ -1189,6 +1189,23 @@
<hbOnly/>
</attribute>
+ <attribute>
+ <id>TPM_MODEL</id>
+ <description>
+ Indicates TPM Model (or family) for a TPM Target
+ 0x00 = Undetermined (reserved if actively detected in the future)
+ 0x01 = Nuvoton 65x (default)
+ 0x02 = Nuvoton 75x
+ </description>
+ <simpleType>
+ <uint8_t>
+ <default>1</default>
+ </uint8_t>
+ </simpleType>
+ <persistency>non-volatile</persistency>
+ <readable/>
+ </attribute>
+
<enumerationType>
<id>TPM_ROLE</id>
<description>
diff --git a/src/usr/targeting/common/xmltohb/target_types_hb.xml b/src/usr/targeting/common/xmltohb/target_types_hb.xml
index b48f4cea0..a9cd859be 100644
--- a/src/usr/targeting/common/xmltohb/target_types_hb.xml
+++ b/src/usr/targeting/common/xmltohb/target_types_hb.xml
@@ -211,6 +211,9 @@
<id>HB_TPM_MUTEX</id>
</attribute>
<attribute>
+ <id>TPM_MODEL</id>
+ </attribute>
+ <attribute>
<id>TPM_ROLE</id>
</attribute>
</targetTypeExtension>
OpenPOWER on IntegriCloud