|
22 | 22 | #include "../tpm_chip.h"
|
23 | 23 | #include "tpm_i2c_interface.h"
|
24 | 24 | #include "tpm_i2c_nuvoton.h"
|
| 25 | +#include <opal-api.h> |
25 | 26 |
|
26 | 27 | //#define DBG(fmt, ...) prlog(PR_DEBUG, fmt, ##__VA_ARGS__)
|
27 | 28 | #define DBG(fmt, ...)
|
@@ -507,10 +508,33 @@ static struct tpm_driver tpm_i2c_nuvoton_driver = {
|
507 | 508 | .transmit = tpm_transmit,
|
508 | 509 | };
|
509 | 510 |
|
| 511 | +static int nuvoton_tpm_quirk(void *data, struct i2c_request *req, int *rc) |
| 512 | +{ |
| 513 | + struct tpm_dev *tpm_device = data; |
| 514 | + |
| 515 | + /* If we're doing i2cdetect on the TPM, pretent we just NACKed |
| 516 | + * it due to errata in nuvoton firmware where if we let this |
| 517 | + * request go through, it would steal the bus and you'd end up |
| 518 | + * in a nice world of pain. |
| 519 | + */ |
| 520 | + if (tpm_device->bus_id == req->bus->opal_id && |
| 521 | + tpm_device->xscom_base == req->dev_addr && |
| 522 | + ((req->op == I2C_READ && req->rw_len == 1) || |
| 523 | + (req->op == I2C_WRITE && req->rw_len == 0))) { |
| 524 | + *rc = OPAL_I2C_TIMEOUT; |
| 525 | + prlog(PR_DEBUG,"NUVOTON: Squashed i2c probe to avoid locking " |
| 526 | + "I2C bus\n"); |
| 527 | + return 1; |
| 528 | + } |
| 529 | + |
| 530 | + return 0; |
| 531 | +} |
| 532 | + |
510 | 533 | void tpm_i2c_nuvoton_probe(void)
|
511 | 534 | {
|
512 | 535 | struct tpm_dev *tpm_device = NULL;
|
513 | 536 | struct dt_node *node = NULL;
|
| 537 | + struct i2c_bus *bus; |
514 | 538 |
|
515 | 539 | dt_for_each_compatible(dt_root, node, "nuvoton,npct650") {
|
516 | 540 | if (!dt_node_is_enabled(node))
|
@@ -551,6 +575,10 @@ void tpm_i2c_nuvoton_probe(void)
|
551 | 575 | if (tpm_register_chip(node, tpm_device,
|
552 | 576 | &tpm_i2c_nuvoton_driver))
|
553 | 577 | free(tpm_device);
|
| 578 | + bus = i2c_find_bus_by_id(tpm_device->bus_id); |
| 579 | + assert(bus->check_quirk == NULL); |
| 580 | + bus->check_quirk = nuvoton_tpm_quirk; |
| 581 | + bus->check_quirk_data = tpm_device; |
554 | 582 | }
|
555 | 583 | return;
|
556 | 584 | disable:
|
|
0 commit comments