tpm2_tis_spi.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Author:
  4. * Miquel Raynal <miquel.raynal@bootlin.com>
  5. *
  6. * Description:
  7. * SPI-level driver for TCG/TIS TPM (trusted platform module).
  8. * Specifications at www.trustedcomputinggroup.org
  9. *
  10. * This device driver implements the TPM interface as defined in
  11. * the TCG SPI protocol stack version 2.0.
  12. *
  13. * It is based on the U-Boot driver tpm_tis_infineon_i2c.c.
  14. */
  15. #include <common.h>
  16. #include <dm.h>
  17. #include <fdtdec.h>
  18. #include <log.h>
  19. #include <spi.h>
  20. #include <tpm-v2.h>
  21. #include <linux/errno.h>
  22. #include <linux/compiler.h>
  23. #include <linux/types.h>
  24. #include <linux/unaligned/be_byteshift.h>
  25. #include <asm-generic/gpio.h>
  26. #include "tpm_tis.h"
  27. #include "tpm_internal.h"
  28. DECLARE_GLOBAL_DATA_PTR;
  29. #define TPM_ACCESS(l) (0x0000 | ((l) << 12))
  30. #define TPM_INT_ENABLE(l) (0x0008 | ((l) << 12))
  31. #define TPM_STS(l) (0x0018 | ((l) << 12))
  32. #define TPM_DATA_FIFO(l) (0x0024 | ((l) << 12))
  33. #define TPM_DID_VID(l) (0x0F00 | ((l) << 12))
  34. #define TPM_RID(l) (0x0F04 | ((l) << 12))
  35. #define MAX_SPI_FRAMESIZE 64
  36. /* Number of wait states to wait for */
  37. #define TPM_WAIT_STATES 100
  38. /**
  39. * struct tpm_tis_chip_data - Non-discoverable TPM information
  40. *
  41. * @pcr_count: Number of PCR per bank
  42. * @pcr_select_min: Size in octets of the pcrSelect array
  43. */
  44. struct tpm_tis_chip_data {
  45. unsigned int pcr_count;
  46. unsigned int pcr_select_min;
  47. unsigned int time_before_first_cmd_ms;
  48. };
  49. /**
  50. * tpm_tis_spi_read() - Read from TPM register
  51. *
  52. * @addr: register address to read from
  53. * @buffer: provided by caller
  54. * @len: number of bytes to read
  55. *
  56. * Read len bytes from TPM register and put them into
  57. * buffer (little-endian format, i.e. first byte is put into buffer[0]).
  58. *
  59. * NOTE: TPM is big-endian for multi-byte values. Multi-byte
  60. * values have to be swapped.
  61. *
  62. * @return -EIO on error, 0 on success.
  63. */
  64. static int tpm_tis_spi_xfer(struct udevice *dev, u32 addr, const u8 *out,
  65. u8 *in, u16 len)
  66. {
  67. struct spi_slave *slave = dev_get_parent_priv(dev);
  68. int transfer_len, ret;
  69. u8 tx_buf[MAX_SPI_FRAMESIZE];
  70. u8 rx_buf[MAX_SPI_FRAMESIZE];
  71. if (in && out) {
  72. log(LOGC_NONE, LOGL_ERR, "%s: can't do full duplex\n",
  73. __func__);
  74. return -EINVAL;
  75. }
  76. ret = spi_claim_bus(slave);
  77. if (ret < 0) {
  78. log(LOGC_NONE, LOGL_ERR, "%s: could not claim bus\n", __func__);
  79. return ret;
  80. }
  81. while (len) {
  82. /* Request */
  83. transfer_len = min_t(u16, len, MAX_SPI_FRAMESIZE);
  84. tx_buf[0] = (in ? BIT(7) : 0) | (transfer_len - 1);
  85. tx_buf[1] = 0xD4;
  86. tx_buf[2] = addr >> 8;
  87. tx_buf[3] = addr;
  88. ret = spi_xfer(slave, 4 * 8, tx_buf, rx_buf, SPI_XFER_BEGIN);
  89. if (ret < 0) {
  90. log(LOGC_NONE, LOGL_ERR,
  91. "%s: spi request transfer failed (err: %d)\n",
  92. __func__, ret);
  93. goto release_bus;
  94. }
  95. /* Wait state */
  96. if (!(rx_buf[3] & 0x1)) {
  97. int i;
  98. for (i = 0; i < TPM_WAIT_STATES; i++) {
  99. ret = spi_xfer(slave, 1 * 8, NULL, rx_buf, 0);
  100. if (ret) {
  101. log(LOGC_NONE, LOGL_ERR,
  102. "%s: wait state failed: %d\n",
  103. __func__, ret);
  104. goto release_bus;
  105. }
  106. if (rx_buf[0] & 0x1)
  107. break;
  108. }
  109. if (i == TPM_WAIT_STATES) {
  110. log(LOGC_NONE, LOGL_ERR,
  111. "%s: timeout on wait state\n", __func__);
  112. ret = -ETIMEDOUT;
  113. goto release_bus;
  114. }
  115. }
  116. /* Read/Write */
  117. if (out) {
  118. memcpy(tx_buf, out, transfer_len);
  119. out += transfer_len;
  120. }
  121. ret = spi_xfer(slave, transfer_len * 8,
  122. out ? tx_buf : NULL,
  123. in ? rx_buf : NULL,
  124. SPI_XFER_END);
  125. if (ret) {
  126. log(LOGC_NONE, LOGL_ERR,
  127. "%s: spi read transfer failed (err: %d)\n",
  128. __func__, ret);
  129. goto release_bus;
  130. }
  131. if (in) {
  132. memcpy(in, rx_buf, transfer_len);
  133. in += transfer_len;
  134. }
  135. len -= transfer_len;
  136. }
  137. release_bus:
  138. /* If an error occurred, release the chip by deasserting the CS */
  139. if (ret < 0)
  140. spi_xfer(slave, 0, NULL, NULL, SPI_XFER_END);
  141. spi_release_bus(slave);
  142. return ret;
  143. }
  144. static int tpm_tis_spi_read(struct udevice *dev, u16 addr, u8 *in, u16 len)
  145. {
  146. return tpm_tis_spi_xfer(dev, addr, NULL, in, len);
  147. }
  148. static int tpm_tis_spi_read32(struct udevice *dev, u32 addr, u32 *result)
  149. {
  150. __le32 result_le;
  151. int ret;
  152. ret = tpm_tis_spi_read(dev, addr, (u8 *)&result_le, sizeof(u32));
  153. if (!ret)
  154. *result = le32_to_cpu(result_le);
  155. return ret;
  156. }
  157. static int tpm_tis_spi_write(struct udevice *dev, u16 addr, const u8 *out,
  158. u16 len)
  159. {
  160. return tpm_tis_spi_xfer(dev, addr, out, NULL, len);
  161. }
  162. static int tpm_tis_spi_check_locality(struct udevice *dev, int loc)
  163. {
  164. const u8 mask = TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID;
  165. struct tpm_chip *chip = dev_get_priv(dev);
  166. u8 buf;
  167. int ret;
  168. ret = tpm_tis_spi_read(dev, TPM_ACCESS(loc), &buf, 1);
  169. if (ret)
  170. return ret;
  171. if ((buf & mask) == mask) {
  172. chip->locality = loc;
  173. return 0;
  174. }
  175. return -ENOENT;
  176. }
  177. static void tpm_tis_spi_release_locality(struct udevice *dev, int loc,
  178. bool force)
  179. {
  180. const u8 mask = TPM_ACCESS_REQUEST_PENDING | TPM_ACCESS_VALID;
  181. u8 buf;
  182. if (tpm_tis_spi_read(dev, TPM_ACCESS(loc), &buf, 1) < 0)
  183. return;
  184. if (force || (buf & mask) == mask) {
  185. buf = TPM_ACCESS_ACTIVE_LOCALITY;
  186. tpm_tis_spi_write(dev, TPM_ACCESS(loc), &buf, 1);
  187. }
  188. }
  189. static int tpm_tis_spi_request_locality(struct udevice *dev, int loc)
  190. {
  191. struct tpm_chip *chip = dev_get_priv(dev);
  192. unsigned long start, stop;
  193. u8 buf = TPM_ACCESS_REQUEST_USE;
  194. int ret;
  195. ret = tpm_tis_spi_check_locality(dev, loc);
  196. if (!ret)
  197. return 0;
  198. if (ret != -ENOENT) {
  199. log(LOGC_NONE, LOGL_ERR, "%s: Failed to get locality: %d\n",
  200. __func__, ret);
  201. return ret;
  202. }
  203. ret = tpm_tis_spi_write(dev, TPM_ACCESS(loc), &buf, 1);
  204. if (ret) {
  205. log(LOGC_NONE, LOGL_ERR, "%s: Failed to write to TPM: %d\n",
  206. __func__, ret);
  207. return ret;
  208. }
  209. start = get_timer(0);
  210. stop = chip->timeout_a;
  211. do {
  212. ret = tpm_tis_spi_check_locality(dev, loc);
  213. if (!ret)
  214. return 0;
  215. if (ret != -ENOENT) {
  216. log(LOGC_NONE, LOGL_ERR,
  217. "%s: Failed to get locality: %d\n", __func__, ret);
  218. return ret;
  219. }
  220. mdelay(TPM_TIMEOUT_MS);
  221. } while (get_timer(start) < stop);
  222. log(LOGC_NONE, LOGL_ERR, "%s: Timeout getting locality: %d\n", __func__,
  223. ret);
  224. return ret;
  225. }
  226. static u8 tpm_tis_spi_status(struct udevice *dev, u8 *status)
  227. {
  228. struct tpm_chip *chip = dev_get_priv(dev);
  229. return tpm_tis_spi_read(dev, TPM_STS(chip->locality), status, 1);
  230. }
  231. static int tpm_tis_spi_wait_for_stat(struct udevice *dev, u8 mask,
  232. unsigned long timeout, u8 *status)
  233. {
  234. unsigned long start = get_timer(0);
  235. unsigned long stop = timeout;
  236. int ret;
  237. do {
  238. mdelay(TPM_TIMEOUT_MS);
  239. ret = tpm_tis_spi_status(dev, status);
  240. if (ret)
  241. return ret;
  242. if ((*status & mask) == mask)
  243. return 0;
  244. } while (get_timer(start) < stop);
  245. return -ETIMEDOUT;
  246. }
  247. static u8 tpm_tis_spi_valid_status(struct udevice *dev, u8 *status)
  248. {
  249. struct tpm_chip *chip = dev_get_priv(dev);
  250. return tpm_tis_spi_wait_for_stat(dev, TPM_STS_VALID,
  251. chip->timeout_c, status);
  252. }
  253. static int tpm_tis_spi_get_burstcount(struct udevice *dev)
  254. {
  255. struct tpm_chip *chip = dev_get_priv(dev);
  256. unsigned long start, stop;
  257. u32 burstcount, ret;
  258. /* wait for burstcount */
  259. start = get_timer(0);
  260. stop = chip->timeout_d;
  261. do {
  262. ret = tpm_tis_spi_read32(dev, TPM_STS(chip->locality),
  263. &burstcount);
  264. if (ret)
  265. return -EBUSY;
  266. burstcount = (burstcount >> 8) & 0xFFFF;
  267. if (burstcount)
  268. return burstcount;
  269. mdelay(TPM_TIMEOUT_MS);
  270. } while (get_timer(start) < stop);
  271. return -EBUSY;
  272. }
  273. static int tpm_tis_spi_cancel(struct udevice *dev)
  274. {
  275. struct tpm_chip *chip = dev_get_priv(dev);
  276. u8 data = TPM_STS_COMMAND_READY;
  277. return tpm_tis_spi_write(dev, TPM_STS(chip->locality), &data, 1);
  278. }
  279. static int tpm_tis_spi_recv_data(struct udevice *dev, u8 *buf, size_t count)
  280. {
  281. struct tpm_chip *chip = dev_get_priv(dev);
  282. int size = 0, burstcnt, len, ret;
  283. u8 status;
  284. while (size < count &&
  285. tpm_tis_spi_wait_for_stat(dev,
  286. TPM_STS_DATA_AVAIL | TPM_STS_VALID,
  287. chip->timeout_c, &status) == 0) {
  288. burstcnt = tpm_tis_spi_get_burstcount(dev);
  289. if (burstcnt < 0)
  290. return burstcnt;
  291. len = min_t(int, burstcnt, count - size);
  292. ret = tpm_tis_spi_read(dev, TPM_DATA_FIFO(chip->locality),
  293. buf + size, len);
  294. if (ret < 0)
  295. return ret;
  296. size += len;
  297. }
  298. return size;
  299. }
  300. static int tpm_tis_spi_recv(struct udevice *dev, u8 *buf, size_t count)
  301. {
  302. struct tpm_chip *chip = dev_get_priv(dev);
  303. int size, expected;
  304. if (!chip)
  305. return -ENODEV;
  306. if (count < TPM_HEADER_SIZE) {
  307. size = -EIO;
  308. goto out;
  309. }
  310. size = tpm_tis_spi_recv_data(dev, buf, TPM_HEADER_SIZE);
  311. if (size < TPM_HEADER_SIZE) {
  312. log(LOGC_NONE, LOGL_ERR, "TPM error, unable to read header\n");
  313. goto out;
  314. }
  315. expected = get_unaligned_be32(buf + 2);
  316. if (expected > count) {
  317. size = -EIO;
  318. goto out;
  319. }
  320. size += tpm_tis_spi_recv_data(dev, &buf[TPM_HEADER_SIZE],
  321. expected - TPM_HEADER_SIZE);
  322. if (size < expected) {
  323. log(LOGC_NONE, LOGL_ERR,
  324. "TPM error, unable to read remaining bytes of result\n");
  325. size = -EIO;
  326. goto out;
  327. }
  328. out:
  329. tpm_tis_spi_cancel(dev);
  330. tpm_tis_spi_release_locality(dev, chip->locality, false);
  331. return size;
  332. }
  333. static int tpm_tis_spi_send(struct udevice *dev, const u8 *buf, size_t len)
  334. {
  335. struct tpm_chip *chip = dev_get_priv(dev);
  336. u32 i, size;
  337. u8 status;
  338. int burstcnt, ret;
  339. u8 data;
  340. if (!chip)
  341. return -ENODEV;
  342. if (len > TPM_DEV_BUFSIZE)
  343. return -E2BIG; /* Command is too long for our tpm, sorry */
  344. ret = tpm_tis_spi_request_locality(dev, 0);
  345. if (ret < 0)
  346. return -EBUSY;
  347. /*
  348. * Check if the TPM is ready. If not, if not, cancel the pending command
  349. * and poll on the status to be finally ready.
  350. */
  351. ret = tpm_tis_spi_status(dev, &status);
  352. if (ret)
  353. return ret;
  354. if (!(status & TPM_STS_COMMAND_READY)) {
  355. /* Force the transition, usually this will be done at startup */
  356. ret = tpm_tis_spi_cancel(dev);
  357. if (ret) {
  358. log(LOGC_NONE, LOGL_ERR,
  359. "%s: Could not cancel previous operation\n",
  360. __func__);
  361. goto out_err;
  362. }
  363. ret = tpm_tis_spi_wait_for_stat(dev, TPM_STS_COMMAND_READY,
  364. chip->timeout_b, &status);
  365. if (ret < 0 || !(status & TPM_STS_COMMAND_READY)) {
  366. log(LOGC_NONE, LOGL_ERR,
  367. "status %d after wait for stat returned %d\n",
  368. status, ret);
  369. goto out_err;
  370. }
  371. }
  372. for (i = 0; i < len - 1;) {
  373. burstcnt = tpm_tis_spi_get_burstcount(dev);
  374. if (burstcnt < 0)
  375. return burstcnt;
  376. size = min_t(int, len - i - 1, burstcnt);
  377. ret = tpm_tis_spi_write(dev, TPM_DATA_FIFO(chip->locality),
  378. buf + i, size);
  379. if (ret < 0)
  380. goto out_err;
  381. i += size;
  382. }
  383. ret = tpm_tis_spi_valid_status(dev, &status);
  384. if (ret)
  385. goto out_err;
  386. if ((status & TPM_STS_DATA_EXPECT) == 0) {
  387. ret = -EIO;
  388. goto out_err;
  389. }
  390. ret = tpm_tis_spi_write(dev, TPM_DATA_FIFO(chip->locality),
  391. buf + len - 1, 1);
  392. if (ret)
  393. goto out_err;
  394. ret = tpm_tis_spi_valid_status(dev, &status);
  395. if (ret)
  396. goto out_err;
  397. if ((status & TPM_STS_DATA_EXPECT) != 0) {
  398. ret = -EIO;
  399. goto out_err;
  400. }
  401. data = TPM_STS_GO;
  402. ret = tpm_tis_spi_write(dev, TPM_STS(chip->locality), &data, 1);
  403. if (ret)
  404. goto out_err;
  405. return len;
  406. out_err:
  407. tpm_tis_spi_cancel(dev);
  408. tpm_tis_spi_release_locality(dev, chip->locality, false);
  409. return ret;
  410. }
  411. static int tpm_tis_spi_cleanup(struct udevice *dev)
  412. {
  413. struct tpm_chip *chip = dev_get_priv(dev);
  414. tpm_tis_spi_cancel(dev);
  415. /*
  416. * The TPM needs some time to clean up here,
  417. * so we sleep rather than keeping the bus busy
  418. */
  419. mdelay(2);
  420. tpm_tis_spi_release_locality(dev, chip->locality, false);
  421. return 0;
  422. }
  423. static int tpm_tis_spi_open(struct udevice *dev)
  424. {
  425. struct tpm_chip *chip = dev_get_priv(dev);
  426. struct tpm_chip_priv *priv = dev_get_uclass_priv(dev);
  427. if (chip->is_open)
  428. return -EBUSY;
  429. chip->is_open = 1;
  430. return 0;
  431. }
  432. static int tpm_tis_spi_close(struct udevice *dev)
  433. {
  434. struct tpm_chip *chip = dev_get_priv(dev);
  435. if (chip->is_open) {
  436. tpm_tis_spi_release_locality(dev, chip->locality, true);
  437. chip->is_open = 0;
  438. }
  439. return 0;
  440. }
  441. static int tpm_tis_get_desc(struct udevice *dev, char *buf, int size)
  442. {
  443. struct tpm_chip *chip = dev_get_priv(dev);
  444. if (size < 80)
  445. return -ENOSPC;
  446. return snprintf(buf, size,
  447. "%s v2.0: VendorID 0x%04x, DeviceID 0x%04x, RevisionID 0x%02x [%s]",
  448. dev->name, chip->vend_dev & 0xFFFF,
  449. chip->vend_dev >> 16, chip->rid,
  450. (chip->is_open ? "open" : "closed"));
  451. }
  452. static int tpm_tis_wait_init(struct udevice *dev, int loc)
  453. {
  454. struct tpm_chip *chip = dev_get_priv(dev);
  455. unsigned long start, stop;
  456. u8 status;
  457. int ret;
  458. start = get_timer(0);
  459. stop = chip->timeout_b;
  460. do {
  461. mdelay(TPM_TIMEOUT_MS);
  462. ret = tpm_tis_spi_read(dev, TPM_ACCESS(loc), &status, 1);
  463. if (ret)
  464. break;
  465. if (status & TPM_ACCESS_VALID)
  466. return 0;
  467. } while (get_timer(start) < stop);
  468. return -EIO;
  469. }
  470. static int tpm_tis_spi_probe(struct udevice *dev)
  471. {
  472. struct tpm_tis_chip_data *drv_data = (void *)dev_get_driver_data(dev);
  473. struct tpm_chip_priv *priv = dev_get_uclass_priv(dev);
  474. struct tpm_chip *chip = dev_get_priv(dev);
  475. int ret;
  476. /* Use the TPM v2 stack */
  477. priv->version = TPM_V2;
  478. if (CONFIG_IS_ENABLED(DM_GPIO)) {
  479. struct gpio_desc reset_gpio;
  480. ret = gpio_request_by_name(dev, "gpio-reset", 0,
  481. &reset_gpio, GPIOD_IS_OUT);
  482. if (ret) {
  483. log(LOGC_NONE, LOGL_NOTICE, "%s: missing reset GPIO\n",
  484. __func__);
  485. } else {
  486. dm_gpio_set_value(&reset_gpio, 1);
  487. mdelay(1);
  488. dm_gpio_set_value(&reset_gpio, 0);
  489. }
  490. }
  491. /* Ensure a minimum amount of time elapsed since reset of the TPM */
  492. mdelay(drv_data->time_before_first_cmd_ms);
  493. chip->locality = 0;
  494. chip->timeout_a = TIS_SHORT_TIMEOUT_MS;
  495. chip->timeout_b = TIS_LONG_TIMEOUT_MS;
  496. chip->timeout_c = TIS_SHORT_TIMEOUT_MS;
  497. chip->timeout_d = TIS_SHORT_TIMEOUT_MS;
  498. priv->pcr_count = drv_data->pcr_count;
  499. priv->pcr_select_min = drv_data->pcr_select_min;
  500. ret = tpm_tis_wait_init(dev, chip->locality);
  501. if (ret) {
  502. log(LOGC_DM, LOGL_ERR, "%s: no device found\n", __func__);
  503. return ret;
  504. }
  505. ret = tpm_tis_spi_request_locality(dev, chip->locality);
  506. if (ret) {
  507. log(LOGC_NONE, LOGL_ERR, "%s: could not request locality %d\n",
  508. __func__, chip->locality);
  509. return ret;
  510. }
  511. ret = tpm_tis_spi_read32(dev, TPM_DID_VID(chip->locality),
  512. &chip->vend_dev);
  513. if (ret) {
  514. log(LOGC_NONE, LOGL_ERR,
  515. "%s: could not retrieve VendorID/DeviceID\n", __func__);
  516. return ret;
  517. }
  518. ret = tpm_tis_spi_read(dev, TPM_RID(chip->locality), &chip->rid, 1);
  519. if (ret) {
  520. log(LOGC_NONE, LOGL_ERR, "%s: could not retrieve RevisionID\n",
  521. __func__);
  522. return ret;
  523. }
  524. log(LOGC_NONE, LOGL_ERR,
  525. "SPI TPMv2.0 found (vid:%04x, did:%04x, rid:%02x)\n",
  526. chip->vend_dev & 0xFFFF, chip->vend_dev >> 16, chip->rid);
  527. return 0;
  528. }
  529. static int tpm_tis_spi_remove(struct udevice *dev)
  530. {
  531. struct tpm_chip *chip = dev_get_priv(dev);
  532. tpm_tis_spi_release_locality(dev, chip->locality, true);
  533. return 0;
  534. }
  535. static const struct tpm_ops tpm_tis_spi_ops = {
  536. .open = tpm_tis_spi_open,
  537. .close = tpm_tis_spi_close,
  538. .get_desc = tpm_tis_get_desc,
  539. .send = tpm_tis_spi_send,
  540. .recv = tpm_tis_spi_recv,
  541. .cleanup = tpm_tis_spi_cleanup,
  542. };
  543. static const struct tpm_tis_chip_data tpm_tis_std_chip_data = {
  544. .pcr_count = 24,
  545. .pcr_select_min = 3,
  546. .time_before_first_cmd_ms = 30,
  547. };
  548. static const struct udevice_id tpm_tis_spi_ids[] = {
  549. {
  550. .compatible = "tis,tpm2-spi",
  551. .data = (ulong)&tpm_tis_std_chip_data,
  552. },
  553. { }
  554. };
  555. U_BOOT_DRIVER(tpm_tis_spi) = {
  556. .name = "tpm_tis_spi",
  557. .id = UCLASS_TPM,
  558. .of_match = tpm_tis_spi_ids,
  559. .ops = &tpm_tis_spi_ops,
  560. .probe = tpm_tis_spi_probe,
  561. .remove = tpm_tis_spi_remove,
  562. .priv_auto_alloc_size = sizeof(struct tpm_chip),
  563. };