Skip to contentSkip to conversation

TPM: STMicroelectronics st33 driver SPI

PATCH New Mathias Leblanc 1 participant 1 message Apr 8, 2013

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

PATCH 1/1 TPM: STMicroelectronics st33 driver SPI

* 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 I2C/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

---
 arch/arm/mach-omap2/board-omap3beagle.c |   40 ++
 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 ++
 6 files changed, 1287 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
arch/arm/mach-omap2/board-omap3beagle.c +40 -0
index c3558f9..72e6513 100644
@@ -46,6 +46,11 @@
 #include <video/omap-panel-tfp410.h>
 #include <linux/platform_data/mtd-nand-omap2.h>
 
+#ifdef CONFIG_TCG_ST33_SPI
+#include <linux/spi/tpm_spi_stm_st33.h>
+#include <linux/spi/spi.h>
+#endif /* CONFIG_TCG_ST33_SPI */
+
 #include "common.h"
 #include "omap_device.h"
 #include "gpmc.h"
@@ -375,6 +380,26 @@ static struct i2c_board_info __initdata beagle_i2c_eeprom[] = {
        },
 };
 
+#if defined CONFIG_TCG_ST33_I2C || defined CONFIG_TCG_ST33_SPI
+static struct st33zp24_platform_data tpm_data = {
+	.io_serirq = 136,
+	.io_lpcpd  = 143,
+};
+#endif
+
+#ifdef CONFIG_TCG_ST33_SPI
+static struct  spi_board_info tpm_st33_spi_board_info[] = {
+	{
+		.modalias = TPM_ST33_SPI,
+		.max_speed_hz = 10000000,
+		.bus_num = 4,
+		.chip_select = 0,
+		.mode = SPI_MODE_0,
+		.platform_data = &tpm_data,
+	},
+};
+#endif
+
 static int __init omap3_beagle_i2c_init(void)
 {
 	omap3_pmic_get_config(&beagle_twldata,
@@ -556,6 +581,20 @@ static void __init omap3_beagle_init(void)
 	omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
 	omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
 
+	#if defined CONFIG_TCG_ST33_I2C || defined CONFIG_TCG_ST33_SPI
+		omap_mux_init_gpio(tpm_data.io_serirq, OMAP_PIN_INPUT);
+		omap_mux_init_gpio(tpm_data.io_lpcpd, OMAP_PIN_OUTPUT);
+	#endif
+
+	#ifdef CONFIG_TCG_ST33_SPI
+		omap_mux_init_signal("mcspi4_clk", OMAP_PIN_INPUT);
+		omap_mux_init_signal("mcspi4_cs0", OMAP_PIN_OUTPUT);
+		omap_mux_init_signal("mcspi4_simo", OMAP_PIN_OUTPUT);
+		omap_mux_init_signal("mcspi4_somi", OMAP_PIN_INPUT);
+
+		spi_register_board_info(tpm_st33_spi_board_info,
+			 ARRAY_SIZE(tpm_st33_spi_board_info));
+	#endif
+
 	pwm_add_table(pwm_lookup, ARRAY_SIZE(pwm_lookup));
 }
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