Skip to contentSkip to conversation

tpm: Add casts for proper compilation

PATCH New Simon Glass 1 participant 3 messages Apr 12, 2013

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

PATCH v2 1/3 tpm: Add casts for proper compilation

From: Taylor Hutt <[email protected]>

When building for the Sandbox version, the casts in this change are necessary to avoid compilation issues.

---
Changes in v2: None

 drivers/tpm/generic_lpc_tpm.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/tpm/generic_lpc_tpm.c +5 -5
index 6c494eb..04ad418 100644
@@ -135,7 +135,7 @@ static u8 tpm_read_byte(const u8 *ptr)
 {
 	u8  ret = readb(ptr);
 	debug(PREFIX "Read reg 0x%4.4x returns 0x%2.2x\n",
-	      (u32)ptr - (u32)lpc_tpm_dev, ret);
+	      (u32)(uintptr_t)ptr - (u32)(uintptr_t)lpc_tpm_dev, ret);
 	return ret;
 }
 
@@ -143,21 +143,21 @@ static u32 tpm_read_word(const u32 *ptr)
 {
 	u32  ret = readl(ptr);
 	debug(PREFIX "Read reg 0x%4.4x returns 0x%8.8x\n",
-	      (u32)ptr - (u32)lpc_tpm_dev, ret);
+	      (u32)(uintptr_t)ptr - (u32)(uintptr_t)lpc_tpm_dev, ret);
 	return ret;
 }
 
 static void tpm_write_byte(u8 value, u8 *ptr)
 {
 	debug(PREFIX "Write reg 0x%4.4x with 0x%2.2x\n",
-	      (u32)ptr - (u32)lpc_tpm_dev, value);
+	      (u32)(uintptr_t)ptr - (u32)(uintptr_t)lpc_tpm_dev, value);
 	writeb(value, ptr);
 }
 
 static void tpm_write_word(u32 value, u32 *ptr)
 {
 	debug(PREFIX "Write reg 0x%4.4x with 0x%8.8x\n",
-	      (u32)ptr - (u32)lpc_tpm_dev, value);
+	      (u32)(uintptr_t)ptr - (u32)(uintptr_t)lpc_tpm_dev, value);
 	writel(value, ptr);
 }
 
@@ -491,5 +491,5 @@ int tis_sendrecv(const u8 *sendbuf, size_t send_size,
 		return TPM_DRIVER_ERR;
 	}
 
-	return tis_readresponse(recvbuf, recv_len);
+	return tis_readresponse(recvbuf, (u32 *)recv_len);
 }
Signature · 1 line
1.8.1.3
#1 lore raw

PATCH v2 2/3 tpm: Add Infineon slb9635_i2c TPM driver

From: Rong Chang <[email protected]>

Add a driver for the I2C TPM from Infineon.

---
Changes in v2:
- Tidy up new checkpatch warnings
- Use udelay() instead of usleep()
- Use new form of i2c_get_bus_num_fdt()

 Makefile                                |   2 +-
 drivers/tpm/Makefile                    |   4 +
 drivers/tpm/slb9635_i2c/compatibility.h |  51 +++
 drivers/tpm/slb9635_i2c/tpm.c           | 453 ++++++++++++++++++++++++++
 drivers/tpm/slb9635_i2c/tpm.h           | 161 +++++++++
 drivers/tpm/slb9635_i2c/tpm_tis_i2c.c   | 561 ++++++++++++++++++++++++++++++++
 drivers/tpm/tis_i2c.c                   | 181 +++++++++++
 include/fdtdec.h                        |   1 +
 lib/fdtdec.c                            |   1 +
 9 files changed, 1414 insertions(+), 1 deletion(-)
 create mode 100644 drivers/tpm/slb9635_i2c/compatibility.h
 create mode 100644 drivers/tpm/slb9635_i2c/tpm.c
 create mode 100644 drivers/tpm/slb9635_i2c/tpm.h
 create mode 100644 drivers/tpm/slb9635_i2c/tpm_tis_i2c.c
 create mode 100644 drivers/tpm/tis_i2c.c
Makefile +1 -1
index db7561c..6547bc0 100644
@@ -314,7 +314,7 @@ endif
 LIBS-y += drivers/rtc/librtc.o
 LIBS-y += drivers/serial/libserial.o
 LIBS-y += drivers/sound/libsound.o
-LIBS-$(CONFIG_GENERIC_LPC_TPM) += drivers/tpm/libtpm.o
+LIBS-y += drivers/tpm/libtpm.o
 LIBS-y += drivers/twserial/libtws.o
 LIBS-y += drivers/usb/eth/libusb_eth.o
 LIBS-y += drivers/usb/gadget/libusb_gadget.o
drivers/tpm/Makefile +4 -0
index be11c8b..e8c159c 100644
@@ -23,7 +23,11 @@ include $(TOPDIR)/config.mk
 
 LIB := $(obj)libtpm.o
 
+$(shell mkdir -p $(obj)slb9635_i2c)
+
 COBJS-$(CONFIG_GENERIC_LPC_TPM) = generic_lpc_tpm.o
+COBJS-$(CONFIG_INFINEON_TPM_I2C) += tis_i2c.o slb9635_i2c/tpm.o
+COBJS-$(CONFIG_INFINEON_TPM_I2C) += slb9635_i2c/tpm_tis_i2c.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
drivers/tpm/slb9635_i2c/compatibility.h new file +51 -0

51 lines not on this page · raw message

drivers/tpm/slb9635_i2c/tpm.c new file +453 -0

453 lines not on this page · raw message

drivers/tpm/slb9635_i2c/tpm.h new file +161 -0

161 lines not on this page · raw message

drivers/tpm/slb9635_i2c/tpm_tis_i2c.c new file +561 -0

561 lines not on this page · raw message

drivers/tpm/tis_i2c.c new file +181 -0

181 lines not on this page · raw message

include/fdtdec.h +1 -0
index e7e3ff9..39fbdf1 100644
@@ -90,6 +90,7 @@ enum fdt_compat_id {
 	COMPAT_MAXIM_MAX77686_PMIC,	/* MAX77686 PMIC */
 	COMPAT_GENERIC_SPI_FLASH,	/* Generic SPI Flash chip */
 	COMPAT_MAXIM_98095_CODEC,	/* MAX98095 Codec */
+	COMPAT_INFINEON_SLB9635_TPM,	/* Infineon SLB9635 TPM */
 
 	COMPAT_COUNT,
 };
lib/fdtdec.c +1 -0
index e17dd00..e93743c 100644
@@ -63,6 +63,7 @@ static const char * const compat_names[COMPAT_COUNT] = {
 	COMPAT(MAXIM_MAX77686_PMIC, "maxim,max77686_pmic"),
 	COMPAT(GENERIC_SPI_FLASH, "spi-flash"),
 	COMPAT(MAXIM_98095_CODEC, "maxim,max98095-codec"),
+	COMPAT(INFINEON_SLB9635_TPM, "infineon,slb9635-tpm"),
 };
 
 const char *fdtdec_get_compatible(enum fdt_compat_id id)
Signature · 1 line
1.8.1.3
#2 lore raw

PATCH v2 3/3 exynos: Enable I2C TPM for smdk5250

In reply to Simon Glass

This is used on some Exynos 5250 variants.

---
Changes in v2:
- Move CONFIG change to exynos5-dt.h

 include/configs/exynos5250-dt.h | 7 +++++++
 1 file changed, 7 insertions(+)
include/configs/exynos5250-dt.h +7 -0
index 2b9d6ac..7378487 100644
@@ -129,6 +129,13 @@
 #define CONFIG_USB_EHCI_EXYNOS
 #define CONFIG_USB_STORAGE
 
+/* TPM */
+#define CONFIG_TPM
+#define CONFIG_CMD_TPM
+#define CONFIG_INFINEON_TPM_I2C
+#define CONFIG_INFINEON_TPM_I2C_BUS 3
+#define CONFIG_INFINEON_TPM_I2C_ADDR 0x20
+
 /* MMC SPL */
 #define CONFIG_SPL
 #define COPY_BL2_FNPTR_ADDR	0x02020030
Signature · 1 line
1.8.1.3