All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] tpm: tpm_tis_lpc: Add support for AT97SC3204
@ 2016-10-14 21:41 George McCollister
  2016-10-15 13:09 ` Simon Glass
  0 siblings, 1 reply; 2+ messages in thread
From: George McCollister @ 2016-10-14 21:41 UTC (permalink / raw)
  To: u-boot

The Atmel AT97SC3204 is also TIS compliant.
Modify the tpm_tis_lpc driver to check for the vid/did used by the
Atmel AT97SC3204 and report an appropriate description.

Signed-off-by: George McCollister <george.mccollister@gmail.com>
---
 drivers/tpm/tpm_tis_lpc.c | 37 ++++++++++++++++++++++++++++---------
 1 file changed, 28 insertions(+), 9 deletions(-)

diff --git a/drivers/tpm/tpm_tis_lpc.c b/drivers/tpm/tpm_tis_lpc.c
index b4efbb5..316993a 100644
--- a/drivers/tpm/tpm_tis_lpc.c
+++ b/drivers/tpm/tpm_tis_lpc.c
@@ -21,6 +21,21 @@
 
 #define PREFIX "lpc_tpm: "
 
+enum i2c_chip_type {
+	SLB9635,
+	AT97SC3204,
+};
+
+static const char * const chip_name[] = {
+	[SLB9635] = "Infineon SLB9635 TT 1.2",
+	[AT97SC3204] = "Atmel AT97SC3204",
+};
+
+static const u32 chip_didvid[] = {
+	[SLB9635] = 0xb15d1,
+	[AT97SC3204] = 0x32041114,
+};
+
 struct tpm_locality {
 	u32 access;
 	u8 padding0[4];
@@ -146,9 +161,9 @@ static int tis_wait_reg(struct tpm_tis_lpc_priv *priv, u32 *reg, u8 mask,
 static int tpm_tis_lpc_probe(struct udevice *dev)
 {
 	struct tpm_tis_lpc_priv *priv = dev_get_priv(dev);
-	u32 vid, did;
 	fdt_addr_t addr;
 	u32 didvid;
+	ulong chip_type = dev_get_driver_data(dev);
 
 	addr = dev_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
@@ -156,15 +171,16 @@ static int tpm_tis_lpc_probe(struct udevice *dev)
 	priv->regs = map_sysmem(addr, 0);
 	didvid = tpm_read_word(priv, &priv->regs[0].did_vid);
 
-	vid = didvid & 0xffff;
-	did = (didvid >> 16) & 0xffff;
-	if (vid != 0x15d1 || did != 0xb) {
+	if (didvid == chip_didvid[chip_type]) {
+		debug("Found TPM: %s\n", chip_name[chip_type]);
+	} else {
+		u32 vid, did;
+		vid = didvid & 0xffff;
+		did = (didvid >> 16) & 0xffff;
 		debug("Invalid vendor/device ID %04x/%04x\n", vid, did);
 		return -ENOSYS;
 	}
 
-	debug("Found TPM %s by %s\n", "SLB9635 TT 1.2", "Infineon");
-
 	return 0;
 }
 
@@ -421,11 +437,13 @@ static int tpm_tis_lpc_close(struct udevice *dev)
 
 static int tpm_tis_get_desc(struct udevice *dev, char *buf, int size)
 {
+	ulong chip_type = dev_get_driver_data(dev);
+
 	if (size < 50)
 		return -ENOSPC;
 
-	return snprintf(buf, size, "1.2 TPM (vendor %s, chip %s)",
-			"Infineon", "SLB9635 TT 1.2");
+	return snprintf(buf, size, "1.2 TPM (%s)",
+			chip_name[chip_type]);
 }
 
 
@@ -438,7 +456,8 @@ static const struct tpm_ops tpm_tis_lpc_ops = {
 };
 
 static const struct udevice_id tpm_tis_lpc_ids[] = {
-	{ .compatible = "infineon,slb9635lpc" },
+	{ .compatible = "infineon,slb9635lpc", .data = SLB9635 },
+	{ .compatible = "atmel,at97sc3204", .data = AT97SC3204 },
 	{ }
 };
 
-- 
2.9.3

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

* [U-Boot] [PATCH] tpm: tpm_tis_lpc: Add support for AT97SC3204
  2016-10-14 21:41 [U-Boot] [PATCH] tpm: tpm_tis_lpc: Add support for AT97SC3204 George McCollister
@ 2016-10-15 13:09 ` Simon Glass
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Glass @ 2016-10-15 13:09 UTC (permalink / raw)
  To: u-boot

Hi George,

On 14 October 2016 at 15:41, George McCollister
<george.mccollister@gmail.com> wrote:
>
> The Atmel AT97SC3204 is also TIS compliant.
> Modify the tpm_tis_lpc driver to check for the vid/did used by the
> Atmel AT97SC3204 and report an appropriate description.
>
> Signed-off-by: George McCollister <george.mccollister@gmail.com>
> ---
>  drivers/tpm/tpm_tis_lpc.c | 37 ++++++++++++++++++++++++++++---------
>  1 file changed, 28 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/tpm/tpm_tis_lpc.c b/drivers/tpm/tpm_tis_lpc.c
> index b4efbb5..316993a 100644
> --- a/drivers/tpm/tpm_tis_lpc.c
> +++ b/drivers/tpm/tpm_tis_lpc.c
> @@ -21,6 +21,21 @@
>
>  #define PREFIX "lpc_tpm: "
>
> +enum i2c_chip_type {
> +       SLB9635,
> +       AT97SC3204,
> +};
> +
> +static const char * const chip_name[] = {
> +       [SLB9635] = "Infineon SLB9635 TT 1.2",
> +       [AT97SC3204] = "Atmel AT97SC3204",
> +};
> +
> +static const u32 chip_didvid[] = {
> +       [SLB9635] = 0xb15d1,
> +       [AT97SC3204] = 0x32041114,
> +};
> +
>  struct tpm_locality {
>         u32 access;
>         u8 padding0[4];
> @@ -146,9 +161,9 @@ static int tis_wait_reg(struct tpm_tis_lpc_priv *priv, u32 *reg, u8 mask,
>  static int tpm_tis_lpc_probe(struct udevice *dev)
>  {
>         struct tpm_tis_lpc_priv *priv = dev_get_priv(dev);
> -       u32 vid, did;
>         fdt_addr_t addr;
>         u32 didvid;
> +       ulong chip_type = dev_get_driver_data(dev);
>
>         addr = dev_get_addr(dev);
>         if (addr == FDT_ADDR_T_NONE)
> @@ -156,15 +171,16 @@ static int tpm_tis_lpc_probe(struct udevice *dev)
>         priv->regs = map_sysmem(addr, 0);
>         didvid = tpm_read_word(priv, &priv->regs[0].did_vid);
>
> -       vid = didvid & 0xffff;
> -       did = (didvid >> 16) & 0xffff;
> -       if (vid != 0x15d1 || did != 0xb) {
> +       if (didvid == chip_didvid[chip_type]) {
> +               debug("Found TPM: %s\n", chip_name[chip_type]);
> +       } else {

Can you put this error clause first, so that the debug() remains where it is?

> +               u32 vid, did;
> +               vid = didvid & 0xffff;
> +               did = (didvid >> 16) & 0xffff;
>                 debug("Invalid vendor/device ID %04x/%04x\n", vid, did);
>                 return -ENOSYS;

I think we should change this to -ENODEV as it is a missing device,
not a missing system call. Or maybe -ENOENT?

>         }
>
> -       debug("Found TPM %s by %s\n", "SLB9635 TT 1.2", "Infineon");
> -
>         return 0;
>  }
>
> @@ -421,11 +437,13 @@ static int tpm_tis_lpc_close(struct udevice *dev)
>
>  static int tpm_tis_get_desc(struct udevice *dev, char *buf, int size)
>  {
> +       ulong chip_type = dev_get_driver_data(dev);
> +
>         if (size < 50)
>                 return -ENOSPC;
>
> -       return snprintf(buf, size, "1.2 TPM (vendor %s, chip %s)",
> -                       "Infineon", "SLB9635 TT 1.2");
> +       return snprintf(buf, size, "1.2 TPM (%s)",
> +                       chip_name[chip_type]);
>  }
>
>
> @@ -438,7 +456,8 @@ static const struct tpm_ops tpm_tis_lpc_ops = {
>  };
>
>  static const struct udevice_id tpm_tis_lpc_ids[] = {
> -       { .compatible = "infineon,slb9635lpc" },
> +       { .compatible = "infineon,slb9635lpc", .data = SLB9635 },
> +       { .compatible = "atmel,at97sc3204", .data = AT97SC3204 },
>         { }
>  };
>
> --
> 2.9.3
>

Regards,
Simon

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

end of thread, other threads:[~2016-10-15 13:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-14 21:41 [U-Boot] [PATCH] tpm: tpm_tis_lpc: Add support for AT97SC3204 George McCollister
2016-10-15 13:09 ` 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.