blob: 7dbb9b840775b291be2e4922d4fa914cb5a1a790 [file] [log] [blame]
Felix Held18b51e92021-05-08 01:30:30 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <acpi/acpigen.h>
4#include <amdblocks/alib.h>
5#include <types.h>
6
Felix Held2d0bf342021-05-12 01:42:37 +02007static void acpigen_dptc_call_alib(const char *buf_name, uint8_t *buffer, size_t size)
Felix Held18b51e92021-05-08 01:30:30 +02008{
9 /* Name (buf_name, Buffer(size) {...} */
10 acpigen_write_name(buf_name);
11 acpigen_write_byte_buffer(buffer, size);
12
13 /* \_SB.ALIB(0xc, buf_name) */
14 acpigen_emit_namestring("\\_SB.ALIB");
15 acpigen_write_integer(ALIB_FUNCTION_DYNAMIC_POWER_THERMAL_CONFIG);
16 acpigen_emit_namestring(buf_name);
17}
Felix Held2d0bf342021-05-12 01:42:37 +020018
19void acpigen_write_alib_dptc(uint8_t *default_param, size_t default_param_len,
20 uint8_t *tablet_param, size_t tablet_param_len)
21{
22 /* Scope (\_SB) */
23 acpigen_write_scope("\\_SB");
24
25 /* Method(DPTC, 0, Serialized) */
26 acpigen_write_method_serialized("DPTC", 0);
27
28 /* TODO: The code assumes that if DPTC gets called the following object exists */
29 /* If (LEqual ("\_SB.PCI0.LPCB.EC0.TBMD", 1)) */
30 acpigen_write_if_lequal_namestr_int("\\_SB.PCI0.LPCB.EC0.TBMD", 1);
31
32 acpigen_dptc_call_alib("TABB", tablet_param, tablet_param_len);
33
34 /* Else */
35 acpigen_write_else();
36
37 acpigen_dptc_call_alib("DEFB", default_param, default_param_len);
38
39 acpigen_pop_len(); /* Else */
40
41 acpigen_pop_len(); /* Method DPTC */
42 acpigen_pop_len(); /* Scope \_SB */
43}