Add i2c TPM driver
cover Add i2c TPM driver
This patchset adds an i2c bus based TPM driver.
Changes in v1:
- Update s-o-b Peter Huewe's email address
- Squash patch #3 into patch #2
Che-Liang Chiou (2):
tpm: Rename generic_lpc_tpm to tpm_tis_lpc
tpm: Add i2c TPM driver
Makefile | 2 +-
README | 18 +-
drivers/tpm/Makefile | 5 +-
drivers/tpm/tpm.c | 457 +++++++++++++++++
drivers/tpm/tpm_private.h | 131 +++++
drivers/tpm/tpm_tis_i2c.c | 584 ++++++++++++++++++++++
drivers/tpm/{generic_lpc_tpm.c => tpm_tis_lpc.c} | 0
7 files changed, 1194 insertions(+), 3 deletions(-)
create mode 100644 drivers/tpm/tpm.c
create mode 100644 drivers/tpm/tpm_private.h
create mode 100644 drivers/tpm/tpm_tis_i2c.c
rename drivers/tpm/{generic_lpc_tpm.c => tpm_tis_lpc.c} (100%)Signature · 1 line
1.7.3.1
PATCH 1/2 tpm: Rename generic_lpc_tpm to tpm_tis_lpc
The new name is more aligned with Linux kernel's naming of TPM driver.
---
Changes in v1:
- Update s-o-b Peter Huewe's email address
Makefile | 2 +-
README | 5 ++++-
drivers/tpm/Makefile | 2 +-
drivers/tpm/{generic_lpc_tpm.c => tpm_tis_lpc.c} | 0
4 files changed, 6 insertions(+), 3 deletions(-)
rename drivers/tpm/{generic_lpc_tpm.c => tpm_tis_lpc.c} (100%)Makefile +1 -1
@@ -277,7 +277,7 @@ LIBS += arch/powerpc/cpu/mpc8xxx/lib8xxx.o endif LIBS += drivers/rtc/librtc.o LIBS += drivers/serial/libserial.o -ifeq ($(CONFIG_GENERIC_LPC_TPM),y) +ifeq ($(CONFIG_TPM),y) LIBS += drivers/tpm/libtpm.o endif LIBS += drivers/twserial/libtws.o
README +4 -1
@@ -1073,7 +1073,10 @@ 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 TPM devices. + + CONFIG_TPM_TIS_LPC Support for generic parallel port TPM devices. Only one device per system is supported at this time.
drivers/tpm/Makefile +1 -1
@@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk LIB := $(obj)libtpm.o -COBJS-$(CONFIG_GENERIC_LPC_TPM) = generic_lpc_tpm.o +COBJS-$(CONFIG_TPM_TIS_LPC) = tpm_tis_lpc.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c)
drivers/tpm/tpm_tis_lpc.c renamed from drivers/tpm/generic_lpc_tpm.c +0 -0
Signature · 1 line
1.7.3.1
PATCH 1/2 tpm: Rename generic_lpc_tpm to tpm_tis_lpc
Dear Che-Liang Chiou,
Quoted 9 lines · In message <[email protected]> you wrote:
The new name is more aligned with Linux kernel's naming of TPM driver.
Signed-off-by Peter Huewe <[email protected]>Signed-off-by Che-Liang Chiou <[email protected]>Acked-by Mike Frysinger <[email protected]>---
Changes in v1:
- Update s-o-b Peter Huewe's email address
Quoted 6 lines
Makefile | 2 +-
README | 5 ++++-
drivers/tpm/Makefile | 2 +-
drivers/tpm/{generic_lpc_tpm.c => tpm_tis_lpc.c} | 0
4 files changed, 6 insertions(+), 3 deletions(-)
rename drivers/tpm/{generic_lpc_tpm.c => tpm_tis_lpc.c} (100%)Does such a change actually make sense?
Should we not rather remove all this dead code again?
Until today there are no users for this code in mainline, and no patches have been submitted that intend to use it.
I think we should scrap this in the next release.
Best regards,
Wolfgang Denk
Signature · 4 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 Drawing on my fine command of language, I said nothing.
PATCH 1/2 tpm: Rename generic_lpc_tpm to tpm_tis_lpc
Quoted 19 lines · Wolfgang Denk
Dear Che-Liang Chiou,
Quoted 9 lines · In message <[email protected]> you wrote:
The new name is more aligned with Linux kernel's naming of TPM driver.
Signed-off-by Peter Huewe <[email protected]>Signed-off-by Che-Liang Chiou <[email protected]>Acked-by Mike Frysinger <[email protected]>---
Changes in v1:
- Update s-o-b Peter Huewe's email addressQuoted 6 lines
?Makefile ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ?2 +- ?README ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ?5 ++++- ?drivers/tpm/Makefile ? ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ?2 +- ?drivers/tpm/{generic_lpc_tpm.c => tpm_tis_lpc.c} | ? ?0?4 files changed, 6 insertions(+), 3 deletions(-) ?rename
drivers/tpm/{generic_lpc_tpm.c=>tpm_tis_lpc.c} (100%)
Quoted 6 lines
Does such a change actually make sense?
Should we not rather remove all this dead code again?
Until today there are no users for this code in mainline, and no patches have been submitted that intend to use it.
Chrome/Chromium OS uses TPM for its secure boot. So I would say it is quite a lot of usage on the critical path of booting.
The code that uses TPM did not send to the mainline because the mainline did not have a TPM driver until very recently.
And, I am still figuring out how to submit the TPM user code. I guess it would be better to organize it in a command-line toolkit so that it can be interleaved in between other commands. What do you think?
Quoted 11 lines
I think we should scrap this in the next release.
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 Drawing on my fine command of language, I said nothing.
PATCH 1/2 tpm: Rename generic_lpc_tpm to tpm_tis_lpc
Dear Che-liang Chiou,
Quoted 8 lines · In message <CANJuy2JQ3nf2MJpxRS-8JgKsiV1ZG2sfcNqDMrKSaqpifuPGHg@mail.gmail.com>…
Quoted 5 lines
Should we not rather remove all this dead code again?
Until today there are no users for this code in mainline, and no patches have been submitted that intend to use it.
Chrome/Chromium OS uses TPM for its secure boot. So I would say it is quite a lot of usage on the critical path of booting.
I do not see any such code in mainline. So for mainline, this is just dead code, i. e. it adds maintenance efforts without benefit for any mainline users.
Quoted 2 lines
The code that uses TPM did not send to the mainline because the mainline did not have a TPM driver until very recently.
Well, the patche shave been submitted long time ago, so I would have expected to see such code soon after. But so far, nothign happened.
Now you are trying to add even more code, with still no users in sight.
Quoted 3 lines
And, I am still figuring out how to submit the TPM user code. I guess it would be better to organize it in a command-line toolkit so that it can be interleaved in between other commands. What do you think?
I don't understand what you mean. Didn't you just write there was code ready to be submitted? So that code is not ready and not intended for 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 Never ascribe to malice that which can adequately be explained by stupidity.
PATCH 1/2 tpm: Rename generic_lpc_tpm to tpm_tis_lpc
Quoted 16 lines · Wolfgang Denk
Dear Che-liang Chiou,
Quoted 8 lines · In message <CANJuy2JQ3nf2MJpxRS-8JgKsiV1ZG2sfcNqDMrKSaqpifuPGHg@mail.gmail.com>…
Quoted 5 lines
Should we not rather remove all this dead code again?
Until today there are no users for this code in mainline, and no patches have been submitted that intend to use it.
Chrome/Chromium OS uses TPM for its secure boot. So I would say it is quite a lot of usage on the critical path of booting.
I do not see any such code in mainline. ?So for mainline, this is just dead code, i. e. it adds maintenance efforts without benefit for any mainline users.
Quoted 8 lines
Quoted 2 lines
The code that uses TPM did not send to the mainline because the mainline did not have a TPM driver until very recently.
Well, the patche shave been submitted long time ago, so I would have expected to see such code soon after. ?But so far, nothign happened.
Now you are trying to add even more code, with still no users in sight.
The board that I test the TPM driver is Seaboard (a tegra2-based board). The config settings enabling TPM are literally pasted as follows. However, I can't submit the confis settings (so that Seaboard would be the first mainline user of the TPM driver) as part of this patchset because the tegra i2c driver is not yet in the mainline and so enabling TPM will break mainline's Seaboard build.
I am 100% certain that tegra i2c driver will be submitted. It just take a few time to polish before sending out for review. And after that I will submit a patch enabling TPM in Seaboard. Would this be sufficient for you?
====
include/configs/seaboard.h +7 -0
@@ -42,6 +42,13 @@#define CONFIG_BOARD_EARLY_INIT_F +/* TPM */ +#define CONFIG_TPM +#define CONFIG_TPM_TIS_I2C +#define CONFIG_TPM_TIS_I2C_BUS_NUMBER 2 +#define CONFIG_TPM_TIS_I2C_SLAVE_ADDRESS 0x20 +#define CONFIG_TPM_TIS_I2C_BURST_LIMITATION 3 +/* SD/MMC */ #define CONFIG_MMC #define CONFIG_GENERIC_MMC
====
Quoted 7 lines
Quoted 3 lines
And, I am still figuring out how to submit the TPM user code. I guess it would be better to organize it in a command-line toolkit so that it can be interleaved in between other commands. What do you think?
I don't understand what you mean. ?Didn't you just write there was code ready to be submitted? ?So that code is not ready and not intended for mainline?
I thought you might be interested in Chrome/Chromium OS secure boot, which is implemented as a single monolithic command, and I guess it would be more interested to you if I break it into smaller sub-commands. Anyway, never mind.
Quoted 10 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 Never ascribe to malice that which can ?adequately ?be ?explained ?by stupidity.
PATCH 1/2 tpm: Rename generic_lpc_tpm to tpm_tis_lpc
Dear Che-liang Chiou,
Quoted 8 lines · In message <CANJuy2JZERkmuSKE4zES3U6oo0MS3WFJFA+Awu0od2Mvbf_cxw@mail.gmail.com>…
The board that I test the TPM driver is Seaboard (a tegra2-based board). The config settings enabling TPM are literally pasted as follows. However, I can't submit the confis settings (so that Seaboard would be the first mainline user of the TPM driver) as part of this patchset because the tegra i2c driver is not yet in the mainline and so enabling TPM will break mainline's Seaboard build.
Quoted 4 lines
I am 100% certain that tegra i2c driver will be submitted. It just take a few time to polish before sending out for review. And after that I will submit a patch enabling TPM in Seaboard. Would this be sufficient for you?
I suggest you submit this all on a single patch series together, then.
Best regards,
Wolfgang Denk
Signature · 4 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 Parkinson's Law: Work expands to fill the time alloted it.
PATCH 1/2 tpm: Rename generic_lpc_tpm to tpm_tis_lpc
Quoted 11 lines · Wolfgang Denk
Dear Che-liang Chiou,
Quoted 8 lines · In message <CANJuy2JZERkmuSKE4zES3U6oo0MS3WFJFA+Awu0od2Mvbf_cxw@mail.gmail.com>…
The board that I test the TPM driver is Seaboard (a tegra2-based board). The config settings enabling TPM are literally pasted as follows. However, I can't submit the confis settings (so that Seaboard would be the first mainline user of the TPM driver) as part of this patchset because the tegra i2c driver is not yet in the mainline and so enabling TPM will break mainline's Seaboard build.
Quoted 6 lines
Quoted 4 lines
I am 100% certain that tegra i2c driver will be submitted. It just take a few time to polish before sending out for review. And after that I will submit a patch enabling TPM in Seaboard. Would this be sufficient for you?
I suggest you submit this all on a single patch series together, then.
Okay.
Quoted 9 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 Parkinson's Law: ?Work expands to fill the time alloted it.
PATCH 2/2 tpm: Add i2c TPM driver
In reply to Che-Liang ChiouPeter Huewe implemented the original driver; this patch only reorganizes the code structure of the driver, and does not make logical changes.
tpm.c implements the interface defined in tpm.h based on underlying LPC or i2C TPM driver. tpm.c and the underlying driver communicate throught tpm_private.h.
This patch is tested on a tegra2-based machine, where the i2c driver is not upstreamed yet.
Note: Merging the LPC driver with tpm.c is left to future patches.
---
Changes in v1:
- Squash patch #3 into patch #2
README | 13 + drivers/tpm/Makefile | 5 +- drivers/tpm/tpm.c | 457 +++++++++++++++++++++++++++++++++++ drivers/tpm/tpm_private.h | 131 ++++++++++ drivers/tpm/tpm_tis_i2c.c | 584 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 1189 insertions(+), 1 deletions(-) create mode 100644 drivers/tpm/tpm.c create mode 100644 drivers/tpm/tpm_private.h create mode 100644 drivers/tpm/tpm_tis_i2c.c
README +13 -0
@@ -1076,6 +1076,19 @@ The following options need to be configured: CONFIG_TPM Support TPM devices. + CONFIG_TPM_TIS_I2C + Support for i2c bus TPM devices. Only one device + per system is supported at this time. + + CONFIG_TPM_TIS_I2C_BUS_NUMBER + Define the the i2c bus number for the TPM device + + CONFIG_TPM_TIS_I2C_SLAVE_ADDRESS + Define the TPM's address on the i2c bus + + CONFIG_TPM_TIS_I2C_BURST_LIMITATION + Define the burst count bytes upper limit + CONFIG_TPM_TIS_LPC Support for generic parallel port TPM devices. Only one device per system is supported at this time.
drivers/tpm/Makefile +4 -1
@@ -23,7 +23,10 @@ include $(TOPDIR)/config.mk LIB := $(obj)libtpm.o -COBJS-$(CONFIG_TPM_TIS_LPC) = tpm_tis_lpc.o +# TODO(clchiou): Merge tpm_tis_lpc.c with tpm.c +COBJS-$(CONFIG_TPM_TIS_I2C) += tpm.o +COBJS-$(CONFIG_TPM_TIS_I2C) += tpm_tis_i2c.o +COBJS-$(CONFIG_TPM_TIS_LPC) += tpm_tis_lpc.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c)
drivers/tpm/tpm.c new file +457 -0
457 lines not on this page · raw message
drivers/tpm/tpm_private.h new file +131 -0
131 lines not on this page · raw message
drivers/tpm/tpm_tis_i2c.c new file +584 -0
584 lines not on this page · raw message
Signature · 1 line
1.7.3.1
PATCH 2/2 tpm: Add i2c TPM driver
drivers/tpm/tpm.c
Quoted 7 lines · On Wednesday 14 December 2011 03:48:24 Che-Liang Chiou wrote:
drivers/tpm/tpm.c new file +1
-0+int tis_sendrecv(const uint8_t *sendbuf, size_t send_size, uint8_t*recvbuf, +
size_t*recv_len)drivers/tpm/tpm.c new file +2
-0+{ +error ("%s: invalid send_size %zx\n" , __func__, send_size);
using __func__ with error() makes no sense as error() already includes that
drivers/tpm/tpm_private.h
Quoted 2 lines
drivers/tpm/tpm_private.h new file +0
-0
this should probably include linux/types.h and linux/compiler.h since it uses __be32 and __packed
drivers/tpm/tpm_tis_i2c.c line 443
Quoted 5 lines
drivers/tpm/tpm_tis_i2c.c new file +2
-0+if (burstcnt > (len-1 -count)) + burstcnt = len-1 -count;
add some spaces around those "-"
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111216/64013648/attachment.pgp>
PATCH 2/2 tpm: Add i2c TPM driver
Quoted 10 lines · Mike Frysinger
Quoted 7 lines · On Wednesday 14 December 2011 03:48:24 Che-Liang Chiou wrote:
drivers/tpm/tpm.c new file +1
-0+int tis_sendrecv(const uint8_t *sendbuf, size_t send_size, uint8_t*recvbuf, + ? ? ? ? ?
size_t*recv_len)
+{
+ ? ? ? ? ? ?error("%s: invalid send_size %zx\n", __func__, send_size);using
__func__witherror()makes no sense aserror()already includes that
Done.
Quoted 5 lines
drivers/tpm/tpm_private.h
Quoted 2 lines
drivers/tpm/tpm_private.h new file +0
-0this should probably include
linux/types.handlinux/compiler.hsince it uses__be32and__packed
Done.
Quoted 7 lines
drivers/tpm/tpm_tis_i2c.c
Quoted 5 lines
drivers/tpm/tpm_tis_i2c.c new file +2
-0+ ? ? ? ? ? ? if (burstcnt > (len-1-count)) + ? ? ? ? ? ? ? ? ? ? burstcnt = len-1-count;add some spaces around those "-"
Done.
Quoted 1 line
-mike
PATCH 2/2 tpm: Add i2c TPM driver
In reply to Che-Liang ChiouDear Che-Liang Chiou,
Quoted 14 lines · In message <[email protected]> you wrote:
Peter Huewe implemented the original driver; this patch only reorganizes the code structure of the driver, and does not make logical changes.
tpm.cimplements the interface defined intpm.hbased on underlying LPC or i2C TPM driver.tpm.cand the underlying driver communicate throughttpm_private.h.This patch is tested on a tegra2-based machine, where the i2c driver is not upstreamed yet.
Note: Merging the LPC driver with
tpm.cis left to future patches.Signed-off-by Peter Huewe <[email protected]>Signed-off-by Che-Liang Chiou <[email protected]>
...
drivers/tpm/tpm.c line 349
Quoted 6 lines
drivers/tpm/tpm.c new file +6
-0+if (ordinal <TPM_MAX_ORDINAL ) + duration_idx = tpm_ordinal_duration[ordinal]; +else if ((ordinal &TPM_PROTECTED_ORDINAL_MASK ) < +TPM_MAX_PROTECTED_ORDINAL ) + duration_idx = tpm_protected_ordinal_duration[ordinal & +TPM_PROTECTED_ORDINAL_MASK ];
Braces needed around multiline statement.
drivers/tpm/tpm.c line 353
Quoted 3 lines
drivers/tpm/tpm.c new file +3
-0+if (duration_idx !=TPM_UNDEFINED ) + duration = chip->vendor.duration[duration_idx]; +if (duration <=0 )
Readability could be improved by inserting a blank line before this one.
...
drivers/tpm/tpm.c line 395
Quoted 3 lines
drivers/tpm/tpm.c new file +3
-0+debug ("%s: waiting for status...\n" , __func__); +u8 status = tpm_chip.vendor.status (&tpm_chip); + if ((status & tpm_chip.vendor.req_complete_mask) ==
Please always seaprate declarations and code by one blank line. Please fix globally.
Best regards,
Wolfgang Denk
Signature · 7 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
Yes, it's a technical challenge, and you have to kind of admire
people who go to the lengths of actually implementing it, but at the
same time you wonder about their IQ...
-- Linus Torvalds in <[email protected]>PATCH 2/2 tpm: Add i2c TPM driver
Quoted 19 lines · Wolfgang Denk
Dear Che-Liang Chiou,
Quoted 14 lines · In message <[email protected]> you wrote:
Peter Huewe implemented the original driver; this patch only reorganizes the code structure of the driver, and does not make logical changes.
tpm.cimplements the interface defined intpm.hbased on underlying LPC or i2C TPM driver. ?tpm.c and the underlying driver communicate throughttpm_private.h.This patch is tested on a tegra2-based machine, where the i2c driver is not upstreamed yet.
Note: Merging the LPC driver with
tpm.cis left to future patches.Signed-off-by Peter Huewe <[email protected]>Signed-off-by Che-Liang Chiou <[email protected]>...
Quoted 8 lines
Quoted 6 lines
+ ? ? if (ordinal <
TPM_MAX_ORDINAL)
+ ? ? ? ? ? ?duration_idx= tpm_ordinal_duration[ordinal];
+ ? ? else if ((ordinal &TPM_PROTECTED_ORDINAL_MASK) <
+ ? ? ? ? ? ? ? ? ? ?TPM_MAX_PROTECTED_ORDINAL)
+ ? ? ? ? ? ?duration_idx= tpm_protected_ordinal_duration[ordinal &
+ ? ? ? ? ? ? ? ? ? ?TPM_PROTECTED_ORDINAL_MASK];Braces needed around multiline statement.
Done.
Quoted 6 lines
Quoted 3 lines
+ ? ? if (
duration_idx!=TPM_UNDEFINED)
+ ? ? ? ? ? ? duration = chip->vendor.duration[duration_idx];
+ ? ? if (duration <= 0)Readability could be improved by inserting a blank line before this one.
Done.
Quoted 7 lines
...
Quoted 3 lines
+ ? ? ? ? ? ?
debug("%s: waiting for status...\n", __func__);
+ ? ? ? ? ? ? u8 status =tpm_chip.vendor.status(&tpm_chip);
+ ? ? ? ? ? ? if ((status & tpm_chip.vendor.req_complete_mask) ==Please always seaprate declarations and code by one blank line. Please fix globally.
Done. I found as many cases as possible, and inserted a few more blank lines. I hope that would increase readability.
Quoted 13 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 Yes, it's a technical challenge, and ?you ?have ?to ?kind ?of ?admire people ?who go to the lengths of actually implementing it, but at the same time you wonder about their IQ...
? ? ? ? -- ?Linus Torvalds in <[email protected]>