2 * Copyright (C) 2005, 2006 IBM Corporation
5 * Leendert van Doorn <leendert@watson.ibm.com>
6 * Kylene Hall <kjhall@us.ibm.com>
8 * Maintained by: <tpmdd-devel@lists.sourceforge.net>
10 * Device driver for TCG/TCPA TPM (trusted platform module).
11 * Specifications at www.trustedcomputinggroup.org
13 * This device driver implements the TPM interface as defined in
14 * the TCG TPM Interface Spec version 1.2, revision 1.0.
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation, version 2 of the
21 #include <linux/init.h>
22 #include <linux/module.h>
23 #include <linux/moduleparam.h>
24 #include <linux/pnp.h>
25 #include <linux/slab.h>
26 #include <linux/interrupt.h>
27 #include <linux/wait.h>
28 #include <linux/acpi.h>
29 #include <linux/freezer.h>
33 TPM_ACCESS_VALID = 0x80,
34 TPM_ACCESS_ACTIVE_LOCALITY = 0x20,
35 TPM_ACCESS_REQUEST_PENDING = 0x04,
36 TPM_ACCESS_REQUEST_USE = 0x02,
41 TPM_STS_COMMAND_READY = 0x40,
43 TPM_STS_DATA_AVAIL = 0x10,
44 TPM_STS_DATA_EXPECT = 0x08,
48 TPM_GLOBAL_INT_ENABLE = 0x80000000,
49 TPM_INTF_BURST_COUNT_STATIC = 0x100,
50 TPM_INTF_CMD_READY_INT = 0x080,
51 TPM_INTF_INT_EDGE_FALLING = 0x040,
52 TPM_INTF_INT_EDGE_RISING = 0x020,
53 TPM_INTF_INT_LEVEL_LOW = 0x010,
54 TPM_INTF_INT_LEVEL_HIGH = 0x008,
55 TPM_INTF_LOCALITY_CHANGE_INT = 0x004,
56 TPM_INTF_STS_VALID_INT = 0x002,
57 TPM_INTF_DATA_AVAIL_INT = 0x001,
61 TIS_MEM_BASE = 0xFED40000,
63 TIS_SHORT_TIMEOUT = 750, /* ms */
64 TIS_LONG_TIMEOUT = 2000, /* 2 sec */
67 #define TPM_ACCESS(l) (0x0000 | ((l) << 12))
68 #define TPM_INT_ENABLE(l) (0x0008 | ((l) << 12))
69 #define TPM_INT_VECTOR(l) (0x000C | ((l) << 12))
70 #define TPM_INT_STATUS(l) (0x0010 | ((l) << 12))
71 #define TPM_INTF_CAPS(l) (0x0014 | ((l) << 12))
72 #define TPM_STS(l) (0x0018 | ((l) << 12))
73 #define TPM_DATA_FIFO(l) (0x0024 | ((l) << 12))
75 #define TPM_DID_VID(l) (0x0F00 | ((l) << 12))
76 #define TPM_RID(l) (0x0F04 | ((l) << 12))
82 #if defined(CONFIG_PNP) && defined(CONFIG_ACPI)
83 static int is_itpm(struct pnp_dev *dev)
85 struct acpi_device *acpi = pnp_acpi_device(dev);
86 struct acpi_hardware_id *id;
91 list_for_each_entry(id, &acpi->pnp.ids, list) {
92 if (!strcmp("INTC0102", id->id))
99 static inline int is_itpm(struct pnp_dev *dev)
105 /* Before we attempt to access the TPM we must see that the valid bit is set.
106 * The specification says that this bit is 0 at reset and remains 0 until the
107 * 'TPM has gone through its self test and initialization and has established
108 * correct values in the other bits.' */
109 static int wait_startup(struct tpm_chip *chip, int l)
111 unsigned long stop = jiffies + chip->vendor.timeout_a;
113 if (ioread8(chip->vendor.iobase + TPM_ACCESS(l)) &
117 } while (time_before(jiffies, stop));
121 static int check_locality(struct tpm_chip *chip, int l)
123 if ((ioread8(chip->vendor.iobase + TPM_ACCESS(l)) &
124 (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) ==
125 (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID))
126 return chip->vendor.locality = l;
131 static void release_locality(struct tpm_chip *chip, int l, int force)
133 if (force || (ioread8(chip->vendor.iobase + TPM_ACCESS(l)) &
134 (TPM_ACCESS_REQUEST_PENDING | TPM_ACCESS_VALID)) ==
135 (TPM_ACCESS_REQUEST_PENDING | TPM_ACCESS_VALID))
136 iowrite8(TPM_ACCESS_ACTIVE_LOCALITY,
137 chip->vendor.iobase + TPM_ACCESS(l));
140 static int request_locality(struct tpm_chip *chip, int l)
142 unsigned long stop, timeout;
145 if (check_locality(chip, l) >= 0)
148 iowrite8(TPM_ACCESS_REQUEST_USE,
149 chip->vendor.iobase + TPM_ACCESS(l));
151 stop = jiffies + chip->vendor.timeout_a;
153 if (chip->vendor.irq) {
155 timeout = stop - jiffies;
156 if ((long)timeout <= 0)
158 rc = wait_event_interruptible_timeout(chip->vendor.int_queue,
164 if (rc == -ERESTARTSYS && freezing(current)) {
165 clear_thread_flag(TIF_SIGPENDING);
169 /* wait for burstcount */
171 if (check_locality(chip, l) >= 0)
175 while (time_before(jiffies, stop));
180 static u8 tpm_tis_status(struct tpm_chip *chip)
182 return ioread8(chip->vendor.iobase +
183 TPM_STS(chip->vendor.locality));
186 static void tpm_tis_ready(struct tpm_chip *chip)
188 /* this causes the current command to be aborted */
189 iowrite8(TPM_STS_COMMAND_READY,
190 chip->vendor.iobase + TPM_STS(chip->vendor.locality));
193 static int get_burstcount(struct tpm_chip *chip)
198 /* wait for burstcount */
199 /* which timeout value, spec has 2 answers (c & d) */
200 stop = jiffies + chip->vendor.timeout_d;
202 burstcnt = ioread8(chip->vendor.iobase +
203 TPM_STS(chip->vendor.locality) + 1);
204 burstcnt += ioread8(chip->vendor.iobase +
205 TPM_STS(chip->vendor.locality) +
210 } while (time_before(jiffies, stop));
214 static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
216 int size = 0, burstcnt;
217 while (size < count &&
218 wait_for_tpm_stat(chip,
219 TPM_STS_DATA_AVAIL | TPM_STS_VALID,
220 chip->vendor.timeout_c,
221 &chip->vendor.read_queue, true)
223 burstcnt = get_burstcount(chip);
224 for (; burstcnt > 0 && size < count; burstcnt--)
225 buf[size++] = ioread8(chip->vendor.iobase +
226 TPM_DATA_FIFO(chip->vendor.
232 static int tpm_tis_recv(struct tpm_chip *chip, u8 *buf, size_t count)
235 int expected, status;
237 if (count < TPM_HEADER_SIZE) {
242 /* read first 10 bytes, including tag, paramsize, and result */
244 recv_data(chip, buf, TPM_HEADER_SIZE)) < TPM_HEADER_SIZE) {
245 dev_err(chip->dev, "Unable to read header\n");
249 expected = be32_to_cpu(*(__be32 *) (buf + 2));
250 if (expected > count) {
256 recv_data(chip, &buf[TPM_HEADER_SIZE],
257 expected - TPM_HEADER_SIZE)) < expected) {
258 dev_err(chip->dev, "Unable to read remainder of result\n");
263 wait_for_tpm_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c,
264 &chip->vendor.int_queue, false);
265 status = tpm_tis_status(chip);
266 if (status & TPM_STS_DATA_AVAIL) { /* retry? */
267 dev_err(chip->dev, "Error left over data\n");
274 release_locality(chip, chip->vendor.locality, 0);
279 module_param(itpm, bool, 0444);
280 MODULE_PARM_DESC(itpm, "Force iTPM workarounds (found on some Lenovo laptops)");
283 * If interrupts are used (signaled by an irq set in the vendor structure)
284 * tpm.c can skip polling for the data to be available as the interrupt is
287 static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len)
289 int rc, status, burstcnt;
292 if (request_locality(chip, 0) < 0)
295 status = tpm_tis_status(chip);
296 if ((status & TPM_STS_COMMAND_READY) == 0) {
298 if (wait_for_tpm_stat
299 (chip, TPM_STS_COMMAND_READY, chip->vendor.timeout_b,
300 &chip->vendor.int_queue, false) < 0) {
306 while (count < len - 1) {
307 burstcnt = get_burstcount(chip);
308 for (; burstcnt > 0 && count < len - 1; burstcnt--) {
309 iowrite8(buf[count], chip->vendor.iobase +
310 TPM_DATA_FIFO(chip->vendor.locality));
314 wait_for_tpm_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c,
315 &chip->vendor.int_queue, false);
316 status = tpm_tis_status(chip);
317 if (!itpm && (status & TPM_STS_DATA_EXPECT) == 0) {
323 /* write last byte */
325 chip->vendor.iobase + TPM_DATA_FIFO(chip->vendor.locality));
326 wait_for_tpm_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c,
327 &chip->vendor.int_queue, false);
328 status = tpm_tis_status(chip);
329 if ((status & TPM_STS_DATA_EXPECT) != 0) {
338 release_locality(chip, chip->vendor.locality, 0);
342 static void disable_interrupts(struct tpm_chip *chip)
347 ioread32(chip->vendor.iobase +
348 TPM_INT_ENABLE(chip->vendor.locality));
349 intmask &= ~TPM_GLOBAL_INT_ENABLE;
351 chip->vendor.iobase +
352 TPM_INT_ENABLE(chip->vendor.locality));
353 free_irq(chip->vendor.irq, chip);
354 chip->vendor.irq = 0;
358 * If interrupts are used (signaled by an irq set in the vendor structure)
359 * tpm.c can skip polling for the data to be available as the interrupt is
362 static int tpm_tis_send_main(struct tpm_chip *chip, u8 *buf, size_t len)
367 rc = tpm_tis_send_data(chip, buf, len);
373 chip->vendor.iobase + TPM_STS(chip->vendor.locality));
375 if (chip->vendor.irq) {
376 ordinal = be32_to_cpu(*((__be32 *) (buf + 6)));
377 if (wait_for_tpm_stat
378 (chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID,
379 tpm_calc_ordinal_duration(chip, ordinal),
380 &chip->vendor.read_queue, false) < 0) {
388 release_locality(chip, chip->vendor.locality, 0);
392 static int tpm_tis_send(struct tpm_chip *chip, u8 *buf, size_t len)
395 struct priv_data *priv = chip->vendor.priv;
397 if (!chip->vendor.irq || priv->irq_tested)
398 return tpm_tis_send_main(chip, buf, len);
400 /* Verify receipt of the expected IRQ */
401 irq = chip->vendor.irq;
402 chip->vendor.irq = 0;
403 rc = tpm_tis_send_main(chip, buf, len);
404 chip->vendor.irq = irq;
405 if (!priv->irq_tested)
407 if (!priv->irq_tested) {
408 disable_interrupts(chip);
410 FW_BUG "TPM interrupt not working, polling instead\n");
412 priv->irq_tested = true;
416 struct tis_vendor_timeout_override {
418 unsigned long timeout_us[4];
421 static const struct tis_vendor_timeout_override vendor_timeout_overrides[] = {
423 { 0x32041114, { (TIS_SHORT_TIMEOUT*1000), (TIS_LONG_TIMEOUT*1000),
424 (TIS_SHORT_TIMEOUT*1000), (TIS_SHORT_TIMEOUT*1000) } },
427 static bool tpm_tis_update_timeouts(struct tpm_chip *chip,
428 unsigned long *timeout_cap)
433 did_vid = ioread32(chip->vendor.iobase + TPM_DID_VID(0));
435 for (i = 0; i != ARRAY_SIZE(vendor_timeout_overrides); i++) {
436 if (vendor_timeout_overrides[i].did_vid != did_vid)
438 memcpy(timeout_cap, vendor_timeout_overrides[i].timeout_us,
439 sizeof(vendor_timeout_overrides[i].timeout_us));
447 * Early probing for iTPM with STS_DATA_EXPECT flaw.
448 * Try sending command without itpm flag set and if that
449 * fails, repeat with itpm flag set.
451 static int probe_itpm(struct tpm_chip *chip)
454 u8 cmd_getticks[] = {
455 0x00, 0xc1, 0x00, 0x00, 0x00, 0x0a,
456 0x00, 0x00, 0x00, 0xf1
458 size_t len = sizeof(cmd_getticks);
459 bool rem_itpm = itpm;
460 u16 vendor = ioread16(chip->vendor.iobase + TPM_DID_VID(0));
462 /* probe only iTPMS */
463 if (vendor != TPM_VID_INTEL)
468 rc = tpm_tis_send_data(chip, cmd_getticks, len);
473 release_locality(chip, chip->vendor.locality, 0);
477 rc = tpm_tis_send_data(chip, cmd_getticks, len);
479 dev_info(chip->dev, "Detected an iTPM.\n");
487 release_locality(chip, chip->vendor.locality, 0);
492 static bool tpm_tis_req_canceled(struct tpm_chip *chip, u8 status)
494 switch (chip->vendor.manufacturer_id) {
495 case TPM_VID_WINBOND:
496 return ((status == TPM_STS_VALID) ||
497 (status == (TPM_STS_VALID | TPM_STS_COMMAND_READY)));
499 return (status == (TPM_STS_VALID | TPM_STS_COMMAND_READY));
501 return (status == TPM_STS_COMMAND_READY);
505 static const struct tpm_class_ops tpm_tis = {
506 .status = tpm_tis_status,
507 .recv = tpm_tis_recv,
508 .send = tpm_tis_send,
509 .cancel = tpm_tis_ready,
510 .update_timeouts = tpm_tis_update_timeouts,
511 .req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
512 .req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
513 .req_canceled = tpm_tis_req_canceled,
516 static irqreturn_t tis_int_probe(int irq, void *dev_id)
518 struct tpm_chip *chip = dev_id;
521 interrupt = ioread32(chip->vendor.iobase +
522 TPM_INT_STATUS(chip->vendor.locality));
527 chip->vendor.probed_irq = irq;
529 /* Clear interrupts handled with TPM_EOI */
531 chip->vendor.iobase +
532 TPM_INT_STATUS(chip->vendor.locality));
536 static irqreturn_t tis_int_handler(int dummy, void *dev_id)
538 struct tpm_chip *chip = dev_id;
542 interrupt = ioread32(chip->vendor.iobase +
543 TPM_INT_STATUS(chip->vendor.locality));
548 ((struct priv_data *)chip->vendor.priv)->irq_tested = true;
549 if (interrupt & TPM_INTF_DATA_AVAIL_INT)
550 wake_up_interruptible(&chip->vendor.read_queue);
551 if (interrupt & TPM_INTF_LOCALITY_CHANGE_INT)
552 for (i = 0; i < 5; i++)
553 if (check_locality(chip, i) >= 0)
556 (TPM_INTF_LOCALITY_CHANGE_INT | TPM_INTF_STS_VALID_INT |
557 TPM_INTF_CMD_READY_INT))
558 wake_up_interruptible(&chip->vendor.int_queue);
560 /* Clear interrupts handled with TPM_EOI */
562 chip->vendor.iobase +
563 TPM_INT_STATUS(chip->vendor.locality));
564 ioread32(chip->vendor.iobase + TPM_INT_STATUS(chip->vendor.locality));
568 static bool interrupts = true;
569 module_param(interrupts, bool, 0444);
570 MODULE_PARM_DESC(interrupts, "Enable interrupts");
572 static void tpm_tis_remove(struct tpm_chip *chip)
574 iowrite32(~TPM_GLOBAL_INT_ENABLE &
575 ioread32(chip->vendor.iobase +
576 TPM_INT_ENABLE(chip->vendor.
578 chip->vendor.iobase +
579 TPM_INT_ENABLE(chip->vendor.locality));
580 release_locality(chip, chip->vendor.locality, 1);
583 static int tpm_tis_init(struct device *dev, resource_size_t start,
584 resource_size_t len, unsigned int irq)
586 u32 vendor, intfcaps, intmask;
587 int rc, i, irq_s, irq_e, probe;
588 struct tpm_chip *chip;
589 struct priv_data *priv;
591 priv = devm_kzalloc(dev, sizeof(struct priv_data), GFP_KERNEL);
595 chip = tpmm_chip_alloc(dev, &tpm_tis);
597 return PTR_ERR(chip);
599 chip->vendor.priv = priv;
601 chip->vendor.iobase = devm_ioremap(dev, start, len);
602 if (!chip->vendor.iobase)
605 /* Default timeouts */
606 chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
607 chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
608 chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
609 chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
611 if (wait_startup(chip, 0) != 0) {
616 if (request_locality(chip, 0) != 0) {
621 vendor = ioread32(chip->vendor.iobase + TPM_DID_VID(0));
622 chip->vendor.manufacturer_id = vendor;
625 "1.2 TPM (device-id 0x%X, rev-id %d)\n",
626 vendor >> 16, ioread8(chip->vendor.iobase + TPM_RID(0)));
629 probe = probe_itpm(chip);
638 dev_info(dev, "Intel iTPM workaround enabled\n");
641 /* Figure out the capabilities */
643 ioread32(chip->vendor.iobase +
644 TPM_INTF_CAPS(chip->vendor.locality));
645 dev_dbg(dev, "TPM interface capabilities (0x%x):\n",
647 if (intfcaps & TPM_INTF_BURST_COUNT_STATIC)
648 dev_dbg(dev, "\tBurst Count Static\n");
649 if (intfcaps & TPM_INTF_CMD_READY_INT)
650 dev_dbg(dev, "\tCommand Ready Int Support\n");
651 if (intfcaps & TPM_INTF_INT_EDGE_FALLING)
652 dev_dbg(dev, "\tInterrupt Edge Falling\n");
653 if (intfcaps & TPM_INTF_INT_EDGE_RISING)
654 dev_dbg(dev, "\tInterrupt Edge Rising\n");
655 if (intfcaps & TPM_INTF_INT_LEVEL_LOW)
656 dev_dbg(dev, "\tInterrupt Level Low\n");
657 if (intfcaps & TPM_INTF_INT_LEVEL_HIGH)
658 dev_dbg(dev, "\tInterrupt Level High\n");
659 if (intfcaps & TPM_INTF_LOCALITY_CHANGE_INT)
660 dev_dbg(dev, "\tLocality Change Int Support\n");
661 if (intfcaps & TPM_INTF_STS_VALID_INT)
662 dev_dbg(dev, "\tSts Valid Int Support\n");
663 if (intfcaps & TPM_INTF_DATA_AVAIL_INT)
664 dev_dbg(dev, "\tData Avail Int Support\n");
666 /* INTERRUPT Setup */
667 init_waitqueue_head(&chip->vendor.read_queue);
668 init_waitqueue_head(&chip->vendor.int_queue);
671 ioread32(chip->vendor.iobase +
672 TPM_INT_ENABLE(chip->vendor.locality));
674 intmask |= TPM_INTF_CMD_READY_INT
675 | TPM_INTF_LOCALITY_CHANGE_INT | TPM_INTF_DATA_AVAIL_INT
676 | TPM_INTF_STS_VALID_INT;
679 chip->vendor.iobase +
680 TPM_INT_ENABLE(chip->vendor.locality));
682 chip->vendor.irq = irq;
683 if (interrupts && !chip->vendor.irq) {
685 ioread8(chip->vendor.iobase +
686 TPM_INT_VECTOR(chip->vendor.locality));
694 for (i = irq_s; i <= irq_e && chip->vendor.irq == 0; i++) {
695 iowrite8(i, chip->vendor.iobase +
696 TPM_INT_VECTOR(chip->vendor.locality));
698 (dev, i, tis_int_probe, IRQF_SHARED,
699 chip->vendor.miscdev.name, chip) != 0) {
701 "Unable to request irq: %d for probe\n",
706 /* Clear all existing */
708 (chip->vendor.iobase +
709 TPM_INT_STATUS(chip->vendor.locality)),
710 chip->vendor.iobase +
711 TPM_INT_STATUS(chip->vendor.locality));
714 iowrite32(intmask | TPM_GLOBAL_INT_ENABLE,
715 chip->vendor.iobase +
716 TPM_INT_ENABLE(chip->vendor.locality));
718 chip->vendor.probed_irq = 0;
720 /* Generate Interrupts */
721 tpm_gen_interrupt(chip);
723 chip->vendor.irq = chip->vendor.probed_irq;
725 /* free_irq will call into tis_int_probe;
726 clear all irqs we haven't seen while doing
729 (chip->vendor.iobase +
730 TPM_INT_STATUS(chip->vendor.locality)),
731 chip->vendor.iobase +
732 TPM_INT_STATUS(chip->vendor.locality));
736 chip->vendor.iobase +
737 TPM_INT_ENABLE(chip->vendor.locality));
740 if (chip->vendor.irq) {
741 iowrite8(chip->vendor.irq,
742 chip->vendor.iobase +
743 TPM_INT_VECTOR(chip->vendor.locality));
745 (dev, chip->vendor.irq, tis_int_handler, IRQF_SHARED,
746 chip->vendor.miscdev.name, chip) != 0) {
748 "Unable to request irq: %d for use\n",
750 chip->vendor.irq = 0;
752 /* Clear all existing */
754 (chip->vendor.iobase +
755 TPM_INT_STATUS(chip->vendor.locality)),
756 chip->vendor.iobase +
757 TPM_INT_STATUS(chip->vendor.locality));
760 iowrite32(intmask | TPM_GLOBAL_INT_ENABLE,
761 chip->vendor.iobase +
762 TPM_INT_ENABLE(chip->vendor.locality));
766 if (tpm_get_timeouts(chip)) {
767 dev_err(dev, "Could not get TPM timeouts and durations\n");
772 if (tpm_do_selftest(chip)) {
773 dev_err(dev, "TPM self test failed\n");
778 return tpm_chip_register(chip);
780 tpm_tis_remove(chip);
784 #ifdef CONFIG_PM_SLEEP
785 static void tpm_tis_reenable_interrupts(struct tpm_chip *chip)
789 /* reenable interrupts that device may have lost or
790 BIOS/firmware may have disabled */
791 iowrite8(chip->vendor.irq, chip->vendor.iobase +
792 TPM_INT_VECTOR(chip->vendor.locality));
795 ioread32(chip->vendor.iobase +
796 TPM_INT_ENABLE(chip->vendor.locality));
798 intmask |= TPM_INTF_CMD_READY_INT
799 | TPM_INTF_LOCALITY_CHANGE_INT | TPM_INTF_DATA_AVAIL_INT
800 | TPM_INTF_STS_VALID_INT | TPM_GLOBAL_INT_ENABLE;
803 chip->vendor.iobase + TPM_INT_ENABLE(chip->vendor.locality));
806 static int tpm_tis_resume(struct device *dev)
808 struct tpm_chip *chip = dev_get_drvdata(dev);
811 if (chip->vendor.irq)
812 tpm_tis_reenable_interrupts(chip);
814 ret = tpm_pm_resume(dev);
816 tpm_do_selftest(chip);
822 static SIMPLE_DEV_PM_OPS(tpm_tis_pm, tpm_pm_suspend, tpm_tis_resume);
825 static int tpm_tis_pnp_init(struct pnp_dev *pnp_dev,
826 const struct pnp_device_id *pnp_id)
828 resource_size_t start, len;
829 unsigned int irq = 0;
831 start = pnp_mem_start(pnp_dev, 0);
832 len = pnp_mem_len(pnp_dev, 0);
834 if (pnp_irq_valid(pnp_dev, 0))
835 irq = pnp_irq(pnp_dev, 0);
839 if (is_itpm(pnp_dev))
842 return tpm_tis_init(&pnp_dev->dev, start, len, irq);
845 static struct pnp_device_id tpm_pnp_tbl[] = {
846 {"PNP0C31", 0}, /* TPM */
847 {"ATM1200", 0}, /* Atmel */
848 {"IFX0102", 0}, /* Infineon */
849 {"BCM0101", 0}, /* Broadcom */
850 {"BCM0102", 0}, /* Broadcom */
851 {"NSC1200", 0}, /* National */
852 {"ICO0102", 0}, /* Intel */
854 {"", 0}, /* User Specified */
855 {"", 0} /* Terminator */
857 MODULE_DEVICE_TABLE(pnp, tpm_pnp_tbl);
859 static void tpm_tis_pnp_remove(struct pnp_dev *dev)
861 struct tpm_chip *chip = pnp_get_drvdata(dev);
862 tpm_chip_unregister(chip);
863 tpm_tis_remove(chip);
866 static struct pnp_driver tis_pnp_driver = {
868 .id_table = tpm_pnp_tbl,
869 .probe = tpm_tis_pnp_init,
870 .remove = tpm_tis_pnp_remove,
876 #define TIS_HID_USR_IDX sizeof(tpm_pnp_tbl)/sizeof(struct pnp_device_id) -2
877 module_param_string(hid, tpm_pnp_tbl[TIS_HID_USR_IDX].id,
878 sizeof(tpm_pnp_tbl[TIS_HID_USR_IDX].id), 0444);
879 MODULE_PARM_DESC(hid, "Set additional specific HID for this driver to probe");
882 static struct platform_driver tis_drv = {
889 static struct platform_device *pdev;
892 module_param(force, bool, 0444);
893 MODULE_PARM_DESC(force, "Force device probe rather than using ACPI entry");
894 static int __init init_tis(void)
899 return pnp_register_driver(&tis_pnp_driver);
902 rc = platform_driver_register(&tis_drv);
905 pdev = platform_device_register_simple("tpm_tis", -1, NULL, 0);
910 rc = tpm_tis_init(&pdev->dev, TIS_MEM_BASE, TIS_MEM_LEN, 0);
915 platform_device_unregister(pdev);
917 platform_driver_unregister(&tis_drv);
921 static void __exit cleanup_tis(void)
923 struct tpm_chip *chip;
926 pnp_unregister_driver(&tis_pnp_driver);
930 chip = dev_get_drvdata(&pdev->dev);
931 tpm_chip_unregister(chip);
932 tpm_tis_remove(chip);
933 platform_device_unregister(pdev);
934 platform_driver_unregister(&tis_drv);
937 module_init(init_tis);
938 module_exit(cleanup_tis);
939 MODULE_AUTHOR("Leendert van Doorn (leendert@watson.ibm.com)");
940 MODULE_DESCRIPTION("TPM Driver");
941 MODULE_VERSION("2.0");
942 MODULE_LICENSE("GPL");