Skip to contentSkip to conversation

tpm: Support for new chip type

PATCH In review Marcel Selhorst 2 participants 2 messages Jul 5, 2005 TPM device driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tpm: Support for new chip type

Hello LKML,

this patch supports the Infineon Trusted Platform Module SLD 9630 (TPM 1.1b), which is embedded on Intel-mainboards or in HP/Fujitsu-Siemens/Toshiba-Notebooks. The module fits the interfaces created by IBM and was patched against the latest kernel-snapshot 2.6.13-rc1-mm1.
Further information about this module and a list of supported hardware can be found here: http://www.prosec.rub.de/tpm

Best Regards,
Marcel Selhorst

---

drivers/char/tpm/Kconfig +13 -0
diff -uprN linux-2.6.13-rc1-mm1/drivers/char/tpm/Kconfig linux-2.6.13-rc-mm1-tpm_inf/drivers/char/tpm/Kconfig
@@ -35,5 +35,18 @@ config TCG_ATMEL
 	  will be accessible from within Linux.  To compile this driver
 	  as a module, choose M here; the module will be called tpm_atmel.
 
+config TCG_INFINEON
+	tristate "Infineon Technologies SLD 9630 TPM Interface"
+	depends on TCG_TPM
+	---help---
+	  If you have a TPM security chip from Infineon Technologies
+	  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_infineon.
+	  Further information on this driver and the supported hardware
+	  can be found at http://www.prosec.rub.de/tpm
+	  Note: To get debugging output into the module, you have to enable
+	  CONFIG_DEBUG_KERNEL, CONFIG_DEBUG_INFO and CONFIG_PCI_DEBUG
+
 endmenu
 
drivers/char/tpm/Makefile +1 -0
diff -uprN linux-2.6.13-rc1-mm1/drivers/char/tpm/Makefile linux-2.6.13-rc-mm1-tpm_inf/drivers/char/tpm/Makefile
@@ -4,4 +4,5 @@
 obj-$(CONFIG_TCG_TPM) += tpm.o
 obj-$(CONFIG_TCG_NSC) += tpm_nsc.o
 obj-$(CONFIG_TCG_ATMEL) += tpm_atmel.o
+obj-$(CONFIG_TCG_INFINEON) += tpm_infineon.o
 
drivers/char/tpm/tpm_infineon.c +488 -0

488 lines not on this page · raw message

#1 lore raw
Quoted 2 lines · Marcel Selhorst

this patch supports the Infineon Trusted Platform Module SLD 9630 (TPM 1.1b), which is embedded on Intel-mainboards or in HP/Fujitsu-Siemens/Toshiba-Notebooks.

Please feed it to scripts/Lindent. It will at least place all curly bracers right.

drivers/char/tpm/tpm_infineon.c line 75

Quoted 11 lines
drivers/char/tpm/tpm_infineon.c +6 -0
 
+/* Register */
+enum tpm_register {
 
+/* Command Bits */
+enum tpm_command_bits {
 
+/* Status Bits */
+enum tpm_status_bits {

IMO, useless comments.

Quoted 1 line

+/* Global variable to count the Waiting-Time-Extensions */

Well, we see it's a variable and it's global in this file.

Quoted 1 line

+static int number_of_wtx = 0;

You can also remove " = 0" and make it go to .bss.

drivers/char/tpm/tpm_infineon.c line 106

Quoted 3 lines
drivers/char/tpm/tpm_infineon.c +2 -0
+static int empty_fifo(struct tpm_chip *chip, int clear_wrfifo) {
 
+	int i=0;

Unneeded initialisation.

drivers/char/tpm/tpm_infineon.c line 120

Quoted 1 line
drivers/char/tpm/tpm_infineon.c +1 -0
+	/* Note: The Values which are currently in the FIFO of the TPM

values

drivers/char/tpm/tpm_infineon.c line 122

Quoted 2 lines
drivers/char/tpm/tpm_infineon.c +2 -0
+	are thrown away since there is no usage for them. Usually,
+	this has nothing to say, since the TPM will give its answer immidiately

immediately

drivers/char/tpm/tpm_infineon.c

Quoted 1 line
drivers/char/tpm/tpm_infineon.c +1 -0
+	return(0);

return 0;

drivers/char/tpm/tpm_infineon.c line 141

Quoted 3 lines
drivers/char/tpm/tpm_infineon.c +2 -0
+static int wait(struct tpm_chip *chip, int wait_for_bit) {
 
+  int i = 0;

Unneeded initialisation.

Quoted 1 line

+ for (i = 0; i < TPM_MAX_TRIES; i++) { /* Check the TPM_TIMEOUT-Variable in the definitions in Infineon.h */

There is no Infineon.h

Quoted 1 line

+ return(0);

return 0; everywhere, please.

drivers/char/tpm/tpm_infineon.c line 237

Quoted 3 lines
drivers/char/tpm/tpm_infineon.c +2 -0
+static int tpm_inf_recv(struct tpm_chip *chip, u8 *buf, size_t count) {
 
+	    return (size);

return size;

drivers/char/tpm/tpm_infineon.c line 337

Quoted 2 lines
drivers/char/tpm/tpm_infineon.c +2 -0
+static struct attribute * inf_attrs[] = {
+	0,

NULL

Quoted 1 line

+int __init tpm_inf_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id) {

static

drivers/char/tpm/tpm_infineon.c line 433

Quoted 10 lines
drivers/char/tpm/tpm_infineon.c +10 -0
+	    /* Finally, we're done, print some infos */	
+	    dev_info(&pci_dev->dev,"************************************************\n");
+	    dev_info(&pci_dev->dev,"*    TPM found with IO-Base 0x%x             *\n",tpm_inf.base);
+	    dev_info(&pci_dev->dev,"*    Chip    ID %02x%02x                           *\n",version[0], version[1]);
+	    dev_info(&pci_dev->dev,"*    Vendor  ID %x%x (Infineon)                *\n",vendor[0], vendor[1]);
+	    if ((vendor[2] == 0) && (vendor[3] == 6))
+		dev_info(&pci_dev->dev,"*    Product ID %02x%02x (SLD 9630 TT 1.1)         *\n",vendor[2],vendor[3]);
+	    else
+		dev_info(&pci_dev->dev,"*    Product ID %02x%02x                           *\n",vendor[2],vendor[3]);
+	    dev_info(&pci_dev->dev,"************************************************\n");

Remove this silly banner.

	dev_info(&pci_dev->dev, ": TPM found: "
				"io base 0x%x, "
				"chip id %02x%02x, "
				"vendor id %x%x (Infineon), "
				"product id %02x%02x"
				"%s\n",
		tpm_inf.base,
		version[0], version[1],
		vendor[0], vendor[1],
		vendor[2],vendor[3],
		((vendor[2] == 0) && (vendor[3] == 6)) ? " (SLD 9630 TT 1.1)" : "");

should be enough. BTW, care to explain why something called "chip id" is in something called "version" and something called "product id" in in something called "vendor"?

drivers/char/tpm/tpm_infineon.c line 435

Quoted 1 line
drivers/char/tpm/tpm_infineon.c +1 -0
+	    /* Let's register our hardware */

Useless comment.

drivers/char/tpm/tpm_infineon.c line 436

Quoted 1 line
drivers/char/tpm/tpm_infineon.c +1 -0
+	    dev_dbg(&pci_dev->dev,"Registering TPM-Infineon-Driver: %x\n",rc);	

Will always print 0. Could you please also remove Studly Caps from debug, info and error messages?

drivers/char/tpm/tpm_infineon.c line 445

Quoted 9 lines
drivers/char/tpm/tpm_infineon.c +9 -0
+	    rc = tpm_register_hardware(pci_dev, &tpm_inf);	
+	    if (rc < 0) {
+		pci_disable_device(pci_dev);
+		return -ENODEV;
+	    }
+	    return 0;
+
+	} else {
+	    dev_err(&pci_dev->dev,": No Infineon TPM found! Sorry! \n");

Trailing space. Why be sorry? :-)

Quoted 1 line

+MODULE_AUTHOR("Marcel Selhorst ([email protected])");

People usually enclose emails in <>.