diff mbox series

[5/6] drivers: tpm: atmel_twi: implement get_desc operation

Message ID 20211104011253.4401-6-matt@traverse.com.au
State Superseded
Delegated to: Eugen Hristev
Headers show
Series Fix Atmel/Microchip TPMv1.2 issues | expand

Commit Message

Mathew McBride Nov. 4, 2021, 1:12 a.m. UTC
Without get_desc, the tpm command will not provide a
description of the device in 'tpm device' or 'tpm info'.

Due to the characteristics of the Atmel TPM it isn't
possible to determine certain attributes (e.g open/close
status) without using the TPM stack (compare Infineon
and ST TPM drivers), so just print out
the udevice name as a unique identifier.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
---
 drivers/tpm/tpm_atmel_twi.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Ilias Apalodimas Nov. 4, 2021, 7:39 a.m. UTC | #1
Hi Matthew,

On Thu, 4 Nov 2021 at 03:14, Mathew McBride <matt@traverse.com.au> wrote:
>
> Without get_desc, the tpm command will not provide a
> description of the device in 'tpm device' or 'tpm info'.
>
> Due to the characteristics of the Atmel TPM it isn't
> possible to determine certain attributes (e.g open/close
> status) without using the TPM stack (compare Infineon
> and ST TPM drivers), so just print out
> the udevice name as a unique identifier.
>
> Signed-off-by: Mathew McBride <matt@traverse.com.au>
> ---
>  drivers/tpm/tpm_atmel_twi.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tpm/tpm_atmel_twi.c b/drivers/tpm/tpm_atmel_twi.c
> index 71b101406d..9ca33e4334 100644
> --- a/drivers/tpm/tpm_atmel_twi.c
> +++ b/drivers/tpm/tpm_atmel_twi.c
> @@ -52,7 +52,10 @@ static int tpm_atmel_twi_close(struct udevice *dev)
>   */
>  static int tpm_atmel_twi_get_desc(struct udevice *dev, char *buf, int size)
>  {
> -       return 0;
> +       if (size < 50)
> +               return -ENOSPC;
> +
> +       return snprintf(buf, size, "Atmel 1.2 TPM (%s)", dev->name);

Is there anything more helpful we can print on that? Device ID,
manufacturer ID maybe?


Regards
/Ilias
>  }
>
>  /*
> --
> 2.30.1
>
Mathew McBride Nov. 10, 2021, 2:43 a.m. UTC | #2
On Thu, Nov 4, 2021, at 6:39 PM, Ilias Apalodimas wrote:
> Hi Matthew,
> 
> On Thu, 4 Nov 2021 at 03:14, Mathew McBride <matt@traverse.com.au> wrote:
> 
> >  static int tpm_atmel_twi_get_desc(struct udevice *dev, char *buf, int size)
> >  {
> > -       return 0;
> > +       if (size < 50)
> > +               return -ENOSPC;
> > +
> > +       return snprintf(buf, size, "Atmel 1.2 TPM (%s)", dev->name);
> 
> Is there anything more helpful we can print on that? Device ID,
> manufacturer ID maybe?
Perhaps the DT compatible would be useful?

=> tpm device
device 0: atmel,at97sc3204t TPM 1.2 (tpm@29)

tpm_version under Linux provides this, but it requires talking to the TPM over TIS:
$ tpm_version
TPM 1.2 Version Info:
  Chip Version:        1.2.66.16
  Spec Level:          2
  Errata Revision:     3
  TPM Vendor ID:       ATML
  TPM Version:         01010000
  Manufacturer Info:   41544d4c

> 
> Regards
> /Ilias
> >  }
> >
> >  /*
> > --
> > 2.30.1
> >
>
Ilias Apalodimas Nov. 10, 2021, 6:58 a.m. UTC | #3
Hi Matthew,

On Wed, 10 Nov 2021 at 04:43, Mathew McBride <matt@traverse.com.au> wrote:
>
>
>
> On Thu, Nov 4, 2021, at 6:39 PM, Ilias Apalodimas wrote:
>
> Hi Matthew,
>
> On Thu, 4 Nov 2021 at 03:14, Mathew McBride <matt@traverse.com.au> wrote:
>
> >  static int tpm_atmel_twi_get_desc(struct udevice *dev, char *buf, int size)
> >  {
> > -       return 0;
> > +       if (size < 50)
> > +               return -ENOSPC;
> > +
> > +       return snprintf(buf, size, "Atmel 1.2 TPM (%s)", dev->name);
>
> Is there anything more helpful we can print on that? Device ID,
> manufacturer ID maybe?
>
> Perhaps the DT compatible would be useful?
>
> => tpm device
> device 0: atmel,at97sc3204t TPM 1.2 (tpm@29)

No strong preference here, up to you.

>
>
> tpm_version under Linux provides this, but it requires talking to the TPM over TIS:
> $ tpm_version
> TPM 1.2 Version Info:
>   Chip Version:        1.2.66.16
>   Spec Level:          2
>   Errata Revision:     3
>   TPM Vendor ID:       ATML
>   TPM Version:         01010000
>   Manufacturer Info:   41544d4c
>

Ok fair enough.  I am fine keeping it as is.

Thanks
/Ilias
diff mbox series

Patch

diff --git a/drivers/tpm/tpm_atmel_twi.c b/drivers/tpm/tpm_atmel_twi.c
index 71b101406d..9ca33e4334 100644
--- a/drivers/tpm/tpm_atmel_twi.c
+++ b/drivers/tpm/tpm_atmel_twi.c
@@ -52,7 +52,10 @@  static int tpm_atmel_twi_close(struct udevice *dev)
  */
 static int tpm_atmel_twi_get_desc(struct udevice *dev, char *buf, int size)
 {
-	return 0;
+	if (size < 50)
+		return -ENOSPC;
+
+	return snprintf(buf, size, "Atmel 1.2 TPM (%s)", dev->name);
 }
 
 /*