xref: /freebsd/sys/dev/tpm/tpm_acpi.c (revision a84d91d81a6f3eeb4949c4fb3440e0634f2b953a)
1 /*
2  * Copyright (c) 2008, 2009 Michael Shalayeff
3  * Copyright (c) 2009, 2010 Hans-Joerg Hoexer
4  * All rights reserved.
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN
15  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
16  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #include <sys/param.h>
20 #include <sys/systm.h>
21 #include <sys/kernel.h>
22 #include <sys/malloc.h>
23 #include <sys/proc.h>
24 
25 #include <sys/module.h>
26 #include <sys/conf.h>
27 #include <sys/uio.h>
28 #include <sys/bus.h>
29 
30 #include <machine/bus.h>
31 #include <sys/rman.h>
32 #include <machine/resource.h>
33 
34 #include <machine/md_var.h>
35 
36 #include <isa/isareg.h>
37 #include <isa/isavar.h>
38 #include "tpmvar.h"
39 
40 #include "opt_acpi.h"
41 #include <contrib/dev/acpica/include/acpi.h>
42 #include <contrib/dev/acpica/include/accommon.h>
43 #include <dev/acpica/acpivar.h>
44 
45 char *tpm_ids[] = {"ATM1200",  "BCM0102", "INTC0102", "SNO3504", "WEC1000",
46     "PNP0C31", NULL};
47 
48 static int
49 tpm_acpi_probe(device_t dev)
50 {
51 	int rv;
52 
53 	rv = ACPI_ID_PROBE(device_get_parent(dev), dev, tpm_ids, NULL);
54 	if (rv <= 0)
55 		device_set_desc(dev, "Trusted Platform Module");
56 
57 	return (rv);
58 }
59 
60 static device_method_t tpm_acpi_methods[] = {
61 #if 0
62 	/*In some case, TPM existence is found only in TPCA header*/
63 	DEVMETHOD(device_identify,	tpm_acpi_identify),
64 #endif
65 
66 	DEVMETHOD(device_probe,		tpm_acpi_probe),
67 	DEVMETHOD(device_attach,	tpm_attach),
68 	DEVMETHOD(device_detach,	tpm_detach),
69 	DEVMETHOD(device_suspend,	tpm_suspend),
70 	DEVMETHOD(device_resume,	tpm_resume),
71 	{ 0, 0 }
72 };
73 
74 static driver_t tpm_acpi_driver = {
75 	"tpm", tpm_acpi_methods, sizeof(struct tpm_softc),
76 };
77 
78 DRIVER_MODULE(tpm, acpi, tpm_acpi_driver, 0, 0);
79