diff options
author | Marcel Selhorst <selhorst@crypto.rub.de> | 2006-04-22 05:38:42 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-04-22 12:19:54 -0400 |
commit | e496f540540f0a0bffcc3f83785f9954dacf1b83 (patch) | |
tree | 92cc03c00665c9f1f69d5ba29e53aab04196ffff /drivers/char | |
parent | 10685a95301d02fde2b10f6047e405c69d2af82a (diff) |
[PATCH] tpm: tpm_infineon updated to latest interface changes
Apply the latest changes in the TPM interface to the Infineon TPM-driver.
Signed-off-by: Marcel Selhorst <selhorst@crypto.rub.de>
Acked-by: Kylie Hall <kjhall@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/tpm/tpm_infineon.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c index 24095f6ee6da..90cae8f9fe21 100644 --- a/drivers/char/tpm/tpm_infineon.c +++ b/drivers/char/tpm/tpm_infineon.c | |||
@@ -104,7 +104,7 @@ static int empty_fifo(struct tpm_chip *chip, int clear_wrfifo) | |||
104 | 104 | ||
105 | if (clear_wrfifo) { | 105 | if (clear_wrfifo) { |
106 | for (i = 0; i < 4096; i++) { | 106 | for (i = 0; i < 4096; i++) { |
107 | status = inb(chip->vendor->base + WRFIFO); | 107 | status = inb(chip->vendor.base + WRFIFO); |
108 | if (status == 0xff) { | 108 | if (status == 0xff) { |
109 | if (check == 5) | 109 | if (check == 5) |
110 | break; | 110 | break; |
@@ -124,8 +124,8 @@ static int empty_fifo(struct tpm_chip *chip, int clear_wrfifo) | |||
124 | */ | 124 | */ |
125 | i = 0; | 125 | i = 0; |
126 | do { | 126 | do { |
127 | status = inb(chip->vendor->base + RDFIFO); | 127 | status = inb(chip->vendor.base + RDFIFO); |
128 | status = inb(chip->vendor->base + STAT); | 128 | status = inb(chip->vendor.base + STAT); |
129 | i++; | 129 | i++; |
130 | if (i == TPM_MAX_TRIES) | 130 | if (i == TPM_MAX_TRIES) |
131 | return -EIO; | 131 | return -EIO; |
@@ -138,7 +138,7 @@ static int wait(struct tpm_chip *chip, int wait_for_bit) | |||
138 | int status; | 138 | int status; |
139 | int i; | 139 | int i; |
140 | for (i = 0; i < TPM_MAX_TRIES; i++) { | 140 | for (i = 0; i < TPM_MAX_TRIES; i++) { |
141 | status = inb(chip->vendor->base + STAT); | 141 | status = inb(chip->vendor.base + STAT); |
142 | /* check the status-register if wait_for_bit is set */ | 142 | /* check the status-register if wait_for_bit is set */ |
143 | if (status & 1 << wait_for_bit) | 143 | if (status & 1 << wait_for_bit) |
144 | break; | 144 | break; |
@@ -157,7 +157,7 @@ static int wait(struct tpm_chip *chip, int wait_for_bit) | |||
157 | static void wait_and_send(struct tpm_chip *chip, u8 sendbyte) | 157 | static void wait_and_send(struct tpm_chip *chip, u8 sendbyte) |
158 | { | 158 | { |
159 | wait(chip, STAT_XFE); | 159 | wait(chip, STAT_XFE); |
160 | outb(sendbyte, chip->vendor->base + WRFIFO); | 160 | outb(sendbyte, chip->vendor.base + WRFIFO); |
161 | } | 161 | } |
162 | 162 | ||
163 | /* Note: WTX means Waiting-Time-Extension. Whenever the TPM needs more | 163 | /* Note: WTX means Waiting-Time-Extension. Whenever the TPM needs more |
@@ -204,7 +204,7 @@ recv_begin: | |||
204 | ret = wait(chip, STAT_RDA); | 204 | ret = wait(chip, STAT_RDA); |
205 | if (ret) | 205 | if (ret) |
206 | return -EIO; | 206 | return -EIO; |
207 | buf[i] = inb(chip->vendor->base + RDFIFO); | 207 | buf[i] = inb(chip->vendor.base + RDFIFO); |
208 | } | 208 | } |
209 | 209 | ||
210 | if (buf[0] != TPM_VL_VER) { | 210 | if (buf[0] != TPM_VL_VER) { |
@@ -219,7 +219,7 @@ recv_begin: | |||
219 | 219 | ||
220 | for (i = 0; i < size; i++) { | 220 | for (i = 0; i < size; i++) { |
221 | wait(chip, STAT_RDA); | 221 | wait(chip, STAT_RDA); |
222 | buf[i] = inb(chip->vendor->base + RDFIFO); | 222 | buf[i] = inb(chip->vendor.base + RDFIFO); |
223 | } | 223 | } |
224 | 224 | ||
225 | if ((size == 0x6D00) && (buf[1] == 0x80)) { | 225 | if ((size == 0x6D00) && (buf[1] == 0x80)) { |
@@ -268,7 +268,7 @@ static int tpm_inf_send(struct tpm_chip *chip, u8 * buf, size_t count) | |||
268 | u8 count_high, count_low, count_4, count_3, count_2, count_1; | 268 | u8 count_high, count_low, count_4, count_3, count_2, count_1; |
269 | 269 | ||
270 | /* Disabling Reset, LP and IRQC */ | 270 | /* Disabling Reset, LP and IRQC */ |
271 | outb(RESET_LP_IRQC_DISABLE, chip->vendor->base + CMD); | 271 | outb(RESET_LP_IRQC_DISABLE, chip->vendor.base + CMD); |
272 | 272 | ||
273 | ret = empty_fifo(chip, 1); | 273 | ret = empty_fifo(chip, 1); |
274 | if (ret) { | 274 | if (ret) { |
@@ -319,7 +319,7 @@ static void tpm_inf_cancel(struct tpm_chip *chip) | |||
319 | 319 | ||
320 | static u8 tpm_inf_status(struct tpm_chip *chip) | 320 | static u8 tpm_inf_status(struct tpm_chip *chip) |
321 | { | 321 | { |
322 | return inb(chip->vendor->base + STAT); | 322 | return inb(chip->vendor.base + STAT); |
323 | } | 323 | } |
324 | 324 | ||
325 | static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL); | 325 | static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL); |
@@ -346,7 +346,7 @@ static struct file_operations inf_ops = { | |||
346 | .release = tpm_release, | 346 | .release = tpm_release, |
347 | }; | 347 | }; |
348 | 348 | ||
349 | static struct tpm_vendor_specific tpm_inf = { | 349 | static const struct tpm_vendor_specific tpm_inf = { |
350 | .recv = tpm_inf_recv, | 350 | .recv = tpm_inf_recv, |
351 | .send = tpm_inf_send, | 351 | .send = tpm_inf_send, |
352 | .cancel = tpm_inf_cancel, | 352 | .cancel = tpm_inf_cancel, |
@@ -375,6 +375,7 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev, | |||
375 | int version[2]; | 375 | int version[2]; |
376 | int productid[2]; | 376 | int productid[2]; |
377 | char chipname[20]; | 377 | char chipname[20]; |
378 | struct tpm_chip *chip; | ||
378 | 379 | ||
379 | /* read IO-ports through PnP */ | 380 | /* read IO-ports through PnP */ |
380 | if (pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && | 381 | if (pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && |
@@ -395,14 +396,13 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev, | |||
395 | goto err_last; | 396 | goto err_last; |
396 | } | 397 | } |
397 | /* publish my base address and request region */ | 398 | /* publish my base address and request region */ |
398 | tpm_inf.base = TPM_INF_BASE; | ||
399 | if (request_region | 399 | if (request_region |
400 | (tpm_inf.base, TPM_INF_PORT_LEN, "tpm_infineon0") == NULL) { | 400 | (TPM_INF_BASE, TPM_INF_PORT_LEN, "tpm_infineon0") == NULL) { |
401 | rc = -EINVAL; | 401 | rc = -EINVAL; |
402 | goto err_last; | 402 | goto err_last; |
403 | } | 403 | } |
404 | if (request_region(TPM_INF_ADDR, TPM_INF_ADDR_LEN, | 404 | if (request_region |
405 | "tpm_infineon0") == NULL) { | 405 | (TPM_INF_ADDR, TPM_INF_ADDR_LEN, "tpm_infineon0") == NULL) { |
406 | rc = -EINVAL; | 406 | rc = -EINVAL; |
407 | goto err_last; | 407 | goto err_last; |
408 | } | 408 | } |
@@ -442,9 +442,9 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev, | |||
442 | 442 | ||
443 | /* configure TPM with IO-ports */ | 443 | /* configure TPM with IO-ports */ |
444 | outb(IOLIMH, TPM_INF_ADDR); | 444 | outb(IOLIMH, TPM_INF_ADDR); |
445 | outb(((tpm_inf.base >> 8) & 0xff), TPM_INF_DATA); | 445 | outb(((TPM_INF_BASE >> 8) & 0xff), TPM_INF_DATA); |
446 | outb(IOLIML, TPM_INF_ADDR); | 446 | outb(IOLIML, TPM_INF_ADDR); |
447 | outb((tpm_inf.base & 0xff), TPM_INF_DATA); | 447 | outb((TPM_INF_BASE & 0xff), TPM_INF_DATA); |
448 | 448 | ||
449 | /* control if IO-ports are set correctly */ | 449 | /* control if IO-ports are set correctly */ |
450 | outb(IOLIMH, TPM_INF_ADDR); | 450 | outb(IOLIMH, TPM_INF_ADDR); |
@@ -452,10 +452,10 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev, | |||
452 | outb(IOLIML, TPM_INF_ADDR); | 452 | outb(IOLIML, TPM_INF_ADDR); |
453 | iol = inb(TPM_INF_DATA); | 453 | iol = inb(TPM_INF_DATA); |
454 | 454 | ||
455 | if ((ioh << 8 | iol) != tpm_inf.base) { | 455 | if ((ioh << 8 | iol) != TPM_INF_BASE) { |
456 | dev_err(&dev->dev, | 456 | dev_err(&dev->dev, |
457 | "Could not set IO-ports to 0x%lx\n", | 457 | "Could not set IO-ports to 0x%x\n", |
458 | tpm_inf.base); | 458 | TPM_INF_BASE); |
459 | rc = -EIO; | 459 | rc = -EIO; |
460 | goto err_release_region; | 460 | goto err_release_region; |
461 | } | 461 | } |
@@ -466,15 +466,15 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev, | |||
466 | outb(DISABLE_REGISTER_PAIR, TPM_INF_ADDR); | 466 | outb(DISABLE_REGISTER_PAIR, TPM_INF_ADDR); |
467 | 467 | ||
468 | /* disable RESET, LP and IRQC */ | 468 | /* disable RESET, LP and IRQC */ |
469 | outb(RESET_LP_IRQC_DISABLE, tpm_inf.base + CMD); | 469 | outb(RESET_LP_IRQC_DISABLE, TPM_INF_BASE + CMD); |
470 | 470 | ||
471 | /* Finally, we're done, print some infos */ | 471 | /* Finally, we're done, print some infos */ |
472 | dev_info(&dev->dev, "TPM found: " | 472 | dev_info(&dev->dev, "TPM found: " |
473 | "config base 0x%x, " | 473 | "config base 0x%x, " |
474 | "io base 0x%x, " | 474 | "io base 0x%x, " |
475 | "chip version %02x%02x, " | 475 | "chip version 0x%02x%02x, " |
476 | "vendor id %x%x (Infineon), " | 476 | "vendor id 0x%x%x (Infineon), " |
477 | "product id %02x%02x" | 477 | "product id 0x%02x%02x" |
478 | "%s\n", | 478 | "%s\n", |
479 | TPM_INF_ADDR, | 479 | TPM_INF_ADDR, |
480 | TPM_INF_BASE, | 480 | TPM_INF_BASE, |
@@ -482,11 +482,10 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev, | |||
482 | vendorid[0], vendorid[1], | 482 | vendorid[0], vendorid[1], |
483 | productid[0], productid[1], chipname); | 483 | productid[0], productid[1], chipname); |
484 | 484 | ||
485 | rc = tpm_register_hardware(&dev->dev, &tpm_inf); | 485 | if (!(chip = tpm_register_hardware(&dev->dev, &tpm_inf))) { |
486 | if (rc < 0) { | ||
487 | rc = -ENODEV; | ||
488 | goto err_release_region; | 486 | goto err_release_region; |
489 | } | 487 | } |
488 | chip->vendor.base = TPM_INF_BASE; | ||
490 | return 0; | 489 | return 0; |
491 | } else { | 490 | } else { |
492 | rc = -ENODEV; | 491 | rc = -ENODEV; |
@@ -494,7 +493,7 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev, | |||
494 | } | 493 | } |
495 | 494 | ||
496 | err_release_region: | 495 | err_release_region: |
497 | release_region(tpm_inf.base, TPM_INF_PORT_LEN); | 496 | release_region(TPM_INF_BASE, TPM_INF_PORT_LEN); |
498 | release_region(TPM_INF_ADDR, TPM_INF_ADDR_LEN); | 497 | release_region(TPM_INF_ADDR, TPM_INF_ADDR_LEN); |
499 | 498 | ||
500 | err_last: | 499 | err_last: |
@@ -506,7 +505,8 @@ static __devexit void tpm_inf_pnp_remove(struct pnp_dev *dev) | |||
506 | struct tpm_chip *chip = pnp_get_drvdata(dev); | 505 | struct tpm_chip *chip = pnp_get_drvdata(dev); |
507 | 506 | ||
508 | if (chip) { | 507 | if (chip) { |
509 | release_region(chip->vendor->base, TPM_INF_PORT_LEN); | 508 | release_region(TPM_INF_BASE, TPM_INF_PORT_LEN); |
509 | release_region(TPM_INF_ADDR, TPM_INF_ADDR_LEN); | ||
510 | tpm_remove_hardware(chip->dev); | 510 | tpm_remove_hardware(chip->dev); |
511 | } | 511 | } |
512 | } | 512 | } |
@@ -538,5 +538,5 @@ module_exit(cleanup_inf); | |||
538 | 538 | ||
539 | MODULE_AUTHOR("Marcel Selhorst <selhorst@crypto.rub.de>"); | 539 | MODULE_AUTHOR("Marcel Selhorst <selhorst@crypto.rub.de>"); |
540 | MODULE_DESCRIPTION("Driver for Infineon TPM SLD 9630 TT 1.1 / SLB 9635 TT 1.2"); | 540 | MODULE_DESCRIPTION("Driver for Infineon TPM SLD 9630 TT 1.1 / SLB 9635 TT 1.2"); |
541 | MODULE_VERSION("1.7"); | 541 | MODULE_VERSION("1.8"); |
542 | MODULE_LICENSE("GPL"); | 542 | MODULE_LICENSE("GPL"); |