Skip to contentSkip to conversation

ast2600: Add I2C TPMv2 driver

PATCH In review Eddie James 2 participants 13 messages May 13, 2022 – May 24, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover ast2600: Add I2C TPMv2 driver

This series backports the addition of a TPM TIS core driver from mainline u-boot. Then, add an I2C driver to talk to the NPCT75X chip using the TPM TIS core.
Add the TPM to the Rainier/Everest devicetree.
Also, add new board code for IBM's systems that need to "poison" the TPM during u-boot initialization.

I tested this on Everest hardware and verified in Linux that the TPM PCR0 was extended. I also tested with the TPM at the wrong bus address to verify that the code can handle a missing TPM, and I saw no errors.

Changes since v1:
- Use upstream core for I2C tpm driver. I initially couldn't get the core driver to work at all, but found a small bug in the ordering of operations in the core init. I also needed to force the locality to 0, like in the Linux NPCT75X driver.
- Use new board init code for IBM's systems that need the TPM poisoning

Eddie James (5):
tpm: core: Set timeouts before requesting locality
i2c: ast_i2c: Remove SCL direct drive mode
tpm: add support for TPMv2.x I2C chips
arm: dts: ast2600-rainier: Add NPCT75X TPM
board: ast2600-ibm: Add AST2600 BMC based POWER10+ servers

Heinrich Schuchardt (1):
tis: fix tpm_tis_remove()

Ilias Apalodimas (1):
tpm2: Introduce TIS tpm core

Johannes Holland (1):
tpm: add #ifndef to fix redeclaration build errors

Simon Glass (1):
tpm: Add more TPM2 definitions

 arch/arm/dts/ast2600-rainier.dts     |  12 +-
 arch/arm/mach-aspeed/ast2600/Kconfig |   7 +
 board/aspeed/ast2600_ibm/Kconfig     |  13 +
 board/aspeed/ast2600_ibm/Makefile    |   1 +
 board/aspeed/ast2600_ibm/ibm.c       |  46 +++
 configs/ast2600_ibm_defconfig        | 137 ++++++++
 drivers/i2c/ast_i2c.c                |   2 +-
 drivers/tpm/Kconfig                  |   9 +
 drivers/tpm/Makefile                 |   1 +
 drivers/tpm/tpm2_tis_core.c          | 470 +++++++++++++++++++++++++++
 drivers/tpm/tpm2_tis_i2c.c           | 171 ++++++++++
 drivers/tpm/tpm_tis.h                | 138 ++++++++
 include/tpm-v2.h                     |  32 ++
 13 files changed, 1033 insertions(+), 6 deletions(-)
 create mode 100644 board/aspeed/ast2600_ibm/Kconfig
 create mode 100644 board/aspeed/ast2600_ibm/Makefile
 create mode 100644 board/aspeed/ast2600_ibm/ibm.c
 create mode 100644 configs/ast2600_ibm_defconfig
 create mode 100644 drivers/tpm/tpm2_tis_core.c
 create mode 100644 drivers/tpm/tpm2_tis_i2c.c
Signature · 1 line
2.27.0
#1 lore raw

PATCH v2 1/9 tpm: Add more TPM2 definitions

From: Simon Glass <[email protected]>

Add definitions for access and status.

Need to drop the mixed case.

---
 include/tpm-v2.h | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
include/tpm-v2.h +31 -0
index ae00803f6d..d53d2e4023 100644
@@ -161,6 +161,37 @@ enum tpm_index_attrs {
 					TPMA_NV_AUTHWRITE | TPMA_NV_POLICYWRITE,
 };
 
+enum {
+	TPM_ACCESS_VALID		= 1 << 7,
+	TPM_ACCESS_ACTIVE_LOCALITY	= 1 << 5,
+	TPM_ACCESS_REQUEST_PENDING	= 1 << 2,
+	TPM_ACCESS_REQUEST_USE		= 1 << 1,
+	TPM_ACCESS_ESTABLISHMENT	= 1 << 0,
+};
+
+enum {
+	TPM_STS_FAMILY_SHIFT		= 26,
+	TPM_STS_FAMILY_MASK		= 0x3 << TPM_STS_FAMILY_SHIFT,
+	TPM_STS_FAMILY_TPM2		= 1 << TPM_STS_FAMILY_SHIFT,
+	TPM_STS_RESE_TESTABLISMENT_BIT	= 1 << 25,
+	TPM_STS_COMMAND_CANCEL		= 1 << 24,
+	TPM_STS_BURST_COUNT_SHIFT	= 8,
+	TPM_STS_BURST_COUNT_MASK	= 0xffff << TPM_STS_BURST_COUNT_SHIFT,
+	TPM_STS_VALID			= 1 << 7,
+	TPM_STS_COMMAND_READY		= 1 << 6,
+	TPM_STS_GO			= 1 << 5,
+	TPM_STS_DATA_AVAIL		= 1 << 4,
+	TPM_STS_DATA_EXPECT		= 1 << 3,
+	TPM_STS_SELF_TEST_DONE		= 1 << 2,
+	TPM_STS_RESPONSE_RETRY		= 1 << 1,
+};
+
+enum {
+	TPM_CMD_COUNT_OFFSET	= 2,
+	TPM_CMD_ORDINAL_OFFSET	= 6,
+	TPM_MAX_BUF_SIZE	= 1260,
+};
+
 /**
  * Issue a TPM2_Startup command.
  *
Signature · 1 line
2.27.0
#2 lore raw

PATCH v2 2/9 tpm: add #ifndef to fix redeclaration build errors

In reply to Eddie James

From: Johannes Holland <[email protected]>

tpm_tis_spi.c directly includes tpm_tis.h and tpm-v2.h which both define the same enums (see e.g. TPM_ACCESS_VALID). Add an #ifndef to prevent redeclaration errors.

---
 drivers/tpm/tpm_tis.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/tpm/tpm_tis.h +2 -0
index 947585f8e3..2a160fe05c 100644
@@ -104,6 +104,7 @@ struct tpm_cmd_t {
 /* Max number of iterations after i2c NAK */
 #define MAX_COUNT		3
 
+#ifndef __TPM_V2_H
 /*
  * Max number of iterations after i2c NAK for 'long' commands
  *
@@ -127,5 +128,6 @@ enum tis_status {
 	TPM_STS_DATA_AVAIL		= 0x10,
 	TPM_STS_DATA_EXPECT		= 0x08,
 };
+#endif
 
 #endif
Signature · 1 line
2.27.0
#3 lore raw

PATCH v2 3/9 tpm2: Introduce TIS tpm core

In reply to Eddie James

From: Ilias Apalodimas <[email protected]>

There's a lot of code duplication in U-Boot right now. All the TPM TIS compatible drivers we have at the moment have their own copy of a TIS implementation.

So let's create a common layer which implements the core TIS functions. Any driver added from now own, which is compatible with the TIS spec, will only have to provide the underlying bus communication mechanisms.

---
 drivers/tpm/tpm2_tis_core.c | 463 ++++++++++++++++++++++++++++++++++++
 drivers/tpm/tpm_tis.h       | 136 +++++++++++
 include/tpm-v2.h            |   1 +
 3 files changed, 600 insertions(+)
 create mode 100644 drivers/tpm/tpm2_tis_core.c
drivers/tpm/tpm2_tis_core.c new file +463 -0
new file mode 100644
index 0000000000..ec8c730fe9
@@ -0,0 +1,463 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2020, Linaro Limited
+ *
+ * Based on the Linux TIS core interface and U-Boot original SPI TPM driver
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <tpm-v2.h>
+#include <linux/delay.h>
+#include <linux/unaligned/be_byteshift.h>
+#include "tpm_tis.h"
+
+int tpm_tis_get_desc(struct udevice *dev, char *buf, int size)
+{
+	struct tpm_chip *chip = dev_get_priv(dev);
+
+	if (size < 80)
+		return -ENOSPC;
+
+	return snprintf(buf, size,
+			"%s v2.0: VendorID 0x%04x, DeviceID 0x%04x, RevisionID 0x%02x [%s]",
+			dev->name, chip->vend_dev & 0xFFFF,
+			chip->vend_dev >> 16, chip->rid,
+			(chip->is_open ? "open" : "closed"));
+}
+
+/**
+ * tpm_tis_check_locality - Check the current TPM locality
+ *
+ * @dev: TPM device
+ * @loc:  locality
+ *
+ * Return: True if the tested locality matches
+ */
+static bool tpm_tis_check_locality(struct udevice *dev, int loc)
+{
+	struct tpm_chip *chip = dev_get_priv(dev);
+	struct tpm_tis_phy_ops *phy_ops = chip->phy_ops;
+	u8 locality;
+
+	phy_ops->read_bytes(dev, TPM_ACCESS(loc), 1, &locality);
+	if ((locality & (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID |
+	    TPM_ACCESS_REQUEST_USE)) ==
+	    (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) {
+		chip->locality = loc;
+		return true;
+	}
+
+	return false;
+}
+
+/**
+ * tpm_tis_request_locality - Request a locality from the TPM
+ *
+ * @dev:  TPM device
+ * @loc:  requested locality
+ *
+ * Return: 0 on success -1 on failure
+ */
+int tpm_tis_request_locality(struct udevice *dev, int loc)
+{
+	struct tpm_chip *chip = dev_get_priv(dev);
+	struct tpm_tis_phy_ops *phy_ops = chip->phy_ops;
+	u8 buf = TPM_ACCESS_REQUEST_USE;
+	unsigned long start, stop;
+
+	if (tpm_tis_check_locality(dev, loc))
+		return 0;
+
+	phy_ops->write_bytes(dev, TPM_ACCESS(loc), 1, &buf);
+	start = get_timer(0);
+	stop = chip->timeout_a;
+	do {
+		if (tpm_tis_check_locality(dev, loc))
+			return 0;
+		mdelay(TPM_TIMEOUT_MS);
+	} while (get_timer(start) < stop);
+
+	return -1;
+}
+
+/**
+ * tpm_tis_status - Check the current device status
+ *
+ * @dev:   TPM device
+ * @status: return value of status
+ *
+ * Return: 0 on success, negative on failure
+ */
+static int tpm_tis_status(struct udevice *dev, u8 *status)
+{
+	struct tpm_chip *chip = dev_get_priv(dev);
+	struct tpm_tis_phy_ops *phy_ops = chip->phy_ops;
+
+	if (chip->locality < 0)
+		return -EINVAL;
+
+	phy_ops->read_bytes(dev, TPM_STS(chip->locality), 1, status);
+
+	if ((*status & TPM_STS_READ_ZERO)) {
+		log_err("TPM returned invalid status\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+/**
+ * tpm_tis_release_locality - Release the requested locality
+ *
+ * @dev: TPM device
+ * @loc:  requested locality
+ *
+ * Return: 0 on success, negative on failure
+ */
+int tpm_tis_release_locality(struct udevice *dev, int loc)
+{
+	struct tpm_chip *chip = dev_get_priv(dev);
+	struct tpm_tis_phy_ops *phy_ops = chip->phy_ops;
+	u8 buf = TPM_ACCESS_ACTIVE_LOCALITY;
+	int ret;
+
+	if (chip->locality < 0)
+		return 0;
+
+	ret = phy_ops->write_bytes(dev, TPM_ACCESS(loc), 1, &buf);
+	chip->locality = -1;
+
+	return ret;
+}
+
+/**
+ * tpm_tis_wait_for_stat - Wait for TPM to become ready
+ *
+ * @dev:     TPM device
+ * @mask:    mask to match
+ * @timeout: timeout for retries
+ * @status:  current status
+ *
+ * Return: 0 on success, negative on failure
+ */
+static int tpm_tis_wait_for_stat(struct udevice *dev, u8 mask,
+				 unsigned long timeout, u8 *status)
+{
+	unsigned long start = get_timer(0);
+	unsigned long stop = timeout;
+	int ret;
+
+	do {
+		mdelay(TPM_TIMEOUT_MS);
+		ret = tpm_tis_status(dev, status);
+		if (ret)
+			return ret;
+
+		if ((*status & mask) == mask)
+			return 0;
+	} while (get_timer(start) < stop);
+
+	return -ETIMEDOUT;
+}
+
+/**
+ * tpm_tis_get_burstcount - Get the burstcount for the data FIFO
+ *
+ * @dev:        TPM device
+ * @burstcount: current burstcount
+ *
+ * Return: 0 on success, negative on failure
+ */
+static int tpm_tis_get_burstcount(struct udevice *dev, size_t *burstcount)
+{
+	struct tpm_chip *chip = dev_get_priv(dev);
+	struct tpm_tis_phy_ops *phy_ops = chip->phy_ops;
+	unsigned long start, stop;
+	u32 burst;
+
+	if (chip->locality < 0)
+		return -EINVAL;
+
+	/* wait for burstcount */
+	start = get_timer(0);
+	/*
+	 * This is the TPMv2 defined timeout. Change this in case you want to
+	 * make the driver compatile to TPMv1
+	 */
+	stop = chip->timeout_a;
+	do {
+		phy_ops->read32(dev, TPM_STS(chip->locality), &burst);
+		*burstcount = (burst >> 8) & 0xFFFF;
+		if (*burstcount)
+			return 0;
+
+		mdelay(TPM_TIMEOUT_MS);
+	} while (get_timer(start) < stop);
+
+	return -ETIMEDOUT;
+}
+
+/**
+ * tpm_tis_ready - Cancel pending comands and get the device on a ready state
+ *
+ * @dev: TPM device
+ *
+ * Return: 0 on success, negative on failure
+ */
+static int tpm_tis_ready(struct udevice *dev)
+{
+	struct tpm_chip *chip = dev_get_priv(dev);
+	struct tpm_tis_phy_ops *phy_ops = chip->phy_ops;
+	u8 data = TPM_STS_COMMAND_READY;
+
+	/* This will cancel any pending commands */
+	return phy_ops->write_bytes(dev, TPM_STS(chip->locality), 1, &data);
+}
+
+int tpm_tis_send(struct udevice *dev, const u8 *buf, size_t len)
+{
+	struct tpm_chip *chip = dev_get_priv(dev);
+	struct tpm_tis_phy_ops *phy_ops = chip->phy_ops;
+	size_t burstcnt, wr_size, sent = 0;
+	u8 data = TPM_STS_GO;
+	u8 status;
+	int ret;
+
+	if (!chip)
+		return -ENODEV;
+
+	ret = tpm_tis_request_locality(dev, 0);
+	if (ret < 0)
+		return -EBUSY;
+
+	ret = tpm_tis_status(dev, &status);
+	if (ret)
+		goto release_locality;
+
+	if (!(status & TPM_STS_COMMAND_READY)) {
+		ret = tpm_tis_ready(dev);
+		if (ret) {
+			log_err("Can't cancel previous TPM operation\n");
+			goto release_locality;
+		}
+		ret = tpm_tis_wait_for_stat(dev, TPM_STS_COMMAND_READY,
+					    chip->timeout_b, &status);
+		if (ret) {
+			log_err("TPM not ready\n");
+			goto release_locality;
+		}
+	}
+
+	while (len > 0) {
+		ret = tpm_tis_get_burstcount(dev, &burstcnt);
+		if (ret)
+			goto release_locality;
+
+		wr_size = min(len, burstcnt);
+		ret = phy_ops->write_bytes(dev, TPM_DATA_FIFO(chip->locality),
+					   wr_size, buf + sent);
+		if (ret < 0)
+			goto release_locality;
+
+		ret = tpm_tis_wait_for_stat(dev, TPM_STS_VALID,
+					    chip->timeout_c, &status);
+		if (ret)
+			goto release_locality;
+
+		sent += wr_size;
+		len -= wr_size;
+		/* make sure the TPM expects more data */
+		if (len && !(status & TPM_STS_DATA_EXPECT)) {
+			ret = -EIO;
+			goto release_locality;
+		}
+	}
+
+	/*
+	 * Make a final check ensuring everything is ok and the TPM expects no
+	 * more data
+	 */
+	ret = tpm_tis_wait_for_stat(dev, TPM_STS_VALID, chip->timeout_c,
+				    &status);
+	if (ret)
+		goto release_locality;
+
+	if (status & TPM_STS_DATA_EXPECT) {
+		ret = -EIO;
+		goto release_locality;
+	}
+
+	ret = phy_ops->write_bytes(dev, TPM_STS(chip->locality), 1, &data);
+	if (ret)
+		goto release_locality;
+
+	return sent;
+
+release_locality:
+	tpm_tis_ready(dev);
+	tpm_tis_release_locality(dev, chip->locality);
+
+	return ret;
+}
+
+static int tpm_tis_recv_data(struct udevice *dev, u8 *buf, size_t count)
+{
+	struct tpm_chip *chip = dev_get_priv(dev);
+	struct tpm_tis_phy_ops *phy_ops = chip->phy_ops;
+	int size = 0, len, ret;
+	size_t burstcnt;
+	u8 status;
+
+	while (size < count &&
+	       tpm_tis_wait_for_stat(dev, TPM_STS_DATA_AVAIL | TPM_STS_VALID,
+				     chip->timeout_c, &status) == 0) {
+		ret = tpm_tis_get_burstcount(dev, &burstcnt);
+		if (ret)
+			return ret;
+
+		len = min_t(int, burstcnt, count - size);
+		ret = phy_ops->read_bytes(dev, TPM_DATA_FIFO(chip->locality),
+					  len, buf + size);
+		if (ret < 0)
+			return ret;
+
+		size += len;
+	}
+
+	return size;
+}
+
+/**
+ * tpm_tis_recv - Receive data from a device
+ *
+ * @dev:  TPM device
+ * @buf:  buffer to copy data
+ * @size: buffer size
+ *
+ * Return: bytes read or negative on failure
+ */
+int tpm_tis_recv(struct udevice *dev, u8 *buf, size_t count)
+{
+	struct tpm_chip *chip = dev_get_priv(dev);
+	int size, expected;
+
+	if (count < TPM_HEADER_SIZE)
+		return -E2BIG;
+
+	size = tpm_tis_recv_data(dev, buf, TPM_HEADER_SIZE);
+	if (size < TPM_HEADER_SIZE) {
+		log_err("TPM error, unable to read header\n");
+		goto out;
+	}
+
+	expected = get_unaligned_be32(buf + TPM_CMD_COUNT_OFFSET);
+	if (expected > count) {
+		size = -EIO;
+		log_warning("Too much data: %d > %zu\n", expected, count);
+		goto out;
+	}
+
+	size += tpm_tis_recv_data(dev, &buf[TPM_HEADER_SIZE],
+				   expected - TPM_HEADER_SIZE);
+	if (size < expected) {
+		log(LOGC_NONE, LOGL_ERR,
+		    "TPM error, unable to read remaining bytes of result\n");
+		size = -EIO;
+		goto out;
+	}
+
+out:
+	tpm_tis_ready(dev);
+	/* acquired in tpm_tis_send */
+	tpm_tis_release_locality(dev, chip->locality);
+
+	return size;
+}
+
+int tpm_tis_cleanup(struct udevice *dev)
+{
+	struct tpm_chip *chip = dev_get_priv(dev);
+
+	tpm_tis_ready(dev);
+	tpm_tis_release_locality(dev, chip->locality);
+
+	return 0;
+}
+
+int tpm_tis_open(struct udevice *dev)
+{
+	struct tpm_chip *chip = dev_get_priv(dev);
+	int ret;
+
+	if (chip->is_open)
+		return -EBUSY;
+
+	ret = tpm_tis_request_locality(dev, 0);
+	if (!ret)
+		chip->is_open = 1;
+
+	return ret;
+}
+
+void tpm_tis_ops_register(struct udevice *dev, struct tpm_tis_phy_ops *ops)
+{
+	struct tpm_chip *chip = dev_get_priv(dev);
+
+	chip->phy_ops = ops;
+}
+
+static bool tis_check_ops(struct tpm_tis_phy_ops *phy_ops)
+{
+	if (!phy_ops || !phy_ops->read_bytes || !phy_ops->write_bytes ||
+	    !phy_ops->read32 || !phy_ops->write32)
+		return false;
+
+	return true;
+}
+
+int tpm_tis_init(struct udevice *dev)
+{
+	struct tpm_chip *chip = dev_get_priv(dev);
+	struct tpm_tis_phy_ops *phy_ops = chip->phy_ops;
+	int ret;
+	u32 tmp;
+
+	if (!tis_check_ops(phy_ops)) {
+		log_err("Driver bug. No bus ops defined\n");
+		return -1;
+	}
+	ret = tpm_tis_request_locality(dev, 0);
+	if (ret)
+		return ret;
+
+	chip->timeout_a = TIS_SHORT_TIMEOUT_MS;
+	chip->timeout_b = TIS_LONG_TIMEOUT_MS;
+	chip->timeout_c = TIS_SHORT_TIMEOUT_MS;
+	chip->timeout_d = TIS_SHORT_TIMEOUT_MS;
+
+	/* Disable interrupts */
+	phy_ops->read32(dev, TPM_INT_ENABLE(chip->locality), &tmp);
+	tmp |= TPM_INTF_CMD_READY_INT | TPM_INTF_LOCALITY_CHANGE_INT |
+	       TPM_INTF_DATA_AVAIL_INT | TPM_INTF_STS_VALID_INT;
+	tmp &= ~TPM_GLOBAL_INT_ENABLE;
+	phy_ops->write32(dev, TPM_INT_ENABLE(chip->locality), tmp);
+
+	phy_ops->read_bytes(dev, TPM_RID(chip->locality), 1, &chip->rid);
+	phy_ops->read32(dev, TPM_DID_VID(chip->locality), &chip->vend_dev);
+
+	return tpm_tis_release_locality(dev, chip->locality);
+}
+
+int tpm_tis_close(struct udevice *dev)
+{
+	struct tpm_chip *chip = dev_get_priv(dev);
+	int ret = 0;
+
+	if (chip->is_open) {
+		ret = tpm_tis_release_locality(dev, chip->locality);
+		chip->is_open = 0;
+	}
+
+	return ret;
+}
drivers/tpm/tpm_tis.h +136 -0

152 lines not on this page · raw message

include/tpm-v2.h +1 -0
index d53d2e4023..b65f2ce55a 100644
@@ -184,6 +184,7 @@ enum {
 	TPM_STS_DATA_EXPECT		= 1 << 3,
 	TPM_STS_SELF_TEST_DONE		= 1 << 2,
 	TPM_STS_RESPONSE_RETRY		= 1 << 1,
+	TPM_STS_READ_ZERO               = 0x23
 };
 
 enum {
Signature · 1 line
2.27.0
#4 lore raw

PATCH v2 4/9 tis: fix tpm_tis_remove()

In reply to Eddie James

From: Heinrich Schuchardt <[email protected]>

tpm_tis_remove() leads to calling tpm_tis_ready() with the IO region unmapped and chip->locality == -1 (locality released). This leads to a crash in mmio_write_bytes().

The patch implements these changes:

tpm_tis_remove(): Unmap the IO region after calling tpm_tis_cleanup().

tpm_tis_cleanup(): Request locality before IO output and releasing locality.

---
 drivers/tpm/tpm2_tis_core.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/tpm/tpm2_tis_core.c +6 -0
index ec8c730fe9..51392c4584 100644
@@ -378,8 +378,14 @@ out:
 int tpm_tis_cleanup(struct udevice *dev)
 {
 	struct tpm_chip *chip = dev_get_priv(dev);
+	int ret;
+
+	ret = tpm_tis_request_locality(dev, 0);
+	if (ret)
+		return ret;
 
 	tpm_tis_ready(dev);
+
 	tpm_tis_release_locality(dev, chip->locality);
 
 	return 0;
Signature · 1 line
2.27.0
#5 lore raw

PATCH v2 5/9 tpm: core: Set timeouts before requesting locality

In reply to Eddie James

Requesting the locality uses the timeout values, so they need to be set beforehand.

---
 drivers/tpm/tpm2_tis_core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/tpm/tpm2_tis_core.c +4 -3
index 51392c4584..985a816219 100644
@@ -433,15 +433,16 @@ int tpm_tis_init(struct udevice *dev)
 		log_err("Driver bug. No bus ops defined\n");
 		return -1;
 	}
-	ret = tpm_tis_request_locality(dev, 0);
-	if (ret)
-		return ret;
 
 	chip->timeout_a = TIS_SHORT_TIMEOUT_MS;
 	chip->timeout_b = TIS_LONG_TIMEOUT_MS;
 	chip->timeout_c = TIS_SHORT_TIMEOUT_MS;
 	chip->timeout_d = TIS_SHORT_TIMEOUT_MS;
 
+	ret = tpm_tis_request_locality(dev, 0);
+	if (ret)
+		return ret;
+
 	/* Disable interrupts */
 	phy_ops->read32(dev, TPM_INT_ENABLE(chip->locality), &tmp);
 	tmp |= TPM_INTF_CMD_READY_INT | TPM_INTF_LOCALITY_CHANGE_INT |
Signature · 1 line
2.27.0
#6 lore raw

PATCH v2 6/9 i2c: ast_i2c: Remove SCL direct drive mode

In reply to Eddie James

SCL direct drive mode prevents communication with devices that do clock stretching, so disable. The Linux driver doesn't use this mode, and the engine can handle clock stretching.

---
 drivers/i2c/ast_i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/ast_i2c.c +1 -1
index bbc32d6cdb..13420ade84 100644
@@ -73,7 +73,7 @@ static void ast_i2c_init_bus(struct udevice *dev)
 	/* Enable Master Mode. Assuming single-master */
 	writel(I2CD_MASTER_EN
 	       | I2CD_M_SDA_LOCK_EN
-	       | I2CD_MULTI_MASTER_DIS | I2CD_M_SCL_DRIVE_EN,
+	       | I2CD_MULTI_MASTER_DIS,
 	       &priv->regs->fcr);
 	/* Enable Interrupts */
 	writel(I2CD_INTR_TX_ACK
Signature · 1 line
2.27.0
#7 lore raw

PATCH v2 7/9 tpm: add support for TPMv2.x I2C chips

In reply to Eddie James

Add the tpm2_tis_i2c driver that should support any TPMv2 compliant I2C chips, such as the NPCT75X chip.

---
 drivers/tpm/Kconfig        |   9 ++
 drivers/tpm/Makefile       |   1 +
 drivers/tpm/tpm2_tis_i2c.c | 171 +++++++++++++++++++++++++++++++++++++
 3 files changed, 181 insertions(+)
 create mode 100644 drivers/tpm/tpm2_tis_i2c.c
drivers/tpm/Kconfig +9 -0
index 94629dffd2..6fd98ac057 100644
@@ -145,6 +145,15 @@ config TPM2_TIS_SPI
 	  to the device using the standard TPM Interface Specification (TIS)
 	  protocol.
 
+config TPM2_TIS_I2C
+	bool "Enable support for TPMv2.x I2C chips"
+	depends on TPM_V2 && DM_I2C
+	help
+	  This driver supports TPMv2.x devices connected on the I2C bus.
+	  The usual TPM operations and the 'tpm' command can be used to talk
+	  to the device using the standard TPM Interface Specification (TIS)
+	  protocol.
+
 endif # TPM_V2
 
 endmenu
drivers/tpm/Makefile +1 -0
index 94c337b8ed..33bc0784f6 100644
@@ -12,3 +12,4 @@ obj-$(CONFIG_TPM_ST33ZP24_SPI) += tpm_tis_st33zp24_spi.o
 
 obj-$(CONFIG_TPM2_TIS_SANDBOX) += tpm2_tis_sandbox.o
 obj-$(CONFIG_TPM2_TIS_SPI) += tpm2_tis_spi.o
+obj-$(CONFIG_TPM2_TIS_I2C) += tpm2_tis_core.o tpm2_tis_i2c.o
drivers/tpm/tpm2_tis_i2c.c new file +171 -0

171 lines not on this page · raw message

Signature · 1 line
2.27.0
#8 lore raw

PATCH v2 8/9 arm: dts: ast2600-rainier: Add NPCT75X TPM

In reply to Eddie James

Add the TPM device on I2C bus 12.

---
 arch/arm/dts/ast2600-rainier.dts | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
arch/arm/dts/ast2600-rainier.dts +7 -5
index 8a44fd8a0a..aa91b12ed3 100755
@@ -106,12 +106,14 @@
 
 &gpio0 {
 	u-boot,dm-pre-reloc;
+};
+
+&i2c12 {
+	status = "okay";
 
-	tpm_reset {
-		u-boot,dm-pre-reloc;
-		gpio-hog;
-		output-high;
-		gpios = <ASPEED_GPIO(R, 0) GPIO_ACTIVE_HIGH>;
+	tpm@2e {
+		compatible = "nuvoton,npct75x";
+		reg = <0x2e>;
 	};
 };
 
Signature · 1 line
2.27.0
#9 lore raw

PATCH v2 9/9 board: ast2600-ibm: Add AST2600 BMC based POWER10+ servers

In reply to Eddie James

Support IBM-specific options for POWER10+ servers built on AST2600 BMC.

---
 arch/arm/mach-aspeed/ast2600/Kconfig |   7 ++
 board/aspeed/ast2600_ibm/Kconfig     |  13 +++
 board/aspeed/ast2600_ibm/Makefile    |   1 +
 board/aspeed/ast2600_ibm/ibm.c       |  46 +++++++++
 configs/ast2600_ibm_defconfig        | 137 +++++++++++++++++++++++++++
 5 files changed, 204 insertions(+)
 create mode 100644 board/aspeed/ast2600_ibm/Kconfig
 create mode 100644 board/aspeed/ast2600_ibm/Makefile
 create mode 100644 board/aspeed/ast2600_ibm/ibm.c
 create mode 100644 configs/ast2600_ibm_defconfig
arch/arm/mach-aspeed/ast2600/Kconfig +7 -0
index fcdc425de5..412ea639ad 100644
@@ -31,6 +31,12 @@ config TARGET_SLT_AST2600
 	help
 	  SLT-AST2600 is Aspeed SLT board for AST2600 chip.
 
+config TARGET_AST2600_IBM
+	bool "AST2600-IBM"
+	depends on ASPEED_AST2600
+	help
+	  AST2600-IBM is IBM boards for AST2600 BMC based P0WER10+ servers
+
 config TARGET_AST2600_INTEL
 	bool "AST2600-INTEL"
 	depends on ASPEED_AST2600
@@ -43,6 +49,7 @@ endchoice
 source "board/aspeed/evb_ast2600/Kconfig"
 source "board/aspeed/fpga_ast2600/Kconfig"
 source "board/aspeed/slt_ast2600/Kconfig"
+source "board/aspeed/ast2600_ibm/Kconfig"
 source "board/aspeed/ast2600_intel/Kconfig"
 
 endif
board/aspeed/ast2600_ibm/Kconfig new file +13 -0
new file mode 100644
index 0000000000..38ee579ed7
@@ -0,0 +1,13 @@
+if TARGET_AST2600_IBM
+
+config SYS_BOARD
+	default "ast2600_ibm"
+
+config SYS_VENDOR
+	default "aspeed"
+
+config SYS_CONFIG_NAME
+	string "board configuration name"
+	default "ast2600_ibm"
+
+endif
board/aspeed/ast2600_ibm/Makefile new file +1 -0
new file mode 100644
index 0000000000..ae1aded893
@@ -0,0 +1 @@
+obj-y += ibm.o
board/aspeed/ast2600_ibm/ibm.c new file +46 -0

46 lines not on this page · raw message

configs/ast2600_ibm_defconfig new file +137 -0

137 lines not on this page · raw message

Signature · 1 line
2.27.0
maintainer
#10 lore raw

Re: [PATCH u-boot v2019.04-aspeed-openbmc v2 9/9] board: ast2600-ibm: Add AST2600 BMC based POWER10+ servers

Quoted 3 lines · Eddie James

Support IBM-specific options for POWER10+ servers built on AST2600 BMC.

Enabling the TPM command and the TPM2_TIS_I2C option adds 32.6KB to the u-boot image, bringing the total to 406KB.

Quoted 13 lines
---
 arch/arm/mach-aspeed/ast2600/Kconfig |   7 ++
 board/aspeed/ast2600_ibm/Kconfig     |  13 +++
 board/aspeed/ast2600_ibm/Makefile    |   1 +
 board/aspeed/ast2600_ibm/ibm.c       |  46 +++++++++
 configs/ast2600_ibm_defconfig        | 137 +++++++++++++++++++++++++++
 5 files changed, 204 insertions(+)
 create mode 100644 board/aspeed/ast2600_ibm/Kconfig
 create mode 100644 board/aspeed/ast2600_ibm/Makefile
 create mode 100644 board/aspeed/ast2600_ibm/ibm.c
 create mode 100644 configs/ast2600_ibm_defconfig

I don't want to end up with defconfigs for every machine we support. Is there a way we can avoid that?

Quoted 58 lines
arch/arm/mach-aspeed/ast2600/Kconfig +7 -0
index fcdc425de5..412ea639ad 100644
@@ -31,6 +31,12 @@ config TARGET_SLT_AST2600
        help
          SLT-AST2600 is Aspeed SLT board for AST2600 chip.
 
+config TARGET_AST2600_IBM
+       bool "AST2600-IBM"
+       depends on ASPEED_AST2600
+       help
+         AST2600-IBM is IBM boards for AST2600 BMC based P0WER10+ servers
+
 config TARGET_AST2600_INTEL
        bool "AST2600-INTEL"
        depends on ASPEED_AST2600
@@ -43,6 +49,7 @@ endchoice
 source "board/aspeed/evb_ast2600/Kconfig"
 source "board/aspeed/fpga_ast2600/Kconfig"
 source "board/aspeed/slt_ast2600/Kconfig"
+source "board/aspeed/ast2600_ibm/Kconfig"
 source "board/aspeed/ast2600_intel/Kconfig"
 
 endif
board/aspeed/ast2600_ibm/Kconfig new file +13 -0
new file mode 100644
index 0000000000..38ee579ed7
@@ -0,0 +1,13 @@
+if TARGET_AST2600_IBM
+
+config SYS_BOARD
+       default "ast2600_ibm"
+
+config SYS_VENDOR
+       default "aspeed"
+
+config SYS_CONFIG_NAME
+       string "board configuration name"
+       default "ast2600_ibm"
+
+endif
board/aspeed/ast2600_ibm/Makefile new file +1 -0
new file mode 100644
index 0000000000..ae1aded893
@@ -0,0 +1 @@
+obj-y += ibm.o
board/aspeed/ast2600_ibm/ibm.c new file +0 -0
new file mode 100644
index 0000000000..d9e06fafe0

board/aspeed/ast2600_ibm/ibm.c line 7

Quoted 7 lines
board/aspeed/ast2600_ibm/ibm.c new file +7 -0
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2022 IBM Corp.
+ */
+
+#include <common.h>
+#if defined(CONFIG_TPM_V2)

The headers will always exist, so this is unnecessary.

Even better, we know this machine will always have a TPM, so can we select it in

Quoted 5 lines
board/aspeed/ast2600_ibm/ibm.c new file +5 -0
+#include <dm/uclass.h>
+#include <tpm-common.h>
+#include <tpm-v2.h>
+#endif
+

board/aspeed/ast2600_ibm/ibm.c line 22

Quoted 10 lines
board/aspeed/ast2600_ibm/ibm.c new file +10 -0
+__weak int board_late_init(void)
+{
+#if defined(CONFIG_TPM_V2)
+       int rc;
+       struct udevice *dev;
+       /*
+        * The digest is just an arbitrary sequence for now to ensure that the
+        * TPM gets "poisoned."
+        */
+       unsigned char digest[32] = {

const

Quoted 170 lines
board/aspeed/ast2600_ibm/ibm.c new file +24 -0
+               0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, 0x01,
+               0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
+               0xa0, 0xb1, 0xc2, 0xd3, 0xe4, 0xf5, 0x06, 0x17,
+               0x28, 0x39, 0x4a, 0x5b, 0x6c, 0x7d, 0x8e, 0x9f
+       };
+
+       rc = uclass_first_device_err(UCLASS_TPM, &dev);
+       if (rc)
+               return 0;
+
+       rc = tpm_init(dev);
+       if (rc)
+               return 0;
+
+       rc = tpm2_startup(dev, TPM2_SU_CLEAR);
+       if (rc)
+               return 0;
+
+       rc = tpm2_pcr_extend(dev, 0, digest);
+       if (!rc)
+               printf("TPM: PCR0 extended.\n");
+#endif
+       return 0;
+}
configs/ast2600_ibm_defconfig new file +137 -1
new file mode 100644
index 0000000000..3fe85bc57a
@@ -0,0 +1,137 @@
+CONFIG_ARM=y
+CONFIG_SYS_CONFIG_NAME="evb_ast2600_spl_emmc"
+CONFIG_SYS_DCACHE_OFF=y
+CONFIG_POSITION_INDEPENDENT=y
+CONFIG_SYS_THUMB_BUILD=y
+# CONFIG_SPL_USE_ARCH_MEMCPY is not set
+# CONFIG_SPL_USE_ARCH_MEMSET is not set
+CONFIG_SPL_LDSCRIPT="arch/$(ARCH)/mach-aspeed/ast2600/u-boot-spl.lds"
+CONFIG_ARCH_ASPEED=y
+CONFIG_SYS_TEXT_BASE=0x81000000
+CONFIG_ASPEED_AST2600=y
+# CONFIG_ASPEED_LOADERS is not set
+CONFIG_TARGET_AST2600_IBM=y
+CONFIG_DEFAULT_DEVICE_TREE="ast2600-rainier"
+CONFIG_SPL_GPIO_SUPPORT=y
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_SPL_SERIAL_SUPPORT=y
+CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
+CONFIG_ENV_SIZE=0x10000
+CONFIG_ENV_OFFSET=0x5000
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x1000
+CONFIG_SPL=y
+CONFIG_SPL_STACK_R_ADDR=0x90300000
+CONFIG_ARMV7_BOOT_SEC_DEFAULT=y
+CONFIG_ARMV7_PSCI_NR_CPUS=2
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_FIT=y
+CONFIG_FIT_ENABLE_SHA512_SUPPORT=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_SPL_FIT_SIGNATURE=y
+CONFIG_SPL_LOAD_FIT=y
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="console=ttyS4,115200n8 root=/dev/ram rw"
+CONFIG_USE_BOOTCOMMAND=y
+CONFIG_BOOTCOMMAND="bootm 20100000"
+CONFIG_SYS_CONSOLE_ENV_OVERWRITE=y
+CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_ARCH_EARLY_INIT_R=y
+CONFIG_BOARD_LATE_INIT=y
+CONFIG_SPL_BOARD_INIT=y
+# CONFIG_SPL_LEGACY_IMAGE_SUPPORT is not set
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPL_STACK_R=y
+CONFIG_SPL_SEPARATE_BSS=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x80
+CONFIG_SPL_SHA512_SUPPORT=y
+CONFIG_SPL_FIT_IMAGE_TINY=y
+CONFIG_SPL_DM_RESET=y
+CONFIG_SPL_RAM_SUPPORT=y
+CONFIG_SPL_RAM_DEVICE=y
+CONFIG_SPL_WATCHDOG_SUPPORT=y
+CONFIG_SPL_YMODEM_SUPPORT=y
+CONFIG_HUSH_PARSER=y
+# CONFIG_AUTO_COMPLETE is not set
+CONFIG_SYS_PROMPT="ast# "
+CONFIG_CMD_BOOTZ=y
+# CONFIG_CMD_ELF is not set
+# CONFIG_CMD_IMI is not set
+# CONFIG_CMD_XIMG is not set
+CONFIG_CMD_MEMTEST=y
+CONFIG_SYS_ALT_MEMTEST=y
+CONFIG_CMD_CLK=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_GPT=y
+# CONFIG_RANDOM_UUID is not set
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PART=y
+CONFIG_CMD_SF=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_NCSI=y
+CONFIG_CMD_EXT2=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_EXT4_WRITE=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_CMD_MTDPARTS=y
+# CONFIG_SPL_DOS_PARTITION is not set
+# CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_SPL_OF_CONTROL=y
+CONFIG_ENV_IS_IN_MMC=y
+CONFIG_USE_DEFAULT_ENV_FILE=y
+CONFIG_DEFAULT_ENV_FILE="board/aspeed/ast2600_openbmc_mmc.txt"
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SPL_DM=y
+CONFIG_REGMAP=y
+CONFIG_SYSCON=y
+CONFIG_SPL_OF_TRANSLATE=y
+CONFIG_CLK=y
+CONFIG_SPL_CLK=y
+CONFIG_ASPEED_HACE_V1=y
+CONFIG_DM_GPIO=y
+CONFIG_SPL_GPIO_HOG=y
+CONFIG_ASPEED_GPIO=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_ASPEED=y
+CONFIG_MISC=y
+CONFIG_ASPEED_AHBC=y
+CONFIG_DM_MMC=y
+CONFIG_SPL_MMC_TINY=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_ASPEED=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_GIGADEVICE=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_PHY_BROADCOM=y
+CONFIG_PHY_REALTEK=y
+CONFIG_PHY_NCSI=y
+CONFIG_DM_ETH=y
+CONFIG_PHY_GIGE=y
+CONFIG_FTGMAC100=y
+CONFIG_MDIO=y
+CONFIG_PHY=y
+CONFIG_PINCTRL=y
+CONFIG_RAM=y
+CONFIG_SPL_RAM=y
+CONFIG_DM_SERIAL=y
+CONFIG_SYS_NS16550=y
+CONFIG_SPI=y
+CONFIG_DM_SPI=y
+CONFIG_SYSRESET=y
+CONFIG_WDT=y
+CONFIG_USE_TINY_PRINTF=y
+CONFIG_SPL_TINY_MEMSET=y
+CONFIG_TPM=y
+CONFIG_TPM2_TIS_I2C=y
+# CONFIG_EFI_LOADER is not set
--

2.27.0

#11 lore raw

Re: [PATCH u-boot v2019.04-aspeed-openbmc v2 9/9] board: ast2600-ibm: Add AST2600 BMC based POWER10+ servers

Quoted 19 lines · Joel Stanley
Quoted 2 lines · Eddie James

Support IBM-specific options for POWER10+ servers built on AST2600 BMC.

Enabling the TPM command and the TPM2_TIS_I2C option adds 32.6KB to the u-boot image, bringing the total to 406KB.

Quoted 8 lines
---
  arch/arm/mach-aspeed/ast2600/Kconfig |   7 ++
  board/aspeed/ast2600_ibm/Kconfig     |  13 +++
  board/aspeed/ast2600_ibm/Makefile    |   1 +
  board/aspeed/ast2600_ibm/ibm.c       |  46 +++++++++
  configs/ast2600_ibm_defconfig        | 137 +++++++++++++++++++++++++++
  5 files changed, 204 insertions(+)
Quoted 4 lines

create mode 100644 board/aspeed/ast2600_ibm/Kconfig create mode 100644 board/aspeed/ast2600_ibm/Makefile create mode 100644 board/aspeed/ast2600_ibm/ibm.c create mode 100644 configs/ast2600_ibm_defconfig

Quoted 2 lines

I don't want to end up with defconfigs for every machine we support. Is there a way we can avoid that?

I'm not sure how we could, unless we just select this board for openbmc defconfig, but that somewhat defeats the purpose of adding the new board. May as well just add the tpm poison to the EVB board code.

Quoted 67 lines
Quoted 58 lines
arch/arm/mach-aspeed/ast2600/Kconfig +7 -0
index fcdc425de5..412ea639ad 100644
@@ -31,6 +31,12 @@ config TARGET_SLT_AST2600
         help
           SLT-AST2600 is Aspeed SLT board for AST2600 chip.
 
+config TARGET_AST2600_IBM
+       bool "AST2600-IBM"
+       depends on ASPEED_AST2600
+       help
+         AST2600-IBM is IBM boards for AST2600 BMC based P0WER10+ servers
+
  config TARGET_AST2600_INTEL
         bool "AST2600-INTEL"
         depends on ASPEED_AST2600
@@ -43,6 +49,7 @@ endchoice
  source "board/aspeed/evb_ast2600/Kconfig"
  source "board/aspeed/fpga_ast2600/Kconfig"
  source "board/aspeed/slt_ast2600/Kconfig"
+source "board/aspeed/ast2600_ibm/Kconfig"
  source "board/aspeed/ast2600_intel/Kconfig"
 
  endif
board/aspeed/ast2600_ibm/Kconfig new file +13 -0
new file mode 100644
index 0000000000..38ee579ed7
@@ -0,0 +1,13 @@
+if TARGET_AST2600_IBM
+
+config SYS_BOARD
+       default "ast2600_ibm"
+
+config SYS_VENDOR
+       default "aspeed"
+
+config SYS_CONFIG_NAME
+       string "board configuration name"
+       default "ast2600_ibm"
+
+endif
board/aspeed/ast2600_ibm/Makefile new file +1 -0
new file mode 100644
index 0000000000..ae1aded893
@@ -0,0 +1 @@
+obj-y += ibm.o
board/aspeed/ast2600_ibm/ibm.c new file +0 -0
new file mode 100644
index 0000000000..d9e06fafe0

board/aspeed/ast2600_ibm/ibm.c line 7

Quoted 7 lines
board/aspeed/ast2600_ibm/ibm.c new file +7 -0
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2022 IBM Corp.
+ */
+
+#include <common.h>
+#if defined(CONFIG_TPM_V2)

The headers will always exist, so this is unnecessary.

Quoted 1 line

Even better, we know this machine will always have a TPM, so can we select it in

Good idea.

Quoted 17 lines
Quoted 6 lines
board/aspeed/ast2600_ibm/ibm.c new file +5 -0
+#include <dm/uclass.h>
+#include <tpm-common.h>
+#include <tpm-v2.h>
+#endif
+

board/aspeed/ast2600_ibm/ibm.c line 22

Quoted 10 lines
board/aspeed/ast2600_ibm/ibm.c new file +10 -0
+__weak int board_late_init(void)
+{
+#if defined(CONFIG_TPM_V2)
+       int rc;
+       struct udevice *dev;
+       /*
+        * The digest is just an arbitrary sequence for now to ensure that the
+        * TPM gets "poisoned."
+        */
+       unsigned char digest[32] = {

const

Ack.

Quoted 171 lines
Quoted 171 lines
board/aspeed/ast2600_ibm/ibm.c new file +24 -0
+               0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, 0x01,
+               0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
+               0xa0, 0xb1, 0xc2, 0xd3, 0xe4, 0xf5, 0x06, 0x17,
+               0x28, 0x39, 0x4a, 0x5b, 0x6c, 0x7d, 0x8e, 0x9f
+       };
+
+       rc = uclass_first_device_err(UCLASS_TPM, &dev);
+       if (rc)
+               return 0;
+
+       rc = tpm_init(dev);
+       if (rc)
+               return 0;
+
+       rc = tpm2_startup(dev, TPM2_SU_CLEAR);
+       if (rc)
+               return 0;
+
+       rc = tpm2_pcr_extend(dev, 0, digest);
+       if (!rc)
+               printf("TPM: PCR0 extended.\n");
+#endif
+       return 0;
+}
configs/ast2600_ibm_defconfig new file +137 -1
new file mode 100644
index 0000000000..3fe85bc57a
@@ -0,0 +1,137 @@
+CONFIG_ARM=y
+CONFIG_SYS_CONFIG_NAME="evb_ast2600_spl_emmc"
+CONFIG_SYS_DCACHE_OFF=y
+CONFIG_POSITION_INDEPENDENT=y
+CONFIG_SYS_THUMB_BUILD=y
+# CONFIG_SPL_USE_ARCH_MEMCPY is not set
+# CONFIG_SPL_USE_ARCH_MEMSET is not set
+CONFIG_SPL_LDSCRIPT="arch/$(ARCH)/mach-aspeed/ast2600/u-boot-spl.lds"
+CONFIG_ARCH_ASPEED=y
+CONFIG_SYS_TEXT_BASE=0x81000000
+CONFIG_ASPEED_AST2600=y
+# CONFIG_ASPEED_LOADERS is not set
+CONFIG_TARGET_AST2600_IBM=y
+CONFIG_DEFAULT_DEVICE_TREE="ast2600-rainier"
+CONFIG_SPL_GPIO_SUPPORT=y
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_SPL_SERIAL_SUPPORT=y
+CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
+CONFIG_ENV_SIZE=0x10000
+CONFIG_ENV_OFFSET=0x5000
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x1000
+CONFIG_SPL=y
+CONFIG_SPL_STACK_R_ADDR=0x90300000
+CONFIG_ARMV7_BOOT_SEC_DEFAULT=y
+CONFIG_ARMV7_PSCI_NR_CPUS=2
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_FIT=y
+CONFIG_FIT_ENABLE_SHA512_SUPPORT=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_SPL_FIT_SIGNATURE=y
+CONFIG_SPL_LOAD_FIT=y
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="console=ttyS4,115200n8 root=/dev/ram rw"
+CONFIG_USE_BOOTCOMMAND=y
+CONFIG_BOOTCOMMAND="bootm 20100000"
+CONFIG_SYS_CONSOLE_ENV_OVERWRITE=y
+CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_ARCH_EARLY_INIT_R=y
+CONFIG_BOARD_LATE_INIT=y
+CONFIG_SPL_BOARD_INIT=y
+# CONFIG_SPL_LEGACY_IMAGE_SUPPORT is not set
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPL_STACK_R=y
+CONFIG_SPL_SEPARATE_BSS=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x80
+CONFIG_SPL_SHA512_SUPPORT=y
+CONFIG_SPL_FIT_IMAGE_TINY=y
+CONFIG_SPL_DM_RESET=y
+CONFIG_SPL_RAM_SUPPORT=y
+CONFIG_SPL_RAM_DEVICE=y
+CONFIG_SPL_WATCHDOG_SUPPORT=y
+CONFIG_SPL_YMODEM_SUPPORT=y
+CONFIG_HUSH_PARSER=y
+# CONFIG_AUTO_COMPLETE is not set
+CONFIG_SYS_PROMPT="ast# "
+CONFIG_CMD_BOOTZ=y
+# CONFIG_CMD_ELF is not set
+# CONFIG_CMD_IMI is not set
+# CONFIG_CMD_XIMG is not set
+CONFIG_CMD_MEMTEST=y
+CONFIG_SYS_ALT_MEMTEST=y
+CONFIG_CMD_CLK=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_GPT=y
+# CONFIG_RANDOM_UUID is not set
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PART=y
+CONFIG_CMD_SF=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_NCSI=y
+CONFIG_CMD_EXT2=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_EXT4_WRITE=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_CMD_MTDPARTS=y
+# CONFIG_SPL_DOS_PARTITION is not set
+# CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_SPL_OF_CONTROL=y
+CONFIG_ENV_IS_IN_MMC=y
+CONFIG_USE_DEFAULT_ENV_FILE=y
+CONFIG_DEFAULT_ENV_FILE="board/aspeed/ast2600_openbmc_mmc.txt"
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SPL_DM=y
+CONFIG_REGMAP=y
+CONFIG_SYSCON=y
+CONFIG_SPL_OF_TRANSLATE=y
+CONFIG_CLK=y
+CONFIG_SPL_CLK=y
+CONFIG_ASPEED_HACE_V1=y
+CONFIG_DM_GPIO=y
+CONFIG_SPL_GPIO_HOG=y
+CONFIG_ASPEED_GPIO=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_ASPEED=y
+CONFIG_MISC=y
+CONFIG_ASPEED_AHBC=y
+CONFIG_DM_MMC=y
+CONFIG_SPL_MMC_TINY=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_ASPEED=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_GIGADEVICE=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_PHY_BROADCOM=y
+CONFIG_PHY_REALTEK=y
+CONFIG_PHY_NCSI=y
+CONFIG_DM_ETH=y
+CONFIG_PHY_GIGE=y
+CONFIG_FTGMAC100=y
+CONFIG_MDIO=y
+CONFIG_PHY=y
+CONFIG_PINCTRL=y
+CONFIG_RAM=y
+CONFIG_SPL_RAM=y
+CONFIG_DM_SERIAL=y
+CONFIG_SYS_NS16550=y
+CONFIG_SPI=y
+CONFIG_DM_SPI=y
+CONFIG_SYSRESET=y
+CONFIG_WDT=y
+CONFIG_USE_TINY_PRINTF=y
+CONFIG_SPL_TINY_MEMSET=y
+CONFIG_TPM=y
+CONFIG_TPM2_TIS_I2C=y
+# CONFIG_EFI_LOADER is not set
--

2.27.0

maintainer
#12 lore raw
In reply to Eddie James
Quoted 12 lines · Eddie James

This series backports the addition of a TPM TIS core driver from mainline u-boot. Then, add an I2C driver to talk to the NPCT75X chip using the TPM TIS core.
Add the TPM to the Rainier/Everest devicetree.
Also, add new board code for IBM's systems that need to "poison" the TPM during u-boot initialization.

I tested this on Everest hardware and verified in Linux that the TPM PCR0 was extended. I also tested with the TPM at the wrong bus address to verify that the code can handle a missing TPM, and I saw no errors.

Quoted 6 lines

Changes since v1:
- Use upstream core for I2C tpm driver. I initially couldn't get the core driver to work at all, but found a small bug in the ordering of operations in the core init. I also needed to force the locality to 0, like in the Linux NPCT75X driver.
- Use new board init code for IBM's systems that need the TPM poisoning

I've merged patches 1-8.

Patch 9 needs a little more discussion. If you repost, start a new series with just those changes (separating out the defconfig and device tree change).

Quoted 44 lines

Eddie James (5):
tpm: core: Set timeouts before requesting locality
i2c: ast_i2c: Remove SCL direct drive mode
tpm: add support for TPMv2.x I2C chips
arm: dts: ast2600-rainier: Add NPCT75X TPM
board: ast2600-ibm: Add AST2600 BMC based POWER10+ servers

Heinrich Schuchardt (1):
tis: fix tpm_tis_remove()

Ilias Apalodimas (1):
tpm2: Introduce TIS tpm core

Johannes Holland (1):
tpm: add #ifndef to fix redeclaration build errors

Simon Glass (1):
tpm: Add more TPM2 definitions

 arch/arm/dts/ast2600-rainier.dts     |  12 +-
 arch/arm/mach-aspeed/ast2600/Kconfig |   7 +
 board/aspeed/ast2600_ibm/Kconfig     |  13 +
 board/aspeed/ast2600_ibm/Makefile    |   1 +
 board/aspeed/ast2600_ibm/ibm.c       |  46 +++
 configs/ast2600_ibm_defconfig        | 137 ++++++++
 drivers/i2c/ast_i2c.c                |   2 +-
 drivers/tpm/Kconfig                  |   9 +
 drivers/tpm/Makefile                 |   1 +
 drivers/tpm/tpm2_tis_core.c          | 470 +++++++++++++++++++++++++++
 drivers/tpm/tpm2_tis_i2c.c           | 171 ++++++++++
 drivers/tpm/tpm_tis.h                | 138 ++++++++
 include/tpm-v2.h                     |  32 ++
 13 files changed, 1033 insertions(+), 6 deletions(-)
 create mode 100644 board/aspeed/ast2600_ibm/Kconfig
 create mode 100644 board/aspeed/ast2600_ibm/Makefile
 create mode 100644 board/aspeed/ast2600_ibm/ibm.c
 create mode 100644 configs/ast2600_ibm_defconfig
 create mode 100644 drivers/tpm/tpm2_tis_core.c
 create mode 100644 drivers/tpm/tpm2_tis_i2c.c

--
2.27.0