1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <acpi/acpigen.h>
4 #include <amdblocks/alib.h>
7 static void acpigen_dptc_call_alib(const char *buf_name
, uint8_t *buffer
, size_t size
)
9 /* Name (buf_name, Buffer(size) {...} */
10 acpigen_write_name(buf_name
);
11 acpigen_write_byte_buffer(buffer
, size
);
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
);
19 void acpigen_write_alib_dptc_default(uint8_t *default_param
, size_t default_param_len
)
22 acpigen_write_scope("\\_SB");
24 /* Default (Unthrottled) Mode */
27 * Method (DDEF, 0, Serialized)
29 * Debug = "DPTC: Using normal SOC DPTC Settings."
30 * Name (DEFB, Buffer (0x25)
40 acpigen_write_method_serialized("DDEF", 0);
41 acpigen_write_debug_string("DPTC: Using normal SOC DPTC Settings.");
42 acpigen_dptc_call_alib("DEFB", default_param
, default_param_len
);
43 acpigen_write_method_end();
45 acpigen_write_scope_end();
48 void acpigen_write_alib_dptc_no_battery(uint8_t *no_battery_param
, size_t no_battery_param_len
)
51 acpigen_write_scope("\\_SB");
53 /* Low/No Battery Mode */
56 * Method (DTHL, 0, Serialized)
58 * Debug = "DPTC: Using low/no battery mode SOC DPTC settings."
59 * Name (THTL, Buffer (0x25)
69 acpigen_write_method_serialized("DTHL", 0);
70 acpigen_write_debug_string("DPTC: Using low/no battery mode SOC DPTC settings.");
71 acpigen_dptc_call_alib("THTL", no_battery_param
, no_battery_param_len
);
72 acpigen_write_method_end();
74 acpigen_write_scope_end();
77 void acpigen_write_alib_dptc_tablet(uint8_t *tablet_param
, size_t tablet_param_len
)
80 acpigen_write_scope("\\_SB");
85 * Method (DTAB, 0, Serialized)
87 * Debug = "DPTC: Using tablet mode SOC DPTC Settings."
88 * Name (TABB, Buffer (0x25)
98 acpigen_write_method_serialized("DTAB", 0);
99 acpigen_write_debug_string("DPTC: Using tablet mode SOC DPTC Settings.");
100 acpigen_dptc_call_alib("TABB", tablet_param
, tablet_param_len
);
101 acpigen_write_method_end();
103 acpigen_write_scope_end();
106 void acpigen_write_alib_dptc_thermal_B(uint8_t *thermal_param_B
, size_t thermal_param_B_len
)
109 acpigen_write_scope("\\_SB");
111 /* Table B for dynamic DPTC*/
114 * Method (DTTB, 0, Serialized)
116 * Debug = "DPTC: TABLE B"
117 * Name (THTB, Buffer (0x25)
127 acpigen_write_method_serialized("DTTB", 0);
128 acpigen_write_debug_string("DPTC: TABLE B");
129 acpigen_dptc_call_alib("THTB", thermal_param_B
, thermal_param_B_len
);
130 acpigen_write_method_end();
132 acpigen_write_scope_end();
135 void acpigen_write_alib_dptc_thermal_C(uint8_t *thermal_param_C
, size_t thermal_param_C_len
)
138 acpigen_write_scope("\\_SB");
140 /* Table C for dynamic DPTC*/
143 * Method (DTTC, 0, Serialized)
145 * Debug = "DPTC: TABLE C"
146 * Name (THTC, Buffer (0x25)
156 acpigen_write_method_serialized("DTTC", 0);
157 acpigen_write_debug_string("DPTC: TABLE C");
158 acpigen_dptc_call_alib("THTC", thermal_param_C
, thermal_param_C_len
);
159 acpigen_write_method_end();
161 acpigen_write_scope_end();
164 void acpigen_write_alib_dptc_thermal_D(uint8_t *thermal_param_D
, size_t thermal_param_D_len
)
167 acpigen_write_scope("\\_SB");
169 /* Table D for dynamic DPTC*/
172 * Method (DTTD, 0, Serialized)
174 * Debug = "DPTC: Using normal SOC DPTC Settings."
175 * Name (THTD, Buffer (0x25)
185 acpigen_write_method_serialized("DTTD", 0);
186 acpigen_write_debug_string("DPTC: TABLE D");
187 acpigen_dptc_call_alib("THTD", thermal_param_D
, thermal_param_D_len
);
188 acpigen_write_method_end();
190 acpigen_write_scope_end();
193 void acpigen_write_alib_dptc_thermal_E(uint8_t *thermal_param_E
, size_t thermal_param_E_len
)
196 acpigen_write_scope("\\_SB");
198 /* Table E for dynamic DPTC*/
201 * Method (DTTE, 0, Serialized)
203 * Debug = "DPTC: TABLE E"
204 * Name (THTE, Buffer (0x25)
214 acpigen_write_method_serialized("DTTE", 0);
215 acpigen_write_debug_string("DPTC: TABLE E");
216 acpigen_dptc_call_alib("THTE", thermal_param_E
, thermal_param_E_len
);
217 acpigen_write_method_end();
219 acpigen_write_scope_end();
222 void acpigen_write_alib_dptc_thermal_F(uint8_t *thermal_param_F
, size_t thermal_param_F_len
)
225 acpigen_write_scope("\\_SB");
227 /* Table F for dynamic DPTC*/
230 * Method (DTTF, 0, Serialized)
232 * Debug = "DPTC: TABLE F"
233 * Name (THTF, Buffer (0x25)
243 acpigen_write_method_serialized("DTTF", 0);
244 acpigen_write_debug_string("DPTC: TABLE F");
245 acpigen_dptc_call_alib("THTF", thermal_param_F
, thermal_param_F_len
);
246 acpigen_write_method_end();
248 acpigen_write_scope_end();