All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] tpm: cr50: Check for valid locality
@ 2020-12-31 16:52 Simon Glass
  2020-12-31 16:52 ` [PATCH 2/5] tpm: cr50: Add a better description and more debug Simon Glass
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Simon Glass @ 2020-12-31 16:52 UTC (permalink / raw)
  To: u-boot

When the Cr50 starts up it doesn't have a valid locality. The driver sets
it to -1 to indicate that. Tracking this allows cr50_i2c_cleanup() to
avoid releasing a locality that was not claimed.

However the helper functions that generate the flags use a u8 type which
cannot support -1, so they return a locality of 0xff.

Fix this by updating the type. With this, 'tpm startup TPM2_SU_CLEAR'
works as expected.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/tpm/cr50_i2c.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/tpm/cr50_i2c.c b/drivers/tpm/cr50_i2c.c
index ce61b72d222..f53924a8fcb 100644
--- a/drivers/tpm/cr50_i2c.c
+++ b/drivers/tpm/cr50_i2c.c
@@ -183,23 +183,31 @@ static int cr50_i2c_write(struct udevice *dev, u8 addr, const u8 *buffer,
 	return cr50_i2c_wait_tpm_ready(dev);
 }
 
-static inline u8 tpm_access(u8 locality)
+static inline u8 tpm_access(int locality)
 {
+	if (locality == -1)
+		locality = 0;
 	return 0x0 | (locality << 4);
 }
 
-static inline u8 tpm_sts(u8 locality)
+static inline u8 tpm_sts(int locality)
 {
+	if (locality == -1)
+		locality = 0;
 	return 0x1 | (locality << 4);
 }
 
-static inline u8 tpm_data_fifo(u8 locality)
+static inline u8 tpm_data_fifo(int locality)
 {
+	if (locality == -1)
+		locality = 0;
 	return 0x5 | (locality << 4);
 }
 
-static inline u8 tpm_did_vid(u8 locality)
+static inline u8 tpm_did_vid(int locality)
 {
+	if (locality == -1)
+		locality = 0;
 	return 0x6 | (locality << 4);
 }
 
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/5] tpm: cr50: Add a better description and more debug
  2020-12-31 16:52 [PATCH 1/5] tpm: cr50: Check for valid locality Simon Glass
@ 2020-12-31 16:52 ` Simon Glass
  2020-12-31 16:52 ` [PATCH 3/5] tpm: cr50: Rename driver to work with of-platdata Simon Glass
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2020-12-31 16:52 UTC (permalink / raw)
  To: u-boot

Update the TPM description to include the interrupt mechanicm since this
is useful to know. Also add a warning if the TPM cannot be found and a
debug line if it succeeds.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/tpm/cr50_i2c.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/tpm/cr50_i2c.c b/drivers/tpm/cr50_i2c.c
index f53924a8fcb..8b792409631 100644
--- a/drivers/tpm/cr50_i2c.c
+++ b/drivers/tpm/cr50_i2c.c
@@ -380,7 +380,6 @@ out_err:
 static int cr50_i2c_send(struct udevice *dev, const u8 *buf, size_t len)
 {
 	struct cr50_priv *priv = dev_get_priv(dev);
-
 	int status;
 	size_t burstcnt, limit, sent = 0;
 	u8 tpm_go[4] = { TPM_STS_GO };
@@ -557,9 +556,23 @@ static int cr50_i2c_get_desc(struct udevice *dev, char *buf, int size)
 {
 	struct dm_i2c_chip *chip = dev_get_parent_plat(dev);
 	struct cr50_priv *priv = dev_get_priv(dev);
+	int len;
+
+	len = snprintf(buf, size, "cr50 TPM 2.0 (i2c %02x id %x), ",
+		       chip->chip_addr, priv->vendor >> 16);
+	if (priv->use_irq) {
+		len += snprintf(buf + len, size - len, "irq=%s/%ld",
+				priv->irq.dev->name, priv->irq.id);
+	} else if (dm_gpio_is_valid(&priv->ready_gpio)) {
+		len += snprintf(buf + len, size - len, "gpio=%s/%u",
+				priv->ready_gpio.dev->name,
+				priv->ready_gpio.offset);
+	} else {
+		len += snprintf(buf + len, size - len, "delay=%d",
+				TIMEOUT_NO_IRQ_US);
+	}
 
-	return snprintf(buf, size, "cr50 TPM 2.0 (i2c %02x id %x) irq=%d",
-			chip->chip_addr, priv->vendor >> 16, priv->use_irq);
+	return len;
 }
 
 static int cr50_i2c_open(struct udevice *dev)
@@ -702,11 +715,12 @@ static int cr50_i2c_probe(struct udevice *dev)
 		mdelay(10);
 	}
 	if (vendor != CR50_DID_VID) {
-		log_debug("DID_VID %08x not recognised\n", vendor);
+		log_warning("DID_VID %08x not recognised\n", vendor);
 		return log_msg_ret("vendor-id", -EXDEV);
 	}
 	priv->vendor = vendor;
 	priv->locality = -1;
+	log_debug("Cr50 ready\n");
 
 	return 0;
 }
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/5] tpm: cr50: Rename driver to work with of-platdata
  2020-12-31 16:52 [PATCH 1/5] tpm: cr50: Check for valid locality Simon Glass
  2020-12-31 16:52 ` [PATCH 2/5] tpm: cr50: Add a better description and more debug Simon Glass
@ 2020-12-31 16:52 ` Simon Glass
  2020-12-31 16:52 ` [PATCH 4/5] x86: coral: Update an unused pin to reduce power Simon Glass
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2020-12-31 16:52 UTC (permalink / raw)
  To: u-boot

Update the driver name to match the compatible string, so it can work
with of-platdata.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/tpm/cr50_i2c.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tpm/cr50_i2c.c b/drivers/tpm/cr50_i2c.c
index 8b792409631..b103a6fdc39 100644
--- a/drivers/tpm/cr50_i2c.c
+++ b/drivers/tpm/cr50_i2c.c
@@ -742,8 +742,8 @@ static const struct udevice_id cr50_i2c_ids[] = {
 	{ }
 };
 
-U_BOOT_DRIVER(cr50_i2c) = {
-	.name   = "cr50_i2c",
+U_BOOT_DRIVER(google_cr50) = {
+	.name   = "google_cr50",
 	.id     = UCLASS_TPM,
 	.of_match = cr50_i2c_ids,
 	.ops    = &cr50_i2c_ops,
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/5] x86: coral: Update an unused pin to reduce power
  2020-12-31 16:52 [PATCH 1/5] tpm: cr50: Check for valid locality Simon Glass
  2020-12-31 16:52 ` [PATCH 2/5] tpm: cr50: Add a better description and more debug Simon Glass
  2020-12-31 16:52 ` [PATCH 3/5] tpm: cr50: Rename driver to work with of-platdata Simon Glass
@ 2020-12-31 16:52 ` Simon Glass
  2020-12-31 16:52 ` [PATCH 5/5] x86: coral: Enable CONFIG_BOOTARGS_SUBST Simon Glass
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2020-12-31 16:52 UTC (permalink / raw)
  To: u-boot

GPIO_25 is not used on coral, so set it up in deep sleep.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/x86/dts/chromebook_coral.dts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/dts/chromebook_coral.dts b/arch/x86/dts/chromebook_coral.dts
index d66e128ae62..580a6e16da1 100644
--- a/arch/x86/dts/chromebook_coral.dts
+++ b/arch/x86/dts/chromebook_coral.dts
@@ -629,6 +629,7 @@
 				PAD_CFG0_TX_DISABLE | PAD_CFG0_ROUTE_IOAPIC |
 				PAD_CFG0_TRIG_LEVEL | PAD_CFG0_RX_POL_INVERT)
 			(PAD_CFG1_PULL_NONE | PAD_CFG1_IOSSTATE_TXD_RXE)
+		PAD_CFG_GPI(GPIO_25, UP_20K, DEEP)	 /* unused */
 
 		/*
 		 * WLAN_PE_RST - default to deasserted just in case FSP
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/5] x86: coral: Enable CONFIG_BOOTARGS_SUBST
  2020-12-31 16:52 [PATCH 1/5] tpm: cr50: Check for valid locality Simon Glass
                   ` (2 preceding siblings ...)
  2020-12-31 16:52 ` [PATCH 4/5] x86: coral: Update an unused pin to reduce power Simon Glass
@ 2020-12-31 16:52 ` Simon Glass
  2021-01-23 17:27 ` Simon Glass
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2020-12-31 16:52 UTC (permalink / raw)
  To: u-boot

Enable this option so that the boot-script substitutions of %U works as
expected. With this, it can boot into Chrome OS.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 configs/chromebook_coral_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/chromebook_coral_defconfig b/configs/chromebook_coral_defconfig
index 05e6ce64932..ab73a0a88ce 100644
--- a/configs/chromebook_coral_defconfig
+++ b/configs/chromebook_coral_defconfig
@@ -29,6 +29,7 @@ CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_SPL_BOOTSTAGE_RECORD_COUNT=10
 CONFIG_BOOTSTAGE_STASH=y
 CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS_SUBST=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 CONFIG_LOGF_FUNC=y
 CONFIG_SPL_LOG=y
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/5] x86: coral: Enable CONFIG_BOOTARGS_SUBST
  2020-12-31 16:52 [PATCH 1/5] tpm: cr50: Check for valid locality Simon Glass
                   ` (3 preceding siblings ...)
  2020-12-31 16:52 ` [PATCH 5/5] x86: coral: Enable CONFIG_BOOTARGS_SUBST Simon Glass
@ 2021-01-23 17:27 ` Simon Glass
  2021-01-23 17:27 ` [PATCH 4/5] x86: coral: Update an unused pin to reduce power Simon Glass
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2021-01-23 17:27 UTC (permalink / raw)
  To: u-boot

Enable this option so that the boot-script substitutions of %U works as
expected. With this, it can boot into Chrome OS.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 configs/chromebook_coral_defconfig | 1 +
 1 file changed, 1 insertion(+)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 4/5] x86: coral: Update an unused pin to reduce power
  2020-12-31 16:52 [PATCH 1/5] tpm: cr50: Check for valid locality Simon Glass
                   ` (4 preceding siblings ...)
  2021-01-23 17:27 ` Simon Glass
@ 2021-01-23 17:27 ` Simon Glass
  2021-01-23 17:27 ` [PATCH 3/5] tpm: cr50: Rename driver to work with of-platdata Simon Glass
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2021-01-23 17:27 UTC (permalink / raw)
  To: u-boot

GPIO_25 is not used on coral, so set it up in deep sleep.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/x86/dts/chromebook_coral.dts | 1 +
 1 file changed, 1 insertion(+)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 3/5] tpm: cr50: Rename driver to work with of-platdata
  2020-12-31 16:52 [PATCH 1/5] tpm: cr50: Check for valid locality Simon Glass
                   ` (5 preceding siblings ...)
  2021-01-23 17:27 ` [PATCH 4/5] x86: coral: Update an unused pin to reduce power Simon Glass
@ 2021-01-23 17:27 ` Simon Glass
  2021-01-23 17:27 ` [PATCH 2/5] tpm: cr50: Add a better description and more debug Simon Glass
  2021-01-23 17:27 ` [PATCH 1/5] tpm: cr50: Check for valid locality Simon Glass
  8 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2021-01-23 17:27 UTC (permalink / raw)
  To: u-boot

Update the driver name to match the compatible string, so it can work
with of-platdata.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/tpm/cr50_i2c.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 2/5] tpm: cr50: Add a better description and more debug
  2020-12-31 16:52 [PATCH 1/5] tpm: cr50: Check for valid locality Simon Glass
                   ` (6 preceding siblings ...)
  2021-01-23 17:27 ` [PATCH 3/5] tpm: cr50: Rename driver to work with of-platdata Simon Glass
@ 2021-01-23 17:27 ` Simon Glass
  2021-01-23 17:27 ` [PATCH 1/5] tpm: cr50: Check for valid locality Simon Glass
  8 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2021-01-23 17:27 UTC (permalink / raw)
  To: u-boot

Update the TPM description to include the interrupt mechanicm since this
is useful to know. Also add a warning if the TPM cannot be found and a
debug line if it succeeds.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/tpm/cr50_i2c.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/5] tpm: cr50: Check for valid locality
  2020-12-31 16:52 [PATCH 1/5] tpm: cr50: Check for valid locality Simon Glass
                   ` (7 preceding siblings ...)
  2021-01-23 17:27 ` [PATCH 2/5] tpm: cr50: Add a better description and more debug Simon Glass
@ 2021-01-23 17:27 ` Simon Glass
  8 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2021-01-23 17:27 UTC (permalink / raw)
  To: u-boot

When the Cr50 starts up it doesn't have a valid locality. The driver sets
it to -1 to indicate that. Tracking this allows cr50_i2c_cleanup() to
avoid releasing a locality that was not claimed.

However the helper functions that generate the flags use a u8 type which
cannot support -1, so they return a locality of 0xff.

Fix this by updating the type. With this, 'tpm startup TPM2_SU_CLEAR'
works as expected.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/tpm/cr50_i2c.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-01-23 17:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-31 16:52 [PATCH 1/5] tpm: cr50: Check for valid locality Simon Glass
2020-12-31 16:52 ` [PATCH 2/5] tpm: cr50: Add a better description and more debug Simon Glass
2020-12-31 16:52 ` [PATCH 3/5] tpm: cr50: Rename driver to work with of-platdata Simon Glass
2020-12-31 16:52 ` [PATCH 4/5] x86: coral: Update an unused pin to reduce power Simon Glass
2020-12-31 16:52 ` [PATCH 5/5] x86: coral: Enable CONFIG_BOOTARGS_SUBST Simon Glass
2021-01-23 17:27 ` Simon Glass
2021-01-23 17:27 ` [PATCH 4/5] x86: coral: Update an unused pin to reduce power Simon Glass
2021-01-23 17:27 ` [PATCH 3/5] tpm: cr50: Rename driver to work with of-platdata Simon Glass
2021-01-23 17:27 ` [PATCH 2/5] tpm: cr50: Add a better description and more debug Simon Glass
2021-01-23 17:27 ` [PATCH 1/5] tpm: cr50: Check for valid locality Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.