soc/intel/alderlake: Add ADL-P 4+4 with 28W TDP
[coreboot.git] / src / drivers / tpm / ppi_stub.c
blob816a3e3d37290aa90687dbb1e4165e04f9c76b87
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <types.h>
4 #include <acpi/acpigen.h>
5 #include <acpi/acpi_device.h>
7 #include "tpm_ppi.h"
9 static void tpm_ppi_func0_cb(void *arg)
11 /* Functions 1-8. */
12 u8 buf[] = {0xff, 0x01};
13 acpigen_write_return_byte_buffer(buf, sizeof(buf));
16 static void tpm_ppi_func1_cb(void *arg)
18 if (CONFIG(TPM2))
19 /* Interface version: 1.3 */
20 acpigen_write_return_string("1.3");
21 else
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);
39 acpigen_pop_len();
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);
56 acpigen_pop_len();
59 static void tpm_ppi_func6_cb(void *arg)
62 * Set preferred user language: deprecated and must return 3 AKA
63 * "not implemented".
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 *) = {
81 tpm_ppi_func0_cb,
82 tpm_ppi_func1_cb,
83 tpm_ppi_func2_cb,
84 tpm_ppi_func3_cb,
85 tpm_ppi_func4_cb,
86 tpm_ppi_func5_cb,
87 tpm_ppi_func6_cb,
88 tpm_ppi_func7_cb,
89 tpm_ppi_func8_cb,
92 static void tpm_mci_func0_cb(void *arg)
94 /* Function 1. */
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 *) = {
104 tpm_mci_func0_cb,
105 tpm_mci_func1_cb,
108 void tpm_ppi_acpi_fill_ssdt(const struct device *dev)
111 * _DSM method
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));