TPM: STMicroelectronics u-boot driver I2C
PATCH 1/1 TPM: STMicroelectronics u-boot driver I2C
From: Mathias Leblanc <[email protected]>
* STMicroelectronics version 1.2.0, Copyright (C) 2013
* 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, read the README file and add the correct defines regarding the tpm in the configuration file of your board.
This file is located in include/configs/your_board.h
The driver will be accessible from within uboot terminal.
--- Makefile | 2 +- README | 14 +- common/cmd_tpm.c | 170 +++++++++++- drivers/tpm/Makefile | 1 + drivers/tpm/compatibility.h | 52 ++++ drivers/tpm/tis_i2c.c | 248 +++++++++++++++++ drivers/tpm/tpm.c | 477 ++++++++++++++++++++++++++++++++ drivers/tpm/tpm.h | 170 +++++++++++ drivers/tpm/tpm_i2c_st.c | 599 ++++++++++++++++++++++++++++++++++++++++ include/configs/coreboot.h | 4 +- include/configs/omap3_beagle.h | 8 + include/tpm.h | 17 ++ 12 files changed, 1757 insertions(+), 5 deletions(-) create mode 100644 drivers/tpm/compatibility.h create mode 100644 drivers/tpm/tis_i2c.c create mode 100644 drivers/tpm/tpm.c create mode 100644 drivers/tpm/tpm.h create mode 100644 drivers/tpm/tpm_i2c_st.c
Makefile +1 -1
@@ -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-$(CONFIG_TPM) += 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
README +13 -1
@@ -1201,7 +1201,7 @@ The following options need to be configured: If this option is set, the driver enables cache flush. - TPM Support: - CONFIG_GENERIC_LPC_TPM + CONFIG_TPM Support for generic parallel port TPM devices. Only one device per system is supported at this time.
@@ -1210,6 +1210,18 @@ The following options need to be configured: to. Contemporary x86 systems usually map it at 0xfed40000. + CONFIG_ST_TPM_I2C + Define to compile the ST TPM I2C DRIVER. + + CONFIG_TPM_I2C_BUS + Define the bus number of the board. + + CONFIG_TPM_I2C_ADDR + Define the address of the TPM. + + CONFIG_CMD_TPM + Define to use some TPM u-boot commands. + - USB Support: At the moment only the UHCI host controller is supported (PIP405, MIP405, MPC5200); define
common/cmd_tpm.c +169 -1
178 lines not on this page · raw message
drivers/tpm/Makefile +1 -0
@@ -24,6 +24,7 @@ include $(TOPDIR)/config.mk LIB := $(obj)libtpm.o COBJS-$(CONFIG_GENERIC_LPC_TPM) = generic_lpc_tpm.o +COBJS-$(CONFIG_ST_TPM_I2C) = tis_i2c.o tpm.o tpm_i2c_st.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c)
drivers/tpm/compatibility.h new file +52 -0
52 lines not on this page · raw message
drivers/tpm/tis_i2c.c new file +248 -0
248 lines not on this page · raw message
drivers/tpm/tpm.c new file +477 -0
477 lines not on this page · raw message
drivers/tpm/tpm.h new file +169 -0
169 lines not on this page · raw message
drivers/tpm/tpm_i2c_st.c new file +599 -0
599 lines not on this page · raw message
include/configs/coreboot.h +2 -2
@@ -76,8 +76,8 @@ CONFIG_SYS_SCSI_MAX_LUN)#endif -/* Generic TPM interfaced through LPC bus */ -#define CONFIG_GENERIC_LPC_TPM +/* Generic TPM interfaced through LPC / I2C bus */ +#define CONFIG_TPM #define CONFIG_TPM_TIS_BASE_ADDRESS 0xfed40000/*-----------------------------------------------------------------------
include/configs/omap3_beagle.h +8 -0
@@ -111,6 +111,14 @@#define STATUS_LED_BOOT STATUS_LED_BIT#define STATUS_LED_GREEN STATUS_LED_BIT1 +/* TPM */ +#define CONFIG_CMD_TPM +#define CONFIG_TPM +#define CONFIG_ST_TPM_DEBUG +#define CONFIG_ST_TPM_I2C +#define CONFIG_TPM_I2C_BUS 1 +#define CONFIG_TPM_I2C_ADDR 0x13 +/* Enable Multi Bus support for I2C */ #define CONFIG_I2C_MULTI_BUS 1
include/tpm.h +18 -0
@@ -68,4 +68,21 @@ int tis_close(void);int tis_sendrecv (const uint8_t *sendbuf,size_t send_size,uint8_t *recvbuf,size_t *recv_len); +/* +* tis_sendrecv_hash() +* +* Send the requested data to the TPM for hash in LOC 4 +* and then try to get its response +* +* @sendbuf - buffer of the data to hash +* @send_size size of the data to send +* @recvbuf - memory to save the response to +* @recv_len - pointer to the size of the response buffer +* +* Returns 0 on success (and places the number of response bytes at recv_len) +* or -1 on failure. +*/ +int tis_sendrecv_hash (const uint8_t *sendbuf,size_t send_size, +uint8_t *recvbuf, +size_t *recv_len); +
#endif /* _INCLUDE_TPM_H_ */
Signature · 1 line
1.7.1
PATCH 1/1 TPM: STMicroelectronics u-boot driver I2C
Quoted 5 lines · Mathias leblanc
From: Mathias Leblanc <[email protected]>
* STMicroelectronics version 1.2.0, Copyright (C) 2013
* This is free software, and you are welcome to redistribute it
* under certain conditions.
Just leave these lines out of the commit message.
Quoted 8 lines
This is the driver for TPM chip from ST Microelectronics.
If you have a TPM security chip from STMicroelectronics working with an I2C, read the README file and add the correct defines regarding the tpm in the configuration file of your board.
This file is located ininclude/configs/your_board.hThe driver will be accessible from within uboot terminal.
Please see
http://www.denx.de/wiki/view/U-Boot/Patches#Sending_updated_patch_versions
as this is the 3rd or 4th posting of these changes.
[snip]
common/cmd_tpm.c static int do_tpm_many(cmd_tbl_t *cmdtp, int flag, · line 149
Quoted 10 lines
common/cmd_tpm.c +2
-0@@ -145,10 +145,177 @@ static int do_tpm_many(cmd_tbl_t *cmdtp, int flag,return rv; } +static int do_tpm_hash (cmd_tbl_t *cmdtp,int flag,int argc, +char *const argv[])
checkpatch warning there, please run tools/checkpatch.pl and fix all errors.
Quoted 9 lines
common/cmd_tpm.c +9
-0+u8 startup[] = { +0x00 ,0xc1 , +0x00 ,0x00 ,0x00 ,0x0c , +0x00 ,0x00 ,0x00 ,0x99 , +0x00 ,0x01 + }; + +u8 selftestfull[] = { +0x00 ,0xc1 ,
common/cmd_tpm.c static int do_tpm_many(cmd_tbl_t *cmdtp, int flag, · line 178
Quoted 10 lines
common/cmd_tpm.c +10
-0+0x00 ,0x00 ,0x00 ,0x0a , + 0x00, 0x00, 0x00, 0x50 + }; + +u8 readpcr17[] = { +0x00 ,0xc1 , +0x00 ,0x00 ,0x00 ,0x0e , +0x00 ,0x00 ,0x00 ,0x15 , +0x00 ,0x00 ,0x00 ,0x11 + };
Comment what these are and/or where they come from.
[snip]
common/cmd_tpm.c static int do_tpm_many(cmd_tbl_t *cmdtp, int flag, · line 170
Quoted 2 lines
common/cmd_tpm.c +2
-0+if (! +tis_sendrecv (readpcr17,sizeof (readpcr17), &response, &read_size)) {
Funny place to break the line, split it on the tis_sendrecv params. And fix anything else like this too.
[snip]
Quoted 9 lines
common/cmd_tpm.c +9
-0+u8 startup[] = { +0x00 ,0xc1 , +0x00 ,0x00 ,0x00 ,0x0c , +0x00 ,0x00 ,0x00 ,0x99 , +0x00 ,0x01 + }; +u8 selftestfull[] = { +0x00 ,0xc1 , +0x00 ,0x00 ,0x00 ,0x0a ,
common/cmd_tpm.c static int do_tpm_many(cmd_tbl_t *cmdtp, int flag, · line 284
Quoted 10 lines
common/cmd_tpm.c +10
-0+ 0x00, 0x00, 0x00, 0x50 + }; +u8 getpermflags[] = { +0x00 ,0xc1 , +0x00 ,0x00 ,0x00 ,0x16 , +0x00 ,0x00 ,0x00 ,0x65 , +0x00 ,0x00 ,0x00 ,0x04 , +0x00 ,0x00 ,0x00 ,0x04 , +0x00 ,0x00 ,0x01 ,0x08 + };
startup and selftestfull are the same as before? Shouldn't duplicate them then.
common/cmd_tpm.c static int do_tpm_many(cmd_tbl_t *cmdtp, int flag, · line 289
Quoted 5 lines
common/cmd_tpm.c +5
-0+ + +CHECK (tis_init ()); + +
Too much whitespace around the line.
[snip]
common/cmd_tpm.c static int do_tpm_many(cmd_tbl_t *cmdtp, int flag, · line 196
Quoted 2 lines
common/cmd_tpm.c +2
-0+/* extended error numbers from linux (see errno.h) */ +#define ECANCELED 125/* Operation Canceled */
'#define<space>' please.
common/cmd_tpm.c static int do_tpm_many(cmd_tbl_t *cmdtp, int flag, · line 197
Quoted 1 line
common/cmd_tpm.c +1
-0+#define msleep (t) udelay((t)*1000)
We already have a few msleep compatibility defines. Can you please do a separate prepatch that adds msleep to <common.h> after the extern for udelay?
common/cmd_tpm.c static int do_tpm_many(cmd_tbl_t *cmdtp, int flag, · line 200
Quoted 3 lines
common/cmd_tpm.c +3
-0+ +/* Timer frequency. Corresponds to msec timer resolution*/ +#define HZ 1000
Please use CONFIG_SYS_HZ
Quoted 1 line
common/cmd_tpm.c +1
-0+++ b/drivers/tpm/tis_i2c.c
[snip]
Quoted 2 lines
+ * [backport from https://github.com/theopolis/u-boot-sboot/
+ *blob/master/drivers/tpm/tis_i2c.c]
You're giving the original author credit in the file already, yes? If not, please do, and drop these lines.
common/cmd_tpm.c
Quoted 5 lines
common/cmd_tpm.c +5
-0+/* Define in board config */ +#ifndef CONFIG_TPM_I2C_BUS +#define CONFIG_TPM_I2C_BUS 0 +#define CONFIG_TPM_I2C_ADDR 0 +#endif
No extra indentation.
[snip]
common/cmd_tpm.c
Quoted 3 lines
common/cmd_tpm.c +3
-0+if (i2c_probe (tpm.slave_addr) &&i2c_probe (tpm.slave_addr)) { +debug ( +"%s: fail to probe i2c addr 0x%x\n" , __func__, tpm.slave_addr);
Split after __func__ instead.
drivers/tpm/tpm.c
Quoted 1 line
drivers/tpm/tpm.c +0
-0
[snip]
We have this as drivers/tpm/slb9635_i2c/tpm.c now, so I think we need to be renaming the existing one, same with tpm.h
[snip]
Quoted 1 line
drivers/tpm/tpm_i2c_st.c +0
-0
[snip]
Quoted 10 lines
drivers/tpm/tpm_i2c_st.c +10
-0+/* +* write8_reg +* Send byte to the TIS register according to the ST33ZP24 I2C protocol. +* @param: tpm_register, the tpm tis register where the data should be written +* @param: tpm_data, the tpm_data to write inside the tpm_register +* @param: tpm_size, The length of the data +* @return: Returns zero in case of success else the negative error code. +*/ +static int write8_reg (u8 addr,u8 tpm_register, +u8 *tpm_data,u16 tpm_size)
drivers/tpm/tpm_i2c_st.c line 143
Quoted 10 lines
drivers/tpm/tpm_i2c_st.c +10
-0+{ +u8 data; + data = tpm_register; +memcpy (&(tpm_dev.buf[0 ]), &data,sizeof (data)); +memcpy (&(tpm_dev.buf[0 ])+1 , tpm_data, tpm_size); + +return i2c_write (addr,0 ,0 , &tpm_dev.buf[0 ], + tpm_size +1 ); + +}/* write8_reg() */
Since this is kerneldoc/etc style commenting, it should be /** at the start, yes? And we don't do comments like that at the end of a function. And since it is kerneldoc style, can you do a template for them? See doc/DocBook/ Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130422/ef503703/attachment.pgp>
PATCH 1/1 TPM: STMicroelectronics u-boot driver I2C
In reply to Mathias leblancHi Mathias,
Quoted 6 lines · Mathias leblanc
From: Mathias Leblanc <[email protected]>
* STMicroelectronics version 1.2.0, Copyright (C) 2013
* This is free software, and you are welcome to redistribute it
* under certain conditions.
Quoted 8 lines
This is the driver for TPM chip from ST Microelectronics.
If you have a TPM security chip from STMicroelectronics working with an I2C, read the README file and add the correct defines regarding the tpm in the configuration file of your board.
This file is located ininclude/configs/your_board.hThe driver will be accessible from within uboot terminal.
Please can you take a look at current mainline TPM support?
Also there are some new patches on top of that:
http://patchwork.ozlabs.org/patch/236211/
http://patchwork.ozlabs.org/patch/236212/
http://patchwork.ozlabs.org/patch/236214/
http://patchwork.ozlabs.org/patch/236215/
http://patchwork.ozlabs.org/patch/236213/
Please take a look, and perhaps rebase on top of that?
Thanks for your efforts on this.
Regards,
Simon