Skip to contentSkip to conversation

tpm: Add casts for proper compilation

PATCH Superseded Simon Glass 2 participants 11 messages Nov 2, 2012 – Nov 7, 2012

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 drivers/tpm/generic_lpc_tpm.c |   10 +++++-----
 1 files 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.7.7.3
#1 lore raw

PATCH 2/3 tpm: Add Infineon slb9635_i2c TPM driver

From: Rong Chang <[email protected]>

Add a driver for the I2C TPM from Infineon.

---
 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   |  562 +++++++++++++++++++++++++++++++
 drivers/tpm/tis_i2c.c                   |  181 ++++++++++
 include/fdtdec.h                        |    1 +
 lib/fdtdec.c                            |    1 +
 9 files changed, 1415 insertions(+), 1 deletions(-)
 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 2fe1490..5355c33 100644
@@ -313,7 +313,7 @@ LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
 endif
 LIBS-y += drivers/rtc/librtc.o
 LIBS-y += drivers/serial/libserial.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 +562 -0

562 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 0b14075..577b149 100644
@@ -66,6 +66,7 @@ enum fdt_compat_id {
 	COMPAT_NVIDIA_TEGRA20_EMC_TABLE, /* Tegra20 memory timing table */
 	COMPAT_NVIDIA_TEGRA20_KBC,	/* Tegra20 Keyboard */
 	COMPAT_NVIDIA_TEGRA20_NAND,	/* Tegra2 NAND controller */
+	COMPAT_INFINEON_SLB9635_TPM,	/* Infineon SLB9635 TPM */
 
 	COMPAT_COUNT,
 };
lib/fdtdec.c +1 -0
index 4c23f45..3027835 100644
@@ -43,6 +43,7 @@ static const char * const compat_names[COMPAT_COUNT] = {
 	COMPAT(NVIDIA_TEGRA20_EMC_TABLE, "nvidia,tegra20-emc-table"),
 	COMPAT(NVIDIA_TEGRA20_KBC, "nvidia,tegra20-kbc"),
 	COMPAT(NVIDIA_TEGRA20_NAND, "nvidia,tegra20-nand"),
+	COMPAT(INFINEON_SLB9635_TPM, "infineon,slb9635-tpm"),
 };
 
 const char *fdtdec_get_compatible(enum fdt_compat_id id)
Signature · 1 line
1.7.7.3
#2 lore raw

PATCH 2/3 tpm: Add Infineon slb9635_i2c TPM driver

Dear Simon Glass,

Quoted 8 lines · In message <[email protected]> you wrote:

From: Rong Chang <[email protected]>

Add a driver for the I2C TPM from Infineon.

NAK. I will not accept any more additions of such dead code. We added TPM support long ago, based on the assumption/promise that users for it would follow soon. But nothing ever happened.

Instead of adding more such dead code, we should rather completely remove this unused stuff - note that it does not even get compile-tested io any mainline configuration.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A year spent in artificial intelligence is enough to make one believe
in God.
#3 lore raw

PATCH 2/3 tpm: Add Infineon slb9635_i2c TPM driver

Hi Wolfgang,

Quoted 12 lines · Wolfgang Denk

Dear Simon Glass,

Quoted 8 lines · In message <[email protected]> you wrote:

From: Rong Chang <[email protected]>

Add a driver for the I2C TPM from Infineon.

Quoted 7 lines

NAK. I will not accept any more additions of such dead code. We added TPM support long ago, based on the assumption/promise that users for it would follow soon. But nothing ever happened.

Instead of adding more such dead code, we should rather completely remove this unused stuff - note that it does not even get compile-tested io any mainline configuration.

Please see my other message on this. Patches are pending for smdk5250 and chromebook-x86.

Regards,
Simon

Quoted 11 lines

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de A year spent in artificial intelligence is enough to make one believe in God.

#4 lore raw

PATCH 3/3 exynos: Enable I2C TPM for smdk5250

In reply to Simon Glass

This is used on some Exynos 5250 variants. For now, enable it manually until we have CONFIG_OF_CONTROL support.

---
 include/configs/smdk5250.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
include/configs/smdk5250.h +5 -0
index c0f8622..c275a0e 100644
@@ -107,6 +107,11 @@
 #define CONFIG_USB_EHCI_EXYNOS
 #define CONFIG_USB_STORAGE
 
+/* 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.7.7.3
#5 lore raw

PATCH 1/3 tpm: Add casts for proper compilation

In reply to Simon Glass

Dear Simon Glass,

Quoted 10 lines · In message <[email protected]> you wrote:

From: Taylor Hutt <[email protected]>

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

---
 drivers/tpm/generic_lpc_tpm.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

I see little sense in spending work on this code. After all the time, it is still unused and dead code in mainline - there is not a single configuration which actually enables the necessary CONFIG_ options.,

I recommend to remove the whole TPM code instead.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
You are an excellent tactician, Captain. You let your second in  com-
mand attack while you sit and watch for weakness.
	-- Khan Noonian Singh, "Space Seed", stardate 3141.9
#6 lore raw

PATCH 1/3 tpm: Add casts for proper compilation

Hi Wolfgang,

Quoted 14 lines · Wolfgang Denk

Dear Simon Glass,

Quoted 10 lines · In message <[email protected]> you wrote:

From: Taylor Hutt <[email protected]>

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

---
 drivers/tpm/generic_lpc_tpm.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
Quoted 5 lines

I see little sense in spending work on this code. After all the time, it is still unused and dead code in mainline - there is not a single configuration which actually enables the necessary CONFIG_ options.,

I recommend to remove the whole TPM code instead.

It is actually used in the x86 Chromebook, but the patch to enable it never made it to mainline. There was quite a bit of push-back on the x86 side at the time and the person working on it finally had enough :-(

I have recently taken this up again to see if we can get x86 into a better state for newer Intel chips and the latest x86 Chromebooks. The patch to enable the TPM there is:

http://patchwork.ozlabs.org/patch/190813/

The patch to enable on ARM Chromebooks is the third patch in this TPM series:

http://patchwork.ozlabs.org/patch/196596/

I accept that it has sat there for a while without a board config to use it. But I would very much like to keep this code and see no sense in removing it now that it is actually in use.

Regards,
Simon

Quoted 12 lines

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de You are an excellent tactician, Captain. You let your second in com- mand attack while you sit and watch for weakness.
-- Khan Noonian Singh, "Space Seed", stardate 3141.9

#7 lore raw

PATCH 1/3 tpm: Add casts for proper compilation

Dear Simon,

Quoted 8 lines · In message <CAPnjgZ0RV991pa7MeVxr463g-TkKa+rzF8Gn7R0_ZbZnOWOsZg@mail.gmail.com>…
Quoted 2 lines

I recommend to remove the whole TPM code instead.

It is actually used in the x86 Chromebook, but the patch to enable it never made it to mainline. There was quite a bit of push-back on the x86 side at the time and the person working on it finally had enough :-(

Quoted 5 lines

I have recently taken this up again to see if we can get x86 into a better state for newer Intel chips and the latest x86 Chromebooks. The patch to enable the TPM there is:

http://patchwork.ozlabs.org/patch/190813/

I don;t see how this uses it in any way in U-Boot. It still would not even compile most of the code, right?

Quoted 3 lines

I accept that it has sat there for a while without a board config to use it. But I would very much like to keep this code and see no sense in removing it now that it is actually in use.

Feel free to re-add it when there are any real users.

I've posted a removal patch.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
...when fits of creativity run strong, more than  one  programmer  or
writer  has  been  known to abandon the desktop for the more spacious
floor.                                             - Fred Brooks, Jr.
#8 lore raw

PATCH 1/3 tpm: Add casts for proper compilation

Hi Wolfgang,

Quoted 11 lines · Wolfgang Denk

Dear Simon,

Quoted 8 lines · In message <CAPnjgZ0RV991pa7MeVxr463g-TkKa+rzF8Gn7R0_ZbZnOWOsZg@mail.gmail.com>…
Quoted 2 lines

I recommend to remove the whole TPM code instead.

It is actually used in the x86 Chromebook, but the patch to enable it never made it to mainline. There was quite a bit of push-back on the x86 side at the time and the person working on it finally had enough :-(

Quoted 8 lines
Quoted 5 lines

I have recently taken this up again to see if we can get x86 into a better state for newer Intel chips and the latest x86 Chromebooks. The patch to enable the TPM there is:

http://patchwork.ozlabs.org/patch/190813/

I don;t see how this uses it in any way in U-Boot. It still would not even compile most of the code, right?

It compiles the driver which is the main thing. The command can be enabled/disabled as needed. If it helps I can post a patch to enable it.

Quoted 8 lines
Quoted 4 lines

I accept that it has sat there for a while without a board config to use it. But I would very much like to keep this code and see no sense in removing it now that it is actually in use.

Feel free to re-add it when there are any real users.

I've posted a removal patch.

Can you please explain what you mean by 'real users'? Are you looking for an entire verified boot implementation before you will accept the TPM driver?

Regards,
Simon

Quoted 12 lines

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de ...when fits of creativity run strong, more than one programmer or writer has been known to abandon the desktop for the more spacious
floor. - Fred Brooks, Jr.

#9 lore raw

PATCH 1/3 tpm: Add casts for proper compilation

Dear Simon,

Quoted 5 lines · In message <CAPnjgZ2p-Re5Hp13st-Q2CuP49azyZZxwNRZSAfhr_iUSGbNJQ@mail.gmail.com>…
Quoted 5 lines
Quoted 4 lines

I accept that it has sat there for a while without a board config to use it. But I would very much like to keep this code and see no sense in removing it now that it is actually in use.

Quoted 7 lines
Quoted 3 lines

Feel free to re-add it when there are any real users.

I've posted a removal patch.

Can you please explain what you mean by 'real users'? Are you looking for an entire verified boot implementation before you will accept the TPM driver?

What exactly is this driver good for? Which function does it provide that can be used on any board in mainline? It looks to me that it's just sitting there, and does nothing good to anybody.

I don't know if there are any other legitimate uses for a TPM driver in U-Boot, but if there are, none appear to be implemented by any mainline board, so why should we have this driver in mainline?

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
While money can't buy happiness, it certainly lets  you  choose  your
own form of misery.
#10 lore raw

PATCH 1/3 tpm: Add casts for proper compilation

Hi Wolfgang,

Quoted 16 lines · Wolfgang Denk

Dear Simon,

Quoted 5 lines · In message <CAPnjgZ2p-Re5Hp13st-Q2CuP49azyZZxwNRZSAfhr_iUSGbNJQ@mail.gmail.com>…
Quoted 5 lines
Quoted 4 lines

I accept that it has sat there for a while without a board config to use it. But I would very much like to keep this code and see no sense in removing it now that it is actually in use.

Quoted 7 lines
Quoted 3 lines

Feel free to re-add it when there are any real users.

I've posted a removal patch.

Can you please explain what you mean by 'real users'? Are you looking for an entire verified boot implementation before you will accept the TPM driver?

Quoted 7 lines

What exactly is this driver good for? Which function does it provide that can be used on any board in mainline? It looks to me that it's just sitting there, and does nothing good to anybody.

I don't know if there are any other legitimate uses for a TPM driver in U-Boot, but if there are, none appear to be implemented by any mainline board, so why should we have this driver in mainline?

I replied on the other thread - hopefully we can agree a plan to move this forward.

Regards,
Simon

Quoted 11 lines

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de While money can't buy happiness, it certainly lets you choose your own form of misery.