2 * Copyright (c) 2018 Stormshield.
3 * Copyright (c) 2018 Semihalf.
4 * Copyright (c) 2023 Juniper Networks, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
29 #include <sys/cdefs.h>
33 static int tpmtis_acpi_probe(device_t dev);
35 char *tpmtis_ids[] = {"MSFT0101", NULL};
38 tpmtis_acpi_probe(device_t dev)
41 ACPI_TABLE_TPM23 *tbl;
44 err = ACPI_ID_PROBE(device_get_parent(dev), dev, tpmtis_ids, NULL);
48 status = AcpiGetTable(ACPI_SIG_TPM2, 1, (ACPI_TABLE_HEADER **) &tbl);
49 if(ACPI_FAILURE(status) ||
50 tbl->StartMethod != TPM2_START_METHOD_TIS)
53 device_set_desc(dev, "Trusted Platform Module 2.0, FIFO mode");
58 tpmtis_acpi_attach(device_t dev)
60 struct tpm_sc *sc = device_get_softc(dev);
63 sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->mem_rid,
65 if (sc->mem_res == NULL) {
70 * If tpmtis_attach() fails, tpmtis_detach() will automatically free
71 * sc->mem_res (not-NULL).
73 return (tpmtis_attach(dev));
77 static device_method_t tpmtis_methods[] = {
78 DEVMETHOD(device_attach, tpmtis_acpi_attach),
79 DEVMETHOD(device_probe, tpmtis_acpi_probe),
83 DEFINE_CLASS_2(tpmtis, tpmtis_acpi_driver, tpmtis_methods,
84 sizeof(struct tpm_sc), tpmtis_driver, tpm_bus_driver);
86 DRIVER_MODULE(tpmtis, acpi, tpmtis_driver, 0, 0);