2 * Copyright (C) 2005, 2006 IBM Corporation
3 * Copyright (C) 2014, 2015 Intel Corporation
6 * Leendert van Doorn <leendert@watson.ibm.com>
7 * Kylene Hall <kjhall@us.ibm.com>
9 * Maintained by: <tpmdd-devel@lists.sourceforge.net>
11 * Device driver for TCG/TCPA TPM (trusted platform module).
12 * Specifications at www.trustedcomputinggroup.org
14 * This device driver implements the TPM interface as defined in
15 * the TCG TPM Interface Spec version 1.2, revision 1.0.
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License as
19 * published by the Free Software Foundation, version 2 of the
22 #include <linux/init.h>
23 #include <linux/module.h>
24 #include <linux/moduleparam.h>
25 #include <linux/pnp.h>
26 #include <linux/slab.h>
27 #include <linux/interrupt.h>
28 #include <linux/wait.h>
29 #include <linux/acpi.h>
30 #include <linux/freezer.h>
32 #include "tpm_tis_core.h"
34 /* Before we attempt to access the TPM we must see that the valid bit is set.
35 * The specification says that this bit is 0 at reset and remains 0 until the
36 * 'TPM has gone through its self test and initialization and has established
37 * correct values in the other bits.'
39 static int wait_startup(struct tpm_chip
*chip
, int l
)
41 struct tpm_tis_data
*priv
= dev_get_drvdata(&chip
->dev
);
42 unsigned long stop
= jiffies
+ chip
->timeout_a
;
48 rc
= tpm_tis_read8(priv
, TPM_ACCESS(l
), &access
);
52 if (access
& TPM_ACCESS_VALID
)
55 } while (time_before(jiffies
, stop
));
59 static int check_locality(struct tpm_chip
*chip
, int l
)
61 struct tpm_tis_data
*priv
= dev_get_drvdata(&chip
->dev
);
65 rc
= tpm_tis_read8(priv
, TPM_ACCESS(l
), &access
);
69 if ((access
& (TPM_ACCESS_ACTIVE_LOCALITY
| TPM_ACCESS_VALID
)) ==
70 (TPM_ACCESS_ACTIVE_LOCALITY
| TPM_ACCESS_VALID
))
71 return priv
->locality
= l
;
76 static void release_locality(struct tpm_chip
*chip
, int l
, int force
)
78 struct tpm_tis_data
*priv
= dev_get_drvdata(&chip
->dev
);
82 rc
= tpm_tis_read8(priv
, TPM_ACCESS(l
), &access
);
86 if (force
|| (access
&
87 (TPM_ACCESS_REQUEST_PENDING
| TPM_ACCESS_VALID
)) ==
88 (TPM_ACCESS_REQUEST_PENDING
| TPM_ACCESS_VALID
))
89 tpm_tis_write8(priv
, TPM_ACCESS(l
), TPM_ACCESS_ACTIVE_LOCALITY
);
93 static int request_locality(struct tpm_chip
*chip
, int l
)
95 struct tpm_tis_data
*priv
= dev_get_drvdata(&chip
->dev
);
96 unsigned long stop
, timeout
;
99 if (check_locality(chip
, l
) >= 0)
102 rc
= tpm_tis_write8(priv
, TPM_ACCESS(l
), TPM_ACCESS_REQUEST_USE
);
106 stop
= jiffies
+ chip
->timeout_a
;
108 if (chip
->flags
& TPM_CHIP_FLAG_IRQ
) {
110 timeout
= stop
- jiffies
;
111 if ((long)timeout
<= 0)
113 rc
= wait_event_interruptible_timeout(priv
->int_queue
,
119 if (rc
== -ERESTARTSYS
&& freezing(current
)) {
120 clear_thread_flag(TIF_SIGPENDING
);
124 /* wait for burstcount */
126 if (check_locality(chip
, l
) >= 0)
129 } while (time_before(jiffies
, stop
));
134 static u8
tpm_tis_status(struct tpm_chip
*chip
)
136 struct tpm_tis_data
*priv
= dev_get_drvdata(&chip
->dev
);
140 rc
= tpm_tis_read8(priv
, TPM_STS(priv
->locality
), &status
);
147 static void tpm_tis_ready(struct tpm_chip
*chip
)
149 struct tpm_tis_data
*priv
= dev_get_drvdata(&chip
->dev
);
151 /* this causes the current command to be aborted */
152 tpm_tis_write8(priv
, TPM_STS(priv
->locality
), TPM_STS_COMMAND_READY
);
155 static int get_burstcount(struct tpm_chip
*chip
)
157 struct tpm_tis_data
*priv
= dev_get_drvdata(&chip
->dev
);
162 /* wait for burstcount */
163 /* which timeout value, spec has 2 answers (c & d) */
164 stop
= jiffies
+ chip
->timeout_d
;
166 rc
= tpm_tis_read32(priv
, TPM_STS(priv
->locality
), &value
);
170 burstcnt
= (value
>> 8) & 0xFFFF;
174 } while (time_before(jiffies
, stop
));
178 static int recv_data(struct tpm_chip
*chip
, u8
*buf
, size_t count
)
180 struct tpm_tis_data
*priv
= dev_get_drvdata(&chip
->dev
);
181 int size
= 0, burstcnt
, rc
;
183 while (size
< count
&&
184 wait_for_tpm_stat(chip
,
185 TPM_STS_DATA_AVAIL
| TPM_STS_VALID
,
187 &priv
->read_queue
, true) == 0) {
188 burstcnt
= min_t(int, get_burstcount(chip
), count
- size
);
190 rc
= tpm_tis_read_bytes(priv
, TPM_DATA_FIFO(priv
->locality
),
191 burstcnt
, buf
+ size
);
200 static int tpm_tis_recv(struct tpm_chip
*chip
, u8
*buf
, size_t count
)
202 struct tpm_tis_data
*priv
= dev_get_drvdata(&chip
->dev
);
204 int expected
, status
;
206 if (count
< TPM_HEADER_SIZE
) {
211 size
= recv_data(chip
, buf
, TPM_HEADER_SIZE
);
212 /* read first 10 bytes, including tag, paramsize, and result */
213 if (size
< TPM_HEADER_SIZE
) {
214 dev_err(&chip
->dev
, "Unable to read header\n");
218 expected
= be32_to_cpu(*(__be32
*) (buf
+ 2));
219 if (expected
> count
) {
224 size
+= recv_data(chip
, &buf
[TPM_HEADER_SIZE
],
225 expected
- TPM_HEADER_SIZE
);
226 if (size
< expected
) {
227 dev_err(&chip
->dev
, "Unable to read remainder of result\n");
232 wait_for_tpm_stat(chip
, TPM_STS_VALID
, chip
->timeout_c
,
233 &priv
->int_queue
, false);
234 status
= tpm_tis_status(chip
);
235 if (status
& TPM_STS_DATA_AVAIL
) { /* retry? */
236 dev_err(&chip
->dev
, "Error left over data\n");
243 release_locality(chip
, priv
->locality
, 0);
248 * If interrupts are used (signaled by an irq set in the vendor structure)
249 * tpm.c can skip polling for the data to be available as the interrupt is
252 static int tpm_tis_send_data(struct tpm_chip
*chip
, u8
*buf
, size_t len
)
254 struct tpm_tis_data
*priv
= dev_get_drvdata(&chip
->dev
);
255 int rc
, status
, burstcnt
;
257 bool itpm
= priv
->flags
& TPM_TIS_ITPM_POSSIBLE
;
259 if (request_locality(chip
, 0) < 0)
262 status
= tpm_tis_status(chip
);
263 if ((status
& TPM_STS_COMMAND_READY
) == 0) {
265 if (wait_for_tpm_stat
266 (chip
, TPM_STS_COMMAND_READY
, chip
->timeout_b
,
267 &priv
->int_queue
, false) < 0) {
273 while (count
< len
- 1) {
274 burstcnt
= min_t(int, get_burstcount(chip
), len
- count
- 1);
275 rc
= tpm_tis_write_bytes(priv
, TPM_DATA_FIFO(priv
->locality
),
276 burstcnt
, buf
+ count
);
282 wait_for_tpm_stat(chip
, TPM_STS_VALID
, chip
->timeout_c
,
283 &priv
->int_queue
, false);
284 status
= tpm_tis_status(chip
);
285 if (!itpm
&& (status
& TPM_STS_DATA_EXPECT
) == 0) {
291 /* write last byte */
292 rc
= tpm_tis_write8(priv
, TPM_DATA_FIFO(priv
->locality
), buf
[count
]);
296 wait_for_tpm_stat(chip
, TPM_STS_VALID
, chip
->timeout_c
,
297 &priv
->int_queue
, false);
298 status
= tpm_tis_status(chip
);
299 if (!itpm
&& (status
& TPM_STS_DATA_EXPECT
) != 0) {
308 release_locality(chip
, priv
->locality
, 0);
312 static void disable_interrupts(struct tpm_chip
*chip
)
314 struct tpm_tis_data
*priv
= dev_get_drvdata(&chip
->dev
);
318 rc
= tpm_tis_read32(priv
, TPM_INT_ENABLE(priv
->locality
), &intmask
);
322 intmask
&= ~TPM_GLOBAL_INT_ENABLE
;
323 rc
= tpm_tis_write32(priv
, TPM_INT_ENABLE(priv
->locality
), intmask
);
325 devm_free_irq(chip
->dev
.parent
, priv
->irq
, chip
);
327 chip
->flags
&= ~TPM_CHIP_FLAG_IRQ
;
331 * If interrupts are used (signaled by an irq set in the vendor structure)
332 * tpm.c can skip polling for the data to be available as the interrupt is
335 static int tpm_tis_send_main(struct tpm_chip
*chip
, u8
*buf
, size_t len
)
337 struct tpm_tis_data
*priv
= dev_get_drvdata(&chip
->dev
);
342 rc
= tpm_tis_send_data(chip
, buf
, len
);
347 rc
= tpm_tis_write8(priv
, TPM_STS(priv
->locality
), TPM_STS_GO
);
351 if (chip
->flags
& TPM_CHIP_FLAG_IRQ
) {
352 ordinal
= be32_to_cpu(*((__be32
*) (buf
+ 6)));
354 if (chip
->flags
& TPM_CHIP_FLAG_TPM2
)
355 dur
= tpm2_calc_ordinal_duration(chip
, ordinal
);
357 dur
= tpm_calc_ordinal_duration(chip
, ordinal
);
359 if (wait_for_tpm_stat
360 (chip
, TPM_STS_DATA_AVAIL
| TPM_STS_VALID
, dur
,
361 &priv
->read_queue
, false) < 0) {
369 release_locality(chip
, priv
->locality
, 0);
373 static int tpm_tis_send(struct tpm_chip
*chip
, u8
*buf
, size_t len
)
376 struct tpm_tis_data
*priv
= dev_get_drvdata(&chip
->dev
);
378 if (!(chip
->flags
& TPM_CHIP_FLAG_IRQ
) || priv
->irq_tested
)
379 return tpm_tis_send_main(chip
, buf
, len
);
381 /* Verify receipt of the expected IRQ */
384 chip
->flags
&= ~TPM_CHIP_FLAG_IRQ
;
385 rc
= tpm_tis_send_main(chip
, buf
, len
);
387 chip
->flags
|= TPM_CHIP_FLAG_IRQ
;
388 if (!priv
->irq_tested
)
390 if (!priv
->irq_tested
)
391 disable_interrupts(chip
);
392 priv
->irq_tested
= true;
396 struct tis_vendor_timeout_override
{
398 unsigned long timeout_us
[4];
401 static const struct tis_vendor_timeout_override vendor_timeout_overrides
[] = {
403 { 0x32041114, { (TIS_SHORT_TIMEOUT
*1000), (TIS_LONG_TIMEOUT
*1000),
404 (TIS_SHORT_TIMEOUT
*1000), (TIS_SHORT_TIMEOUT
*1000) } },
407 static bool tpm_tis_update_timeouts(struct tpm_chip
*chip
,
408 unsigned long *timeout_cap
)
410 struct tpm_tis_data
*priv
= dev_get_drvdata(&chip
->dev
);
414 rc
= tpm_tis_read32(priv
, TPM_DID_VID(0), &did_vid
);
418 for (i
= 0; i
!= ARRAY_SIZE(vendor_timeout_overrides
); i
++) {
419 if (vendor_timeout_overrides
[i
].did_vid
!= did_vid
)
421 memcpy(timeout_cap
, vendor_timeout_overrides
[i
].timeout_us
,
422 sizeof(vendor_timeout_overrides
[i
].timeout_us
));
430 * Early probing for iTPM with STS_DATA_EXPECT flaw.
431 * Try sending command without itpm flag set and if that
432 * fails, repeat with itpm flag set.
434 static int probe_itpm(struct tpm_chip
*chip
)
436 struct tpm_tis_data
*priv
= dev_get_drvdata(&chip
->dev
);
438 u8 cmd_getticks
[] = {
439 0x00, 0xc1, 0x00, 0x00, 0x00, 0x0a,
440 0x00, 0x00, 0x00, 0xf1
442 size_t len
= sizeof(cmd_getticks
);
446 rc
= tpm_tis_read16(priv
, TPM_DID_VID(0), &vendor
);
450 /* probe only iTPMS */
451 if (vendor
!= TPM_VID_INTEL
)
456 rc
= tpm_tis_send_data(chip
, cmd_getticks
, len
);
461 release_locality(chip
, priv
->locality
, 0);
465 rc
= tpm_tis_send_data(chip
, cmd_getticks
, len
);
467 dev_info(&chip
->dev
, "Detected an iTPM.\n");
474 release_locality(chip
, priv
->locality
, 0);
479 static bool tpm_tis_req_canceled(struct tpm_chip
*chip
, u8 status
)
481 struct tpm_tis_data
*priv
= dev_get_drvdata(&chip
->dev
);
483 switch (priv
->manufacturer_id
) {
484 case TPM_VID_WINBOND
:
485 return ((status
== TPM_STS_VALID
) ||
486 (status
== (TPM_STS_VALID
| TPM_STS_COMMAND_READY
)));
488 return (status
== (TPM_STS_VALID
| TPM_STS_COMMAND_READY
));
490 return (status
== TPM_STS_COMMAND_READY
);
494 static irqreturn_t
tis_int_handler(int dummy
, void *dev_id
)
496 struct tpm_chip
*chip
= dev_id
;
497 struct tpm_tis_data
*priv
= dev_get_drvdata(&chip
->dev
);
501 rc
= tpm_tis_read32(priv
, TPM_INT_STATUS(priv
->locality
), &interrupt
);
508 priv
->irq_tested
= true;
509 if (interrupt
& TPM_INTF_DATA_AVAIL_INT
)
510 wake_up_interruptible(&priv
->read_queue
);
511 if (interrupt
& TPM_INTF_LOCALITY_CHANGE_INT
)
512 for (i
= 0; i
< 5; i
++)
513 if (check_locality(chip
, i
) >= 0)
516 (TPM_INTF_LOCALITY_CHANGE_INT
| TPM_INTF_STS_VALID_INT
|
517 TPM_INTF_CMD_READY_INT
))
518 wake_up_interruptible(&priv
->int_queue
);
520 /* Clear interrupts handled with TPM_EOI */
521 rc
= tpm_tis_write32(priv
, TPM_INT_STATUS(priv
->locality
), interrupt
);
525 tpm_tis_read32(priv
, TPM_INT_STATUS(priv
->locality
), &interrupt
);
529 /* Register the IRQ and issue a command that will cause an interrupt. If an
530 * irq is seen then leave the chip setup for IRQ operation, otherwise reverse
531 * everything and leave in polling mode. Returns 0 on success.
533 static int tpm_tis_probe_irq_single(struct tpm_chip
*chip
, u32 intmask
,
536 struct tpm_tis_data
*priv
= dev_get_drvdata(&chip
->dev
);
541 if (devm_request_irq(chip
->dev
.parent
, irq
, tis_int_handler
, flags
,
542 dev_name(&chip
->dev
), chip
) != 0) {
543 dev_info(&chip
->dev
, "Unable to request irq: %d for probe\n",
549 rc
= tpm_tis_read8(priv
, TPM_INT_VECTOR(priv
->locality
),
554 rc
= tpm_tis_write8(priv
, TPM_INT_VECTOR(priv
->locality
), irq
);
558 rc
= tpm_tis_read32(priv
, TPM_INT_STATUS(priv
->locality
), &int_status
);
562 /* Clear all existing */
563 rc
= tpm_tis_write32(priv
, TPM_INT_STATUS(priv
->locality
), int_status
);
568 rc
= tpm_tis_write32(priv
, TPM_INT_ENABLE(priv
->locality
),
569 intmask
| TPM_GLOBAL_INT_ENABLE
);
573 priv
->irq_tested
= false;
575 /* Generate an interrupt by having the core call through to
578 if (chip
->flags
& TPM_CHIP_FLAG_TPM2
)
579 tpm2_gen_interrupt(chip
);
581 tpm_gen_interrupt(chip
);
583 /* tpm_tis_send will either confirm the interrupt is working or it
584 * will call disable_irq which undoes all of the above.
586 if (!(chip
->flags
& TPM_CHIP_FLAG_IRQ
)) {
587 rc
= tpm_tis_write8(priv
, original_int_vec
,
588 TPM_INT_VECTOR(priv
->locality
));
598 /* Try to find the IRQ the TPM is using. This is for legacy x86 systems that
599 * do not have ACPI/etc. We typically expect the interrupt to be declared if
602 static void tpm_tis_probe_irq(struct tpm_chip
*chip
, u32 intmask
)
604 struct tpm_tis_data
*priv
= dev_get_drvdata(&chip
->dev
);
608 rc
= tpm_tis_read8(priv
, TPM_INT_VECTOR(priv
->locality
),
613 if (!original_int_vec
) {
614 if (IS_ENABLED(CONFIG_X86
))
615 for (i
= 3; i
<= 15; i
++)
616 if (!tpm_tis_probe_irq_single(chip
, intmask
, 0,
619 } else if (!tpm_tis_probe_irq_single(chip
, intmask
, 0,
624 void tpm_tis_remove(struct tpm_chip
*chip
)
626 struct tpm_tis_data
*priv
= dev_get_drvdata(&chip
->dev
);
627 u32 reg
= TPM_INT_ENABLE(priv
->locality
);
631 rc
= tpm_tis_read32(priv
, reg
, &interrupt
);
635 tpm_tis_write32(priv
, reg
, ~TPM_GLOBAL_INT_ENABLE
& interrupt
);
636 release_locality(chip
, priv
->locality
, 1);
638 EXPORT_SYMBOL_GPL(tpm_tis_remove
);
640 static const struct tpm_class_ops tpm_tis
= {
641 .flags
= TPM_OPS_AUTO_STARTUP
,
642 .status
= tpm_tis_status
,
643 .recv
= tpm_tis_recv
,
644 .send
= tpm_tis_send
,
645 .cancel
= tpm_tis_ready
,
646 .update_timeouts
= tpm_tis_update_timeouts
,
647 .req_complete_mask
= TPM_STS_DATA_AVAIL
| TPM_STS_VALID
,
648 .req_complete_val
= TPM_STS_DATA_AVAIL
| TPM_STS_VALID
,
649 .req_canceled
= tpm_tis_req_canceled
,
652 int tpm_tis_core_init(struct device
*dev
, struct tpm_tis_data
*priv
, int irq
,
653 const struct tpm_tis_phy_ops
*phy_ops
,
654 acpi_handle acpi_dev_handle
)
656 u32 vendor
, intfcaps
, intmask
;
659 struct tpm_chip
*chip
;
661 chip
= tpmm_chip_alloc(dev
, &tpm_tis
);
663 return PTR_ERR(chip
);
666 chip
->acpi_dev_handle
= acpi_dev_handle
;
669 /* Maximum timeouts */
670 chip
->timeout_a
= msecs_to_jiffies(TIS_TIMEOUT_A_MAX
);
671 chip
->timeout_b
= msecs_to_jiffies(TIS_TIMEOUT_B_MAX
);
672 chip
->timeout_c
= msecs_to_jiffies(TIS_TIMEOUT_C_MAX
);
673 chip
->timeout_d
= msecs_to_jiffies(TIS_TIMEOUT_D_MAX
);
674 priv
->phy_ops
= phy_ops
;
675 dev_set_drvdata(&chip
->dev
, priv
);
677 if (wait_startup(chip
, 0) != 0) {
682 /* Take control of the TPM's interrupt hardware and shut it off */
683 rc
= tpm_tis_read32(priv
, TPM_INT_ENABLE(priv
->locality
), &intmask
);
687 intmask
|= TPM_INTF_CMD_READY_INT
| TPM_INTF_LOCALITY_CHANGE_INT
|
688 TPM_INTF_DATA_AVAIL_INT
| TPM_INTF_STS_VALID_INT
;
689 intmask
&= ~TPM_GLOBAL_INT_ENABLE
;
690 tpm_tis_write32(priv
, TPM_INT_ENABLE(priv
->locality
), intmask
);
692 if (request_locality(chip
, 0) != 0) {
697 rc
= tpm2_probe(chip
);
701 rc
= tpm_tis_read32(priv
, TPM_DID_VID(0), &vendor
);
705 priv
->manufacturer_id
= vendor
;
707 rc
= tpm_tis_read8(priv
, TPM_RID(0), &rid
);
711 dev_info(dev
, "%s TPM (device-id 0x%X, rev-id %d)\n",
712 (chip
->flags
& TPM_CHIP_FLAG_TPM2
) ? "2.0" : "1.2",
715 if (!(priv
->flags
& TPM_TIS_ITPM_POSSIBLE
)) {
716 probe
= probe_itpm(chip
);
723 priv
->flags
|= TPM_TIS_ITPM_POSSIBLE
;
726 /* Figure out the capabilities */
727 rc
= tpm_tis_read32(priv
, TPM_INTF_CAPS(priv
->locality
), &intfcaps
);
731 dev_dbg(dev
, "TPM interface capabilities (0x%x):\n",
733 if (intfcaps
& TPM_INTF_BURST_COUNT_STATIC
)
734 dev_dbg(dev
, "\tBurst Count Static\n");
735 if (intfcaps
& TPM_INTF_CMD_READY_INT
)
736 dev_dbg(dev
, "\tCommand Ready Int Support\n");
737 if (intfcaps
& TPM_INTF_INT_EDGE_FALLING
)
738 dev_dbg(dev
, "\tInterrupt Edge Falling\n");
739 if (intfcaps
& TPM_INTF_INT_EDGE_RISING
)
740 dev_dbg(dev
, "\tInterrupt Edge Rising\n");
741 if (intfcaps
& TPM_INTF_INT_LEVEL_LOW
)
742 dev_dbg(dev
, "\tInterrupt Level Low\n");
743 if (intfcaps
& TPM_INTF_INT_LEVEL_HIGH
)
744 dev_dbg(dev
, "\tInterrupt Level High\n");
745 if (intfcaps
& TPM_INTF_LOCALITY_CHANGE_INT
)
746 dev_dbg(dev
, "\tLocality Change Int Support\n");
747 if (intfcaps
& TPM_INTF_STS_VALID_INT
)
748 dev_dbg(dev
, "\tSts Valid Int Support\n");
749 if (intfcaps
& TPM_INTF_DATA_AVAIL_INT
)
750 dev_dbg(dev
, "\tData Avail Int Support\n");
752 /* Very early on issue a command to the TPM in polling mode to make
753 * sure it works. May as well use that command to set the proper
754 * timeouts for the driver.
756 if (tpm_get_timeouts(chip
)) {
757 dev_err(dev
, "Could not get TPM timeouts and durations\n");
762 /* INTERRUPT Setup */
763 init_waitqueue_head(&priv
->read_queue
);
764 init_waitqueue_head(&priv
->int_queue
);
767 tpm_tis_probe_irq_single(chip
, intmask
, IRQF_SHARED
,
769 if (!(chip
->flags
& TPM_CHIP_FLAG_IRQ
))
770 dev_err(&chip
->dev
, FW_BUG
771 "TPM interrupt not working, polling instead\n");
773 tpm_tis_probe_irq(chip
, intmask
);
777 return tpm_chip_register(chip
);
779 tpm_tis_remove(chip
);
782 EXPORT_SYMBOL_GPL(tpm_tis_core_init
);
784 #ifdef CONFIG_PM_SLEEP
785 static void tpm_tis_reenable_interrupts(struct tpm_chip
*chip
)
787 struct tpm_tis_data
*priv
= dev_get_drvdata(&chip
->dev
);
791 /* reenable interrupts that device may have lost or
792 * BIOS/firmware may have disabled
794 rc
= tpm_tis_write8(priv
, TPM_INT_VECTOR(priv
->locality
), priv
->irq
);
798 rc
= tpm_tis_read32(priv
, TPM_INT_ENABLE(priv
->locality
), &intmask
);
802 intmask
|= TPM_INTF_CMD_READY_INT
803 | TPM_INTF_LOCALITY_CHANGE_INT
| TPM_INTF_DATA_AVAIL_INT
804 | TPM_INTF_STS_VALID_INT
| TPM_GLOBAL_INT_ENABLE
;
806 tpm_tis_write32(priv
, TPM_INT_ENABLE(priv
->locality
), intmask
);
809 int tpm_tis_resume(struct device
*dev
)
811 struct tpm_chip
*chip
= dev_get_drvdata(dev
);
814 if (chip
->flags
& TPM_CHIP_FLAG_IRQ
)
815 tpm_tis_reenable_interrupts(chip
);
817 ret
= tpm_pm_resume(dev
);
821 /* TPM 1.2 requires self-test on resume. This function actually returns
822 * an error code but for unknown reason it isn't handled.
824 if (!(chip
->flags
& TPM_CHIP_FLAG_TPM2
))
825 tpm_do_selftest(chip
);
829 EXPORT_SYMBOL_GPL(tpm_tis_resume
);
832 MODULE_AUTHOR("Leendert van Doorn (leendert@watson.ibm.com)");
833 MODULE_DESCRIPTION("TPM Driver");
834 MODULE_VERSION("2.0");
835 MODULE_LICENSE("GPL");