Skip to contentSkip to conversation

TPM: STMicroelectronics st33 driver SPI

PATCH In review Matthias Leblanc 2 participants 4 messages Apr 9, 2013 – Apr 11, 2013

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

PATCH 1/1 TPM: STMicroelectronics st33 driver SPI

From: Mathias leblanc <[email protected]>

* STMicroelectronics version 1.2.0, Copyright (C) 2010
* STMicroelectronics comes with ABSOLUTELY NO WARRANTY.
* This is free software, and you are welcome to redistribute it
* under certain conditions.

This is the driver for TPM chip from ST Microelectronics.

If you have a TPM security chip from STMicroelectronics working with an SPI, in menuconfig or .config choose the tpm driver on device --> tpm and activate the protocol of your choice before compiling the kernel.
The driver will be accessible from within Linux.

Tested on linux x86/x64 and beagleboard REV B & XM REV C

---
 drivers/char/tpm/Kconfig             |   10 +
 drivers/char/tpm/Makefile            |    1 +
 drivers/char/tpm/tpm_spi_stm_st33.c  | 1116 ++++++++++++++++++++++++++++++++++
 drivers/char/tpm/tpm_spi_stm_st33.h  |   75 +++
 include/linux/spi/tpm_spi_stm_st33.h |   46 ++
 5 files changed, 1248 insertions(+), 0 deletions(-)
 create mode 100644 drivers/char/tpm/tpm_spi_stm_st33.c
 create mode 100644 drivers/char/tpm/tpm_spi_stm_st33.h
 create mode 100644 include/linux/spi/tpm_spi_stm_st33.h
drivers/char/tpm/Kconfig +10 -0
index dbfd564..2fc1254 100644
@@ -91,4 +91,14 @@ config TCG_ST33_I2C
         To compile this driver as a module, choose M here; the module will be
         called tpm_stm_st33_i2c.
 
+config TCG_ST33_SPI
+       tristate "STMicroelectronics ST33 SPI"
+       depends on SPI
+       depends on GPIOLIB
+       ---help---
+       If you have a TPM security chip from STMicroelectronics working with
+       an SPI bus say Yes and it will be accessible from within Linux.
+       To compile this driver as a module, choose M here; the module will be
+       called tpm_stm_st33_spi.
+
 endif # TCG_TPM
drivers/char/tpm/Makefile +1 -0
index a3736c9..a1db3dd 100644
@@ -18,3 +18,4 @@ obj-$(CONFIG_TCG_ATMEL) += tpm_atmel.o
 obj-$(CONFIG_TCG_INFINEON) += tpm_infineon.o
 obj-$(CONFIG_TCG_IBMVTPM) += tpm_ibmvtpm.o
 obj-$(CONFIG_TCG_ST33_I2C) += tpm_i2c_stm_st33.o
+obj-$(CONFIG_TCG_ST33_SPI) += tpm_spi_stm_st33.o
drivers/char/tpm/tpm_spi_stm_st33.c new file +1116 -0

1,116 lines not on this page · raw message

drivers/char/tpm/tpm_spi_stm_st33.h new file +75 -0

75 lines not on this page · raw message

include/linux/spi/tpm_spi_stm_st33.h new file +46 -0

46 lines not on this page · raw message

Signature · 1 line
1.7.1
maintainer
#1 lore raw

Hi Matthias,

Am Dienstag, 9. April 2013, 16:42:42 schrieb Matthias Leblanc:

Quoted 15 lines

From: Mathias leblanc <[email protected]>

* STMicroelectronics version 1.2.0, Copyright (C) 2010
* STMicroelectronics comes with ABSOLUTELY NO WARRANTY.
* This is free software, and you are welcome to redistribute it
* under certain conditions.

This is the driver for TPM chip from ST Microelectronics.

If you have a TPM security chip from STMicroelectronics working with an SPI, in menuconfig or .config choose the tpm driver on device --> tpm and activate the protocol of your choice before compiling the kernel.
The driver will be accessible from within Linux.

Quoted 3 lines

Tested on linux x86/x64 and beagleboard REV B & XM REV C

fails to compile for me.

Steps to reproduce (on x86_64):
make defconfig
git reset --hard tpmdd/tpmdd-03-04-13
make defconfig
git am /tmp/\[tpmdd-devel\]\ \[PATCH\ 1_1\]\ TPM_STMicroelectronics\ st33\ driver\ SPI.mbox make menuconfig -> enable spi, gpio, and the TPM
make

LANG=C make
make[1]: Nothing to be done for `all'.
make[1]: Nothing to be done for `relocs'.

  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h

make[3]: `arch/x86/realmode/rm/realmode.bin' is up to date.
LD [M] drivers/char/tpm/tpm_bios.o
CC [M] drivers/char/tpm/tpm_spi_stm_st33.o
drivers/char/tpm/tpm_spi_stm_st33.c: In function 'write8_reg':
drivers/char/tpm/tpm_spi_stm_st33.c:115:33: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:118:27: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:121:28: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:149:32: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c: In function 'read8_reg':
drivers/char/tpm/tpm_spi_stm_st33.c:188:33: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:191:27: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:195:28: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c: In function '_wait_for_interrupt_serirq_timeout':
drivers/char/tpm/tpm_spi_stm_st33.c:323:15: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:325:35: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:326:32: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c: In function 'tpm_ioserirq_handler':
drivers/char/tpm/tpm_spi_stm_st33.c:605:21: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c: In function 'evaluate_latency':
drivers/char/tpm/tpm_spi_stm_st33.c:802:16: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c: In function 'tpm_st33_spi_probe':
drivers/char/tpm/tpm_spi_stm_st33.c:864:15: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:867:19: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:871:15: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:874:19: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:889:35: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:892:31: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:895:15: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:896:19: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:904:33: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:909:35: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:915:46: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:921:4: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:959:15: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:964:36: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:967:26: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:970:26: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:973:19: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:974:22: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:975:16: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:978:19: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:979:22: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:980:16: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:983:15: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c: In function 'tpm_st33_spi_remove':
drivers/char/tpm/tpm_spi_stm_st33.c:1004:22: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:1007:16: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:1009:16: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:1010:19: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:1011:13: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:1013:16: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:1014:19: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:1015:13: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c: In function 'tpm_st33_spi_pm_suspend':
drivers/char/tpm/tpm_spi_stm_st33.c:1041:27: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:1044:33: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c: In function 'tpm_st33_spi_pm_resume':
drivers/char/tpm/tpm_spi_stm_st33.c:1064:27: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:1071:33: error: dereferencing pointer to incomplete type make[3]: *** [drivers/char/tpm/tpm_spi_stm_st33.o] Error 1
make[2]: *** [drivers/char/tpm] Error 2
make[1]: *** [drivers/char] Error 2
make: *** [drivers] Error 2

This is caused by your double inclusion guard in
include/linux/spi/tpm_spi_stm_st33.h

#ifndef __STM_ST33_TPM_SPI_H__
#define __STM_ST33_TPM_SPI_H__

#include <linux/spi/spi.h>

#define TPM_ST33_SPI "st33zp24_spi"

#ifndef __STM_ST33_TPM_SPI_H__ <------- the define was just a few lines before struct st33zp24_platform_data {

Regards,
Peter

#2 lore raw

Hi Peter,

Yes, you have right, these error are generated by #ifndef __STM_ST33_TPM_SPI_H__ Just remove it and the #endif next the structure.

Did you have these warning when you have run checkpatch script?

Thanks,

Mathias

-----Original Message-----
From: Peter Hüwe [mailto:[email protected]]
Sent: 10 April, 2013 22:32
To: [email protected]; Mathias LEBLANC; Kent Yoder; Jean-Luc BLANC
Cc: [email protected]; Mathias leblanc
Subject: Re: [tpmdd-devel] [PATCH 1/1] TPM: STMicroelectronics st33 driver SPI

Hi Matthias,

Am Dienstag, 9. April 2013, 16:42:42 schrieb Matthias Leblanc:

Quoted 15 lines

From: Mathias leblanc <[email protected]>

* STMicroelectronics version 1.2.0, Copyright (C) 2010
* STMicroelectronics comes with ABSOLUTELY NO WARRANTY.
* This is free software, and you are welcome to redistribute it
* under certain conditions.

This is the driver for TPM chip from ST Microelectronics.

If you have a TPM security chip from STMicroelectronics working with an SPI, in menuconfig or .config choose the tpm driver on device --> tpm and activate the protocol of your choice before compiling the kernel.
The driver will be accessible from within Linux.

Quoted 3 lines

Tested on linux x86/x64 and beagleboard REV B & XM REV C

fails to compile for me.

Steps to reproduce (on x86_64):
make defconfig
git reset --hard tpmdd/tpmdd-03-04-13
make defconfig
git am /tmp/\[tpmdd-devel\]\ \[PATCH\ 1_1\]\ TPM_STMicroelectronics\ st33\ driver\ SPI.mbox make menuconfig -> enable spi, gpio, and the TPM make

LANG=C make
make[1]: Nothing to be done for `all'.
make[1]: Nothing to be done for `relocs'.

  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h

make[3]: `arch/x86/realmode/rm/realmode.bin' is up to date.
LD [M] drivers/char/tpm/tpm_bios.o
CC [M] drivers/char/tpm/tpm_spi_stm_st33.o
drivers/char/tpm/tpm_spi_stm_st33.c: In function 'write8_reg':
drivers/char/tpm/tpm_spi_stm_st33.c:115:33: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:118:27: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:121:28: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:149:32: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c: In function 'read8_reg':
drivers/char/tpm/tpm_spi_stm_st33.c:188:33: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:191:27: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:195:28: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c: In function '_wait_for_interrupt_serirq_timeout':
drivers/char/tpm/tpm_spi_stm_st33.c:323:15: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:325:35: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:326:32: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c: In function 'tpm_ioserirq_handler':
drivers/char/tpm/tpm_spi_stm_st33.c:605:21: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c: In function 'evaluate_latency':
drivers/char/tpm/tpm_spi_stm_st33.c:802:16: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c: In function 'tpm_st33_spi_probe':
drivers/char/tpm/tpm_spi_stm_st33.c:864:15: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:867:19: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:871:15: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:874:19: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:889:35: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:892:31: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:895:15: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:896:19: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:904:33: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:909:35: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:915:46: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:921:4: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:959:15: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:964:36: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:967:26: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:970:26: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:973:19: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:974:22: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:975:16: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:978:19: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:979:22: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:980:16: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:983:15: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c: In function 'tpm_st33_spi_remove':
drivers/char/tpm/tpm_spi_stm_st33.c:1004:22: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:1007:16: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:1009:16: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:1010:19: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:1011:13: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:1013:16: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:1014:19: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:1015:13: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c: In function 'tpm_st33_spi_pm_suspend':
drivers/char/tpm/tpm_spi_stm_st33.c:1041:27: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:1044:33: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c: In function 'tpm_st33_spi_pm_resume':
drivers/char/tpm/tpm_spi_stm_st33.c:1064:27: error: dereferencing pointer to incomplete type drivers/char/tpm/tpm_spi_stm_st33.c:1071:33: error: dereferencing pointer to incomplete type make[3]: *** [drivers/char/tpm/tpm_spi_stm_st33.o] Error 1
make[2]: *** [drivers/char/tpm] Error 2
make[1]: *** [drivers/char] Error 2
make: *** [drivers] Error 2

This is caused by your double inclusion guard in
include/linux/spi/tpm_spi_stm_st33.h

#ifndef __STM_ST33_TPM_SPI_H__
#define __STM_ST33_TPM_SPI_H__

#include <linux/spi/spi.h>

#define TPM_ST33_SPI "st33zp24_spi"

#ifndef __STM_ST33_TPM_SPI_H__ <------- the define was just a few lines before struct st33zp24_platform_data {

Regards,
Peter

maintainer
#3 lore raw

Hi Matthias,
Am Donnerstag, 11. April 2013, 10:58:59 schrieb Mathias LEBLANC:

Quoted 4 lines

Hi Peter,

Yes, you have right, these error are generated by #ifndef __STM_ST33_TPM_SPI_H__ Just remove it and the #endif next the structure.

Yes, I know that - for the submission to be included this has to be changed by you.

Quoted 1 line

Did you have these warning when you have run checkpatch script?

You mean the sparse warnings I sent you?
I removed the superflous ifdef to compile it and then let sparse run against it.
The driver passes normal checkpatch check, unless you call it with -strict

Peter