Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'tpmdd-next-6.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd

Pull TPM updates from Jarkko Sakkinen:
"Only some minor tweaks"

* tag 'tpmdd-next-6.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd:
tpm: atmel: Drop PPC64 specific MMIO setup
char: tpm: cr50: Add new device/vendor ID 0x50666666
char: tpm: cr50: Move i2c locking to request/relinquish locality ops
char: tpm: cr50: Use generic request/relinquish locality ops
tpm: ibmvtpm: Set TPM_OPS_AUTO_STARTUP flag on driver

+167 -222
+1 -1
drivers/char/tpm/Kconfig
··· 162 162 163 163 config TCG_ATMEL 164 164 tristate "Atmel TPM Interface" 165 - depends on PPC64 || HAS_IOPORT_MAP 165 + depends on HAS_IOPORT_MAP 166 166 depends on HAS_IOPORT 167 167 help 168 168 If you have a TPM security chip from Atmel say Yes and it
-1
drivers/char/tpm/tpm2-sessions.c
··· 1390 1390 1391 1391 return rc; 1392 1392 } 1393 - EXPORT_SYMBOL(tpm2_sessions_init); 1394 1393 #endif /* CONFIG_TCG_TPM2_HMAC */
+60 -3
drivers/char/tpm/tpm_atmel.c
··· 15 15 */ 16 16 17 17 #include "tpm.h" 18 - #include "tpm_atmel.h" 18 + 19 + struct tpm_atmel_priv { 20 + int region_size; 21 + int have_region; 22 + unsigned long base; 23 + void __iomem *iobase; 24 + }; 25 + 26 + #define atmel_getb(chip, offset) inb(atmel_get_priv(chip)->base + (offset)) 27 + #define atmel_putb(val, chip, offset) \ 28 + outb(val, atmel_get_priv(chip)->base + (offset)) 29 + #define atmel_request_region request_region 30 + #define atmel_release_region release_region 31 + /* Atmel definitions */ 32 + enum tpm_atmel_addr { 33 + TPM_ATMEL_BASE_ADDR_LO = 0x08, 34 + TPM_ATMEL_BASE_ADDR_HI = 0x09 35 + }; 36 + 37 + static inline int tpm_read_index(int base, int index) 38 + { 39 + outb(index, base); 40 + return inb(base + 1) & 0xFF; 41 + } 42 + 43 + /* Verify this is a 1.1 Atmel TPM */ 44 + static int atmel_verify_tpm11(void) 45 + { 46 + /* verify that it is an Atmel part */ 47 + if (tpm_read_index(TPM_ADDR, 4) != 'A' || 48 + tpm_read_index(TPM_ADDR, 5) != 'T' || 49 + tpm_read_index(TPM_ADDR, 6) != 'M' || 50 + tpm_read_index(TPM_ADDR, 7) != 'L') 51 + return 1; 52 + 53 + /* query chip for its version number */ 54 + if (tpm_read_index(TPM_ADDR, 0x00) != 1 || 55 + tpm_read_index(TPM_ADDR, 0x01) != 1) 56 + return 1; 57 + 58 + /* This is an atmel supported part */ 59 + return 0; 60 + } 61 + 62 + /* Determine where to talk to device */ 63 + static void __iomem *atmel_get_base_addr(unsigned long *base, int *region_size) 64 + { 65 + int lo, hi; 66 + 67 + if (atmel_verify_tpm11() != 0) 68 + return NULL; 69 + 70 + lo = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_LO); 71 + hi = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_HI); 72 + 73 + *base = (hi << 8) | lo; 74 + *region_size = 2; 75 + 76 + return ioport_map(*base, *region_size); 77 + } 19 78 20 79 /* write status bits */ 21 80 enum tpm_atmel_write_status { ··· 201 142 tpm_chip_unregister(chip); 202 143 if (priv->have_region) 203 144 atmel_release_region(priv->base, priv->region_size); 204 - atmel_put_base_addr(priv->iobase); 205 145 platform_device_unregister(pdev); 206 146 } 207 147 ··· 269 211 err_unreg_dev: 270 212 platform_device_unregister(pdev); 271 213 err_rel_reg: 272 - atmel_put_base_addr(iobase); 273 214 if (have_region) 274 215 atmel_release_region(base, 275 216 region_size);
-140
drivers/char/tpm/tpm_atmel.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-only */ 2 - /* 3 - * Copyright (C) 2005 IBM Corporation 4 - * 5 - * Authors: 6 - * Kylene Hall <kjhall@us.ibm.com> 7 - * 8 - * Maintained by: <tpmdd-devel@lists.sourceforge.net> 9 - * 10 - * Device driver for TCG/TCPA TPM (trusted platform module). 11 - * Specifications at www.trustedcomputinggroup.org 12 - * 13 - * These difference are required on power because the device must be 14 - * discovered through the device tree and iomap must be used to get 15 - * around the need for holes in the io_page_mask. This does not happen 16 - * automatically because the tpm is not a normal pci device and lives 17 - * under the root node. 18 - */ 19 - 20 - struct tpm_atmel_priv { 21 - int region_size; 22 - int have_region; 23 - unsigned long base; 24 - void __iomem *iobase; 25 - }; 26 - 27 - #ifdef CONFIG_PPC64 28 - 29 - #include <linux/of.h> 30 - 31 - #define atmel_getb(priv, offset) readb(priv->iobase + offset) 32 - #define atmel_putb(val, priv, offset) writeb(val, priv->iobase + offset) 33 - #define atmel_request_region request_mem_region 34 - #define atmel_release_region release_mem_region 35 - 36 - static inline void atmel_put_base_addr(void __iomem *iobase) 37 - { 38 - iounmap(iobase); 39 - } 40 - 41 - static void __iomem * atmel_get_base_addr(unsigned long *base, int *region_size) 42 - { 43 - struct device_node *dn; 44 - unsigned long address, size; 45 - const unsigned int *reg; 46 - int reglen; 47 - int naddrc; 48 - int nsizec; 49 - 50 - dn = of_find_node_by_name(NULL, "tpm"); 51 - 52 - if (!dn) 53 - return NULL; 54 - 55 - if (!of_device_is_compatible(dn, "AT97SC3201")) { 56 - of_node_put(dn); 57 - return NULL; 58 - } 59 - 60 - reg = of_get_property(dn, "reg", &reglen); 61 - naddrc = of_n_addr_cells(dn); 62 - nsizec = of_n_size_cells(dn); 63 - 64 - of_node_put(dn); 65 - 66 - 67 - if (naddrc == 2) 68 - address = ((unsigned long) reg[0] << 32) | reg[1]; 69 - else 70 - address = reg[0]; 71 - 72 - if (nsizec == 2) 73 - size = 74 - ((unsigned long) reg[naddrc] << 32) | reg[naddrc + 1]; 75 - else 76 - size = reg[naddrc]; 77 - 78 - *base = address; 79 - *region_size = size; 80 - return ioremap(*base, *region_size); 81 - } 82 - #else 83 - #define atmel_getb(chip, offset) inb(atmel_get_priv(chip)->base + offset) 84 - #define atmel_putb(val, chip, offset) \ 85 - outb(val, atmel_get_priv(chip)->base + offset) 86 - #define atmel_request_region request_region 87 - #define atmel_release_region release_region 88 - /* Atmel definitions */ 89 - enum tpm_atmel_addr { 90 - TPM_ATMEL_BASE_ADDR_LO = 0x08, 91 - TPM_ATMEL_BASE_ADDR_HI = 0x09 92 - }; 93 - 94 - static inline int tpm_read_index(int base, int index) 95 - { 96 - outb(index, base); 97 - return inb(base+1) & 0xFF; 98 - } 99 - 100 - /* Verify this is a 1.1 Atmel TPM */ 101 - static int atmel_verify_tpm11(void) 102 - { 103 - 104 - /* verify that it is an Atmel part */ 105 - if (tpm_read_index(TPM_ADDR, 4) != 'A' || 106 - tpm_read_index(TPM_ADDR, 5) != 'T' || 107 - tpm_read_index(TPM_ADDR, 6) != 'M' || 108 - tpm_read_index(TPM_ADDR, 7) != 'L') 109 - return 1; 110 - 111 - /* query chip for its version number */ 112 - if (tpm_read_index(TPM_ADDR, 0x00) != 1 || 113 - tpm_read_index(TPM_ADDR, 0x01) != 1) 114 - return 1; 115 - 116 - /* This is an atmel supported part */ 117 - return 0; 118 - } 119 - 120 - static inline void atmel_put_base_addr(void __iomem *iobase) 121 - { 122 - } 123 - 124 - /* Determine where to talk to device */ 125 - static void __iomem * atmel_get_base_addr(unsigned long *base, int *region_size) 126 - { 127 - int lo, hi; 128 - 129 - if (atmel_verify_tpm11() != 0) 130 - return NULL; 131 - 132 - lo = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_LO); 133 - hi = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_HI); 134 - 135 - *base = (hi << 8) | lo; 136 - *region_size = 2; 137 - 138 - return ioport_map(*base, *region_size); 139 - } 140 - #endif
+1 -14
drivers/char/tpm/tpm_ibmvtpm.c
··· 450 450 } 451 451 452 452 static const struct tpm_class_ops tpm_ibmvtpm = { 453 + .flags = TPM_OPS_AUTO_STARTUP, 453 454 .recv = tpm_ibmvtpm_recv, 454 455 .send = tpm_ibmvtpm_send, 455 456 .cancel = tpm_ibmvtpm_cancel, ··· 690 689 691 690 if (!strcmp(id->compat, "IBM,vtpm20")) 692 691 chip->flags |= TPM_CHIP_FLAG_TPM2; 693 - 694 - rc = tpm_get_timeouts(chip); 695 - if (rc) 696 - goto init_irq_cleanup; 697 - 698 - if (chip->flags & TPM_CHIP_FLAG_TPM2) { 699 - rc = tpm2_get_cc_attrs_tbl(chip); 700 - if (rc) 701 - goto init_irq_cleanup; 702 - 703 - rc = tpm2_sessions_init(chip); 704 - if (rc) 705 - goto init_irq_cleanup; 706 - } 707 692 708 693 return tpm_chip_register(chip); 709 694 init_irq_cleanup:
+105 -63
drivers/char/tpm/tpm_tis_i2c_cr50.c
··· 17 17 */ 18 18 19 19 #include <linux/acpi.h> 20 + #include <linux/bug.h> 20 21 #include <linux/completion.h> 21 22 #include <linux/i2c.h> 22 23 #include <linux/interrupt.h> ··· 31 30 #define TPM_CR50_MAX_BUFSIZE 64 32 31 #define TPM_CR50_TIMEOUT_SHORT_MS 2 /* Short timeout during transactions */ 33 32 #define TPM_CR50_TIMEOUT_NOIRQ_MS 20 /* Timeout for TPM ready without IRQ */ 34 - #define TPM_CR50_I2C_DID_VID 0x00281ae0L /* Device and vendor ID reg value */ 35 - #define TPM_TI50_I2C_DID_VID 0x504a6666L /* Device and vendor ID reg value */ 33 + #define TPM_CR50_I2C_DID_VID 0x00281ae0L /* Device and vendor ID for Cr50 H1 */ 34 + #define TPM_TI50_DT_I2C_DID_VID 0x504a6666L /* Device and vendor ID for Ti50 DT */ 35 + #define TPM_TI50_OT_I2C_DID_VID 0x50666666L /* Device and vendor ID for TI50 OT */ 36 36 #define TPM_CR50_I2C_MAX_RETRIES 3 /* Max retries due to I2C errors */ 37 37 #define TPM_CR50_I2C_RETRY_DELAY_LO 55 /* Min usecs between retries on I2C */ 38 38 #define TPM_CR50_I2C_RETRY_DELAY_HI 65 /* Max usecs between retries on I2C */ 39 + #define TPM_CR50_I2C_DEFAULT_LOC 0 39 40 40 41 #define TPM_I2C_ACCESS(l) (0x0000 | ((l) << 4)) 41 42 #define TPM_I2C_STS(l) (0x0001 | ((l) << 4)) ··· 202 199 }; 203 200 int rc; 204 201 205 - i2c_lock_bus(client->adapter, I2C_LOCK_SEGMENT); 206 - 207 202 /* Prepare for completion interrupt */ 208 203 tpm_cr50_i2c_enable_tpm_irq(chip); 209 204 ··· 220 219 221 220 out: 222 221 tpm_cr50_i2c_disable_tpm_irq(chip); 223 - i2c_unlock_bus(client->adapter, I2C_LOCK_SEGMENT); 224 222 225 223 if (rc < 0) 226 224 return rc; ··· 261 261 priv->buf[0] = addr; 262 262 memcpy(priv->buf + 1, buffer, len); 263 263 264 - i2c_lock_bus(client->adapter, I2C_LOCK_SEGMENT); 265 - 266 264 /* Prepare for completion interrupt */ 267 265 tpm_cr50_i2c_enable_tpm_irq(chip); 268 266 ··· 274 276 275 277 out: 276 278 tpm_cr50_i2c_disable_tpm_irq(chip); 277 - i2c_unlock_bus(client->adapter, I2C_LOCK_SEGMENT); 278 279 279 280 if (rc < 0) 280 281 return rc; ··· 282 285 } 283 286 284 287 /** 285 - * tpm_cr50_check_locality() - Verify TPM locality 0 is active. 288 + * tpm_cr50_check_locality() - Verify if required TPM locality is active. 286 289 * @chip: A TPM chip. 290 + * @loc: Locality to be verified 287 291 * 288 292 * Return: 289 - * - 0: Success. 293 + * - loc: Success. 290 294 * - -errno: A POSIX error code. 291 295 */ 292 - static int tpm_cr50_check_locality(struct tpm_chip *chip) 296 + static int tpm_cr50_check_locality(struct tpm_chip *chip, int loc) 293 297 { 294 298 u8 mask = TPM_ACCESS_VALID | TPM_ACCESS_ACTIVE_LOCALITY; 295 299 u8 buf; 296 300 int rc; 297 301 298 - rc = tpm_cr50_i2c_read(chip, TPM_I2C_ACCESS(0), &buf, sizeof(buf)); 302 + rc = tpm_cr50_i2c_read(chip, TPM_I2C_ACCESS(loc), &buf, sizeof(buf)); 299 303 if (rc < 0) 300 304 return rc; 301 305 302 306 if ((buf & mask) == mask) 303 - return 0; 307 + return loc; 304 308 305 309 return -EIO; 306 310 } ··· 309 311 /** 310 312 * tpm_cr50_release_locality() - Release TPM locality. 311 313 * @chip: A TPM chip. 312 - * @force: Flag to force release if set. 313 - */ 314 - static void tpm_cr50_release_locality(struct tpm_chip *chip, bool force) 315 - { 316 - u8 mask = TPM_ACCESS_VALID | TPM_ACCESS_REQUEST_PENDING; 317 - u8 addr = TPM_I2C_ACCESS(0); 318 - u8 buf; 319 - 320 - if (tpm_cr50_i2c_read(chip, addr, &buf, sizeof(buf)) < 0) 321 - return; 322 - 323 - if (force || (buf & mask) == mask) { 324 - buf = TPM_ACCESS_ACTIVE_LOCALITY; 325 - tpm_cr50_i2c_write(chip, addr, &buf, sizeof(buf)); 326 - } 327 - } 328 - 329 - /** 330 - * tpm_cr50_request_locality() - Request TPM locality 0. 331 - * @chip: A TPM chip. 314 + * @loc: Locality to be released 332 315 * 333 316 * Return: 334 317 * - 0: Success. 335 318 * - -errno: A POSIX error code. 336 319 */ 337 - static int tpm_cr50_request_locality(struct tpm_chip *chip) 320 + static int tpm_cr50_release_locality(struct tpm_chip *chip, int loc) 338 321 { 322 + struct i2c_client *client = to_i2c_client(chip->dev.parent); 323 + u8 mask = TPM_ACCESS_VALID | TPM_ACCESS_REQUEST_PENDING; 324 + u8 addr = TPM_I2C_ACCESS(loc); 325 + u8 buf; 326 + int rc; 327 + 328 + rc = tpm_cr50_i2c_read(chip, addr, &buf, sizeof(buf)); 329 + if (rc < 0) 330 + goto unlock_out; 331 + 332 + if ((buf & mask) == mask) { 333 + buf = TPM_ACCESS_ACTIVE_LOCALITY; 334 + rc = tpm_cr50_i2c_write(chip, addr, &buf, sizeof(buf)); 335 + } 336 + 337 + unlock_out: 338 + i2c_unlock_bus(client->adapter, I2C_LOCK_SEGMENT); 339 + return rc; 340 + } 341 + 342 + /** 343 + * tpm_cr50_request_locality() - Request TPM locality. 344 + * @chip: A TPM chip. 345 + * @loc: Locality to be requested. 346 + * 347 + * Return: 348 + * - loc: Success. 349 + * - -errno: A POSIX error code. 350 + */ 351 + static int tpm_cr50_request_locality(struct tpm_chip *chip, int loc) 352 + { 353 + struct i2c_client *client = to_i2c_client(chip->dev.parent); 339 354 u8 buf = TPM_ACCESS_REQUEST_USE; 340 355 unsigned long stop; 341 356 int rc; 342 357 343 - if (!tpm_cr50_check_locality(chip)) 344 - return 0; 358 + i2c_lock_bus(client->adapter, I2C_LOCK_SEGMENT); 345 359 346 - rc = tpm_cr50_i2c_write(chip, TPM_I2C_ACCESS(0), &buf, sizeof(buf)); 360 + if (tpm_cr50_check_locality(chip, loc) == loc) 361 + return loc; 362 + 363 + rc = tpm_cr50_i2c_write(chip, TPM_I2C_ACCESS(loc), &buf, sizeof(buf)); 347 364 if (rc < 0) 348 - return rc; 365 + goto unlock_out; 349 366 350 367 stop = jiffies + chip->timeout_a; 351 368 do { 352 - if (!tpm_cr50_check_locality(chip)) 353 - return 0; 369 + if (tpm_cr50_check_locality(chip, loc) == loc) 370 + return loc; 354 371 355 372 msleep(TPM_CR50_TIMEOUT_SHORT_MS); 356 373 } while (time_before(jiffies, stop)); 357 374 358 - return -ETIMEDOUT; 375 + rc = -ETIMEDOUT; 376 + 377 + unlock_out: 378 + i2c_unlock_bus(client->adapter, I2C_LOCK_SEGMENT); 379 + return rc; 359 380 } 360 381 361 382 /** ··· 390 373 { 391 374 u8 buf[4]; 392 375 393 - if (tpm_cr50_i2c_read(chip, TPM_I2C_STS(0), buf, sizeof(buf)) < 0) 376 + if (tpm_cr50_i2c_read(chip, TPM_I2C_STS(chip->locality), buf, sizeof(buf)) < 0) 394 377 return 0; 395 378 396 379 return buf[0]; ··· 406 389 { 407 390 u8 buf[4] = { TPM_STS_COMMAND_READY }; 408 391 409 - tpm_cr50_i2c_write(chip, TPM_I2C_STS(0), buf, sizeof(buf)); 392 + tpm_cr50_i2c_write(chip, TPM_I2C_STS(chip->locality), buf, sizeof(buf)); 410 393 msleep(TPM_CR50_TIMEOUT_SHORT_MS); 411 394 } 412 395 ··· 436 419 stop = jiffies + chip->timeout_b; 437 420 438 421 do { 439 - if (tpm_cr50_i2c_read(chip, TPM_I2C_STS(0), buf, sizeof(buf)) < 0) { 422 + if (tpm_cr50_i2c_read(chip, TPM_I2C_STS(chip->locality), buf, sizeof(buf)) < 0) { 440 423 msleep(TPM_CR50_TIMEOUT_SHORT_MS); 441 424 continue; 442 425 } ··· 470 453 471 454 u8 mask = TPM_STS_VALID | TPM_STS_DATA_AVAIL; 472 455 size_t burstcnt, cur, len, expected; 473 - u8 addr = TPM_I2C_DATA_FIFO(0); 456 + u8 addr = TPM_I2C_DATA_FIFO(chip->locality); 474 457 u32 status; 475 458 int rc; 476 459 ··· 532 515 goto out_err; 533 516 } 534 517 535 - tpm_cr50_release_locality(chip, false); 536 518 return cur; 537 519 538 520 out_err: ··· 539 523 if (tpm_cr50_i2c_tis_status(chip) & TPM_STS_COMMAND_READY) 540 524 tpm_cr50_i2c_tis_set_ready(chip); 541 525 542 - tpm_cr50_release_locality(chip, false); 543 526 return rc; 544 527 } 545 528 ··· 559 544 unsigned long stop; 560 545 u32 status; 561 546 int rc; 562 - 563 - rc = tpm_cr50_request_locality(chip); 564 - if (rc < 0) 565 - return rc; 566 547 567 548 /* Wait until TPM is ready for a command */ 568 549 stop = jiffies + chip->timeout_b; ··· 588 577 * that is inserted by tpm_cr50_i2c_write() 589 578 */ 590 579 limit = min_t(size_t, burstcnt - 1, len); 591 - rc = tpm_cr50_i2c_write(chip, TPM_I2C_DATA_FIFO(0), &buf[sent], limit); 580 + rc = tpm_cr50_i2c_write(chip, TPM_I2C_DATA_FIFO(chip->locality), 581 + &buf[sent], limit); 592 582 if (rc < 0) { 593 583 dev_err(&chip->dev, "Write failed\n"); 594 584 goto out_err; ··· 610 598 } 611 599 612 600 /* Start the TPM command */ 613 - rc = tpm_cr50_i2c_write(chip, TPM_I2C_STS(0), tpm_go, 601 + rc = tpm_cr50_i2c_write(chip, TPM_I2C_STS(chip->locality), tpm_go, 614 602 sizeof(tpm_go)); 615 603 if (rc < 0) { 616 604 dev_err(&chip->dev, "Start command failed\n"); ··· 623 611 if (tpm_cr50_i2c_tis_status(chip) & TPM_STS_COMMAND_READY) 624 612 tpm_cr50_i2c_tis_set_ready(chip); 625 613 626 - tpm_cr50_release_locality(chip, false); 627 614 return rc; 628 615 } 629 616 ··· 661 650 .req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID, 662 651 .req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID, 663 652 .req_canceled = &tpm_cr50_i2c_req_canceled, 653 + .request_locality = &tpm_cr50_request_locality, 654 + .relinquish_locality = &tpm_cr50_release_locality, 664 655 }; 665 656 666 657 #ifdef CONFIG_ACPI ··· 682 669 #endif 683 670 684 671 /** 672 + * tpm_cr50_vid_to_name() - Maps VID to name. 673 + * @vendor: Vendor identifier to map to name 674 + * 675 + * Return: 676 + * A valid string for the vendor or empty string 677 + */ 678 + static const char *tpm_cr50_vid_to_name(u32 vendor) 679 + { 680 + switch (vendor) { 681 + case TPM_CR50_I2C_DID_VID: 682 + return "cr50"; 683 + case TPM_TI50_DT_I2C_DID_VID: 684 + return "ti50 DT"; 685 + case TPM_TI50_OT_I2C_DID_VID: 686 + return "ti50 OT"; 687 + default: 688 + return "unknown"; 689 + } 690 + } 691 + 692 + /** 685 693 * tpm_cr50_i2c_probe() - Driver probe function. 686 694 * @client: I2C client information. 687 695 * ··· 718 684 u32 vendor; 719 685 u8 buf[4]; 720 686 int rc; 687 + int loc; 721 688 722 689 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) 723 690 return -ENODEV; ··· 761 726 TPM_CR50_TIMEOUT_NOIRQ_MS); 762 727 } 763 728 764 - rc = tpm_cr50_request_locality(chip); 765 - if (rc < 0) { 729 + loc = tpm_cr50_request_locality(chip, TPM_CR50_I2C_DEFAULT_LOC); 730 + if (loc < 0) { 766 731 dev_err(dev, "Could not request locality\n"); 767 - return rc; 732 + return loc; 768 733 } 769 734 770 735 /* Read four bytes from DID_VID register */ 771 - rc = tpm_cr50_i2c_read(chip, TPM_I2C_DID_VID(0), buf, sizeof(buf)); 736 + rc = tpm_cr50_i2c_read(chip, TPM_I2C_DID_VID(loc), buf, sizeof(buf)); 772 737 if (rc < 0) { 773 738 dev_err(dev, "Could not read vendor id\n"); 774 - tpm_cr50_release_locality(chip, true); 739 + if (tpm_cr50_release_locality(chip, loc)) 740 + dev_err(dev, "Could not release locality\n"); 741 + return rc; 742 + } 743 + 744 + rc = tpm_cr50_release_locality(chip, loc); 745 + if (rc) { 746 + dev_err(dev, "Could not release locality\n"); 775 747 return rc; 776 748 } 777 749 778 750 vendor = le32_to_cpup((__le32 *)buf); 779 - if (vendor != TPM_CR50_I2C_DID_VID && vendor != TPM_TI50_I2C_DID_VID) { 751 + if (vendor != TPM_CR50_I2C_DID_VID && 752 + vendor != TPM_TI50_DT_I2C_DID_VID && 753 + vendor != TPM_TI50_OT_I2C_DID_VID) { 780 754 dev_err(dev, "Vendor ID did not match! ID was %08x\n", vendor); 781 - tpm_cr50_release_locality(chip, true); 782 755 return -ENODEV; 783 756 } 784 757 785 758 dev_info(dev, "%s TPM 2.0 (i2c 0x%02x irq %d id 0x%x)\n", 786 - vendor == TPM_TI50_I2C_DID_VID ? "ti50" : "cr50", 759 + tpm_cr50_vid_to_name(vendor), 787 760 client->addr, client->irq, vendor >> 16); 788 761 return tpm_chip_register(chip); 789 762 } ··· 815 772 } 816 773 817 774 tpm_chip_unregister(chip); 818 - tpm_cr50_release_locality(chip, true); 819 775 } 820 776 821 777 static SIMPLE_DEV_PM_OPS(cr50_i2c_pm, tpm_pm_suspend, tpm_pm_resume);