tpm2_tis_spi.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  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/bitops.h>
  22. #include <linux/delay.h>
  23. #include <linux/errno.h>
  24. #include <linux/compiler.h>
  25. #include <linux/types.h>
  26. #include <linux/unaligned/be_byteshift.h>
  27. #include <asm-generic/gpio.h>
  28. #include "tpm_tis.h"
  29. #include "tpm_internal.h"
  30. #define TPM_ACCESS(l) (0x0000 | ((l) << 12))
  31. #define TPM_INT_ENABLE(l) (0x0008 | ((l) << 12))
  32. #define TPM_STS(l) (0x0018 | ((l) << 12))
  33. #define TPM_DATA_FIFO(l) (0x0024 | ((l) << 12))
  34. #define TPM_DID_VID(l) (0x0F00 | ((l) << 12))
  35. #define TPM_RID(l) (0x0F04 | ((l) << 12))
  36. #define MAX_SPI_FRAMESIZE 64
  37. /* Number of wait states to wait for */
  38. #define TPM_WAIT_STATES 100
  39. /**
  40. * struct tpm_tis_chip_data - Non-discoverable TPM information
  41. *
  42. * @pcr_count: Number of PCR per bank
  43. * @pcr_select_min: Size in octets of the pcrSelect array
  44. */
  45. struct tpm_tis_chip_data {
  46. unsigned int pcr_count;
  47. unsigned int pcr_select_min;
  48. unsigned int time_before_first_cmd_ms;
  49. };
  50. /**
  51. * tpm_tis_spi_read() - Read from TPM register
  52. *
  53. * @addr: register address to read from
  54. * @buffer: provided by caller
  55. * @len: number of bytes to read
  56. *
  57. * Read len bytes from TPM register and put them into
  58. * buffer (little-endian format, i.e. first byte is put into buffer[0]).
  59. *
  60. * NOTE: TPM is big-endian for multi-byte values. Multi-byte
  61. * values have to be swapped.
  62. *
  63. * @return -EIO on error, 0 on success.
  64. */
  65. static int tpm_tis_spi_xfer(struct udevice *dev, u32 addr, const u8 *out,
  66. u8 *in, u16 len)
  67. {
  68. struct spi_slave *slave = dev_get_parent_priv(dev);
  69. int transfer_len, ret;
  70. u8 tx_buf[MAX_SPI_FRAMESIZE];
  71. u8 rx_buf[MAX_SPI_FRAMESIZE];
  72. if (in && out) {
  73. log(LOGC_NONE, LOGL_ERR, "%s: can't do full duplex\n",
  74. __func__);
  75. return -EINVAL;
  76. }
  77. ret = spi_claim_bus(slave);
  78. if (ret < 0) {
  79. log(LOGC_NONE, LOGL_ERR, "%s: could not claim bus\n", __func__);
  80. return ret;
  81. }
  82. while (len) {
  83. /* Request */
  84. transfer_len = min_t(u16, len, MAX_SPI_FRAMESIZE);
  85. tx_buf[0] = (in ? BIT(7) : 0) | (transfer_len - 1);
  86. tx_buf[1] = 0xD4;
  87. tx_buf[2] = addr >> 8;
  88. tx_buf[3] = addr;
  89. ret = spi_xfer(slave, 4 * 8, tx_buf, rx_buf, SPI_XFER_BEGIN);
  90. if (ret < 0) {
  91. log(LOGC_NONE, LOGL_ERR,
  92. "%s: spi request transfer failed (err: %d)\n",
  93. __func__, ret);
  94. goto release_bus;
  95. }
  96. /* Wait state */
  97. if (!(rx_buf[3] & 0x1)) {
  98. int i;
  99. for (i = 0; i < TPM_WAIT_STATES; i++) {
  100. ret = spi_xfer(slave, 1 * 8, NULL, rx_buf, 0);
  101. if (ret) {
  102. log(LOGC_NONE, LOGL_ERR,
  103. "%s: wait state failed: %d\n",
  104. __func__, ret);
  105. goto release_bus;
  106. }
  107. if (rx_buf[0] & 0x1)
  108. break;
  109. }
  110. if (i == TPM_WAIT_STATES) {
  111. log(LOGC_NONE, LOGL_ERR,
  112. "%s: timeout on wait state\n", __func__);
  113. ret = -ETIMEDOUT;
  114. goto release_bus;
  115. }
  116. }
  117. /* Read/Write */
  118. if (out) {
  119. memcpy(tx_buf, out, transfer_len);
  120. out += transfer_len;
  121. }
  122. ret = spi_xfer(slave, transfer_len * 8,
  123. out ? tx_buf : NULL,
  124. in ? rx_buf : NULL,
  125. SPI_XFER_END);
  126. if (ret) {
  127. log(LOGC_NONE, LOGL_ERR,
  128. "%s: spi read transfer failed (err: %d)\n",
  129. __func__, ret);
  130. goto release_bus;
  131. }
  132. if (in) {
  133. memcpy(in, rx_buf, transfer_len);
  134. in += transfer_len;
  135. }
  136. len -= transfer_len;
  137. }
  138. release_bus:
  139. /* If an error occurred, release the chip by deasserting the CS */
  140. if (ret < 0)
  141. spi_xfer(slave, 0, NULL, NULL, SPI_XFER_END);
  142. spi_release_bus(slave);
  143. return ret;
  144. }
  145. static int tpm_tis_spi_read(struct udevice *dev, u16 addr, u8 *in, u16 len)
  146. {
  147. return tpm_tis_spi_xfer(dev, addr, NULL, in, len);
  148. }
  149. static int tpm_tis_spi_read32(struct udevice *dev, u32 addr, u32 *result)
  150. {
  151. __le32 result_le;
  152. int ret;
  153. ret = tpm_tis_spi_read(dev, addr, (u8 *)&result_le, sizeof(u32));
  154. if (!ret)
  155. *result = le32_to_cpu(result_le);
  156. return ret;
  157. }
  158. static int tpm_tis_spi_write(struct udevice *dev, u16 addr, const u8 *out,
  159. u16 len)
  160. {
  161. return tpm_tis_spi_xfer(dev, addr, out, NULL, len);
  162. }
  163. static int tpm_tis_spi_check_locality(struct udevice *dev, int loc)
  164. {
  165. const u8 mask = TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID;
  166. struct tpm_chip *chip = dev_get_priv(dev);
  167. u8 buf;
  168. int ret;
  169. ret = tpm_tis_spi_read(dev, TPM_ACCESS(loc), &buf, 1);
  170. if (ret)
  171. return ret;
  172. if ((buf & mask) == mask) {
  173. chip->locality = loc;
  174. return 0;
  175. }
  176. return -ENOENT;
  177. }
  178. static void tpm_tis_spi_release_locality(struct udevice *dev, int loc,
  179. bool force)
  180. {
  181. const u8 mask = TPM_ACCESS_REQUEST_PENDING | TPM_ACCESS_VALID;
  182. u8 buf;
  183. if (tpm_tis_spi_read(dev, TPM_ACCESS(loc), &buf, 1) < 0)
  184. return;
  185. if (force || (buf & mask) == mask) {
  186. buf = TPM_ACCESS_ACTIVE_LOCALITY;
  187. tpm_tis_spi_write(dev, TPM_ACCESS(loc), &buf, 1);
  188. }
  189. }
  190. static int tpm_tis_spi_request_locality(struct udevice *dev, int loc)
  191. {
  192. struct tpm_chip *chip = dev_get_priv(dev);
  193. unsigned long start, stop;
  194. u8 buf = TPM_ACCESS_REQUEST_USE;
  195. int ret;
  196. ret = tpm_tis_spi_check_locality(dev, loc);
  197. if (!ret)
  198. return 0;
  199. if (ret != -ENOENT) {
  200. log(LOGC_NONE, LOGL_ERR, "%s: Failed to get locality: %d\n",
  201. __func__, ret);
  202. return ret;
  203. }
  204. ret = tpm_tis_spi_write(dev, TPM_ACCESS(loc), &buf, 1);
  205. if (ret) {
  206. log(LOGC_NONE, LOGL_ERR, "%s: Failed to write to TPM: %d\n",
  207. __func__, ret);
  208. return ret;
  209. }
  210. start = get_timer(0);
  211. stop = chip->timeout_a;
  212. do {
  213. ret = tpm_tis_spi_check_locality(dev, loc);
  214. if (!ret)
  215. return 0;
  216. if (ret != -ENOENT) {
  217. log(LOGC_NONE, LOGL_ERR,
  218. "%s: Failed to get locality: %d\n", __func__, ret);
  219. return ret;
  220. }
  221. mdelay(TPM_TIMEOUT_MS);
  222. } while (get_timer(start) < stop);
  223. log(LOGC_NONE, LOGL_ERR, "%s: Timeout getting locality: %d\n", __func__,
  224. ret);
  225. return ret;
  226. }
  227. static u8 tpm_tis_spi_status(struct udevice *dev, u8 *status)
  228. {
  229. struct tpm_chip *chip = dev_get_priv(dev);
  230. return tpm_tis_spi_read(dev, TPM_STS(chip->locality), status, 1);
  231. }
  232. static int tpm_tis_spi_wait_for_stat(struct udevice *dev, u8 mask,
  233. unsigned long timeout, u8 *status)
  234. {
  235. unsigned long start = get_timer(0);
  236. unsigned long stop = timeout;
  237. int ret;
  238. do {
  239. mdelay(TPM_TIMEOUT_MS);
  240. ret = tpm_tis_spi_status(dev, status);
  241. if (ret)
  242. return ret;
  243. if ((*status & mask) == mask)
  244. return 0;
  245. } while (get_timer(start) < stop);
  246. return -ETIMEDOUT;
  247. }
  248. static u8 tpm_tis_spi_valid_status(struct udevice *dev, u8 *status)
  249. {
  250. struct tpm_chip *chip = dev_get_priv(dev);
  251. return tpm_tis_spi_wait_for_stat(dev, TPM_STS_VALID,
  252. chip->timeout_c, status);
  253. }
  254. static int tpm_tis_spi_get_burstcount(struct udevice *dev)
  255. {
  256. struct tpm_chip *chip = dev_get_priv(dev);
  257. unsigned long start, stop;
  258. u32 burstcount, ret;
  259. /* wait for burstcount */
  260. start = get_timer(0);
  261. stop = chip->timeout_d;
  262. do {
  263. ret = tpm_tis_spi_read32(dev, TPM_STS(chip->locality),
  264. &burstcount);
  265. if (ret)
  266. return -EBUSY;
  267. burstcount = (burstcount >> 8) & 0xFFFF;
  268. if (burstcount)
  269. return burstcount;
  270. mdelay(TPM_TIMEOUT_MS);
  271. } while (get_timer(start) < stop);
  272. return -EBUSY;
  273. }
  274. static int tpm_tis_spi_cancel(struct udevice *dev)
  275. {
  276. struct tpm_chip *chip = dev_get_priv(dev);
  277. u8 data = TPM_STS_COMMAND_READY;
  278. return tpm_tis_spi_write(dev, TPM_STS(chip->locality), &data, 1);
  279. }
  280. static int tpm_tis_spi_recv_data(struct udevice *dev, u8 *buf, size_t count)
  281. {
  282. struct tpm_chip *chip = dev_get_priv(dev);
  283. int size = 0, burstcnt, len, ret;
  284. u8 status;
  285. while (size < count &&
  286. tpm_tis_spi_wait_for_stat(dev,
  287. TPM_STS_DATA_AVAIL | TPM_STS_VALID,
  288. chip->timeout_c, &status) == 0) {
  289. burstcnt = tpm_tis_spi_get_burstcount(dev);
  290. if (burstcnt < 0)
  291. return burstcnt;
  292. len = min_t(int, burstcnt, count - size);
  293. ret = tpm_tis_spi_read(dev, TPM_DATA_FIFO(chip->locality),
  294. buf + size, len);
  295. if (ret < 0)
  296. return ret;
  297. size += len;
  298. }
  299. return size;
  300. }
  301. static int tpm_tis_spi_recv(struct udevice *dev, u8 *buf, size_t count)
  302. {
  303. struct tpm_chip *chip = dev_get_priv(dev);
  304. int size, expected;
  305. if (!chip)
  306. return -ENODEV;
  307. if (count < TPM_HEADER_SIZE) {
  308. size = -EIO;
  309. goto out;
  310. }
  311. size = tpm_tis_spi_recv_data(dev, buf, TPM_HEADER_SIZE);
  312. if (size < TPM_HEADER_SIZE) {
  313. log(LOGC_NONE, LOGL_ERR, "TPM error, unable to read header\n");
  314. goto out;
  315. }
  316. expected = get_unaligned_be32(buf + 2);
  317. if (expected > count) {
  318. size = -EIO;
  319. goto out;
  320. }
  321. size += tpm_tis_spi_recv_data(dev, &buf[TPM_HEADER_SIZE],
  322. expected - TPM_HEADER_SIZE);
  323. if (size < expected) {
  324. log(LOGC_NONE, LOGL_ERR,
  325. "TPM error, unable to read remaining bytes of result\n");
  326. size = -EIO;
  327. goto out;
  328. }
  329. out:
  330. tpm_tis_spi_cancel(dev);
  331. tpm_tis_spi_release_locality(dev, chip->locality, false);
  332. return size;
  333. }
  334. static int tpm_tis_spi_send(struct udevice *dev, const u8 *buf, size_t len)
  335. {
  336. struct tpm_chip *chip = dev_get_priv(dev);
  337. u32 i, size;
  338. u8 status;
  339. int burstcnt, ret;
  340. u8 data;
  341. if (!chip)
  342. return -ENODEV;
  343. if (len > TPM_DEV_BUFSIZE)
  344. return -E2BIG; /* Command is too long for our tpm, sorry */
  345. ret = tpm_tis_spi_request_locality(dev, 0);
  346. if (ret < 0)
  347. return -EBUSY;
  348. /*
  349. * Check if the TPM is ready. If not, if not, cancel the pending command
  350. * and poll on the status to be finally ready.
  351. */
  352. ret = tpm_tis_spi_status(dev, &status);
  353. if (ret)
  354. return ret;
  355. if (!(status & TPM_STS_COMMAND_READY)) {
  356. /* Force the transition, usually this will be done at startup */
  357. ret = tpm_tis_spi_cancel(dev);
  358. if (ret) {
  359. log(LOGC_NONE, LOGL_ERR,
  360. "%s: Could not cancel previous operation\n",
  361. __func__);
  362. goto out_err;
  363. }
  364. ret = tpm_tis_spi_wait_for_stat(dev, TPM_STS_COMMAND_READY,
  365. chip->timeout_b, &status);
  366. if (ret < 0 || !(status & TPM_STS_COMMAND_READY)) {
  367. log(LOGC_NONE, LOGL_ERR,
  368. "status %d after wait for stat returned %d\n",
  369. status, ret);
  370. goto out_err;
  371. }
  372. }
  373. for (i = 0; i < len - 1;) {
  374. burstcnt = tpm_tis_spi_get_burstcount(dev);
  375. if (burstcnt < 0)
  376. return burstcnt;
  377. size = min_t(int, len - i - 1, burstcnt);
  378. ret = tpm_tis_spi_write(dev, TPM_DATA_FIFO(chip->locality),
  379. buf + i, size);
  380. if (ret < 0)
  381. goto out_err;
  382. i += size;
  383. }
  384. ret = tpm_tis_spi_valid_status(dev, &status);
  385. if (ret)
  386. goto out_err;
  387. if ((status & TPM_STS_DATA_EXPECT) == 0) {
  388. ret = -EIO;
  389. goto out_err;
  390. }
  391. ret = tpm_tis_spi_write(dev, TPM_DATA_FIFO(chip->locality),
  392. buf + len - 1, 1);
  393. if (ret)
  394. goto out_err;
  395. ret = tpm_tis_spi_valid_status(dev, &status);
  396. if (ret)
  397. goto out_err;
  398. if ((status & TPM_STS_DATA_EXPECT) != 0) {
  399. ret = -EIO;
  400. goto out_err;
  401. }
  402. data = TPM_STS_GO;
  403. ret = tpm_tis_spi_write(dev, TPM_STS(chip->locality), &data, 1);
  404. if (ret)
  405. goto out_err;
  406. return len;
  407. out_err:
  408. tpm_tis_spi_cancel(dev);
  409. tpm_tis_spi_release_locality(dev, chip->locality, false);
  410. return ret;
  411. }
  412. static int tpm_tis_spi_cleanup(struct udevice *dev)
  413. {
  414. struct tpm_chip *chip = dev_get_priv(dev);
  415. tpm_tis_spi_cancel(dev);
  416. /*
  417. * The TPM needs some time to clean up here,
  418. * so we sleep rather than keeping the bus busy
  419. */
  420. mdelay(2);
  421. tpm_tis_spi_release_locality(dev, chip->locality, false);
  422. return 0;
  423. }
  424. static int tpm_tis_spi_open(struct udevice *dev)
  425. {
  426. struct tpm_chip *chip = dev_get_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 = "tcg,tpm_tis-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 = sizeof(struct tpm_chip),
  563. };