1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <acpi/acpigen.h>
5 #include <acpi/acpi_device.h>
9 static void tpm_ppi_func0_cb(void *arg
)
12 u8 buf
[] = {0xff, 0x01};
13 acpigen_write_return_byte_buffer(buf
, sizeof(buf
));
16 static void tpm_ppi_func1_cb(void *arg
)
19 /* Interface version: 1.3 */
20 acpigen_write_return_string("1.3");
22 /* Interface version: 1.2 */
23 acpigen_write_return_string("1.2");
26 static void tpm_ppi_func2_cb(void *arg
)
28 /* Submit operations: drop on the floor and return success. */
29 acpigen_write_return_byte(PPI2_RET_SUCCESS
);
32 static void tpm_ppi_func3_cb(void *arg
)
34 /* Pending operation: none. */
35 acpigen_emit_byte(RETURN_OP
);
36 acpigen_write_package(2);
37 acpigen_write_byte(0);
38 acpigen_write_byte(0);
42 static void tpm_ppi_func4_cb(void *arg
)
44 /* Pre-OS transition method: reboot. */
45 acpigen_write_return_byte(2);
48 static void tpm_ppi_func5_cb(void *arg
)
50 /* Operation response: no operation executed. */
51 acpigen_emit_byte(RETURN_OP
);
52 acpigen_write_package(3);
53 acpigen_write_byte(0);
54 acpigen_write_byte(0);
55 acpigen_write_byte(0);
59 static void tpm_ppi_func6_cb(void *arg
)
62 * Set preferred user language: deprecated and must return 3 AKA
65 acpigen_write_return_byte(PPI6_RET_NOT_IMPLEMENTED
);
68 static void tpm_ppi_func7_cb(void *arg
)
70 /* Submit operations: deny. */
71 acpigen_write_return_byte(PPI7_RET_BLOCKED_BY_FIRMWARE
);
74 static void tpm_ppi_func8_cb(void *arg
)
76 /* All actions are forbidden. */
77 acpigen_write_return_byte(PPI8_RET_FIRMWARE_ONLY
);
80 static void (*tpm_ppi_callbacks
[])(void *) = {
92 static void tpm_mci_func0_cb(void *arg
)
95 acpigen_write_return_singleton_buffer(0x3);
97 static void tpm_mci_func1_cb(void *arg
)
99 /* Just return success. */
100 acpigen_write_return_byte(0);
103 static void (*tpm_mci_callbacks
[])(void *) = {
108 void tpm_ppi_acpi_fill_ssdt(const struct device
*dev
)
113 struct dsm_uuid ids
[] = {
114 /* Physical presence interface.
115 * This is used to submit commands like "Clear TPM" to
116 * be run at next reboot provided that user confirms
117 * them. Spec allows user to cancel all commands and/or
118 * configure BIOS to reject commands. So we pretend that
119 * user did just this: cancelled everything. If user
120 * really wants to clear TPM the only option now is to
121 * do it manually in payload.
123 DSM_UUID(TPM_PPI_UUID
, tpm_ppi_callbacks
,
124 ARRAY_SIZE(tpm_ppi_callbacks
), NULL
),
125 /* Memory clearing on boot: just a dummy. */
126 DSM_UUID(TPM_MCI_UUID
, tpm_mci_callbacks
,
127 ARRAY_SIZE(tpm_mci_callbacks
), NULL
),
130 acpigen_write_dsm_uuid_arr(ids
, ARRAY_SIZE(ids
));