soc/amd: factor out acpigen_write_alib_dptc to common code
Also drop unneeded intermediate cast to void * before casting the
address of the struct dptc_input type variables to uint8_t *.
Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Change-Id: Ie1e2aa1ec728a4e16d3a587d7400cdfc8962f443
Reviewed-on: https://review.coreboot.org/c/coreboot/+/54077
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Raul Rangel <rrangel@chromium.org>
diff --git a/src/soc/amd/common/block/acpi/alib.c b/src/soc/amd/common/block/acpi/alib.c
index 5e1e8fb..7dbb9b8 100644
--- a/src/soc/amd/common/block/acpi/alib.c
+++ b/src/soc/amd/common/block/acpi/alib.c
@@ -4,7 +4,7 @@
#include <amdblocks/alib.h>
#include <types.h>
-void acpigen_dptc_call_alib(const char *buf_name, uint8_t *buffer, size_t size)
+static void acpigen_dptc_call_alib(const char *buf_name, uint8_t *buffer, size_t size)
{
/* Name (buf_name, Buffer(size) {...} */
acpigen_write_name(buf_name);
@@ -15,3 +15,29 @@
acpigen_write_integer(ALIB_FUNCTION_DYNAMIC_POWER_THERMAL_CONFIG);
acpigen_emit_namestring(buf_name);
}
+
+void acpigen_write_alib_dptc(uint8_t *default_param, size_t default_param_len,
+ uint8_t *tablet_param, size_t tablet_param_len)
+{
+ /* Scope (\_SB) */
+ acpigen_write_scope("\\_SB");
+
+ /* Method(DPTC, 0, Serialized) */
+ acpigen_write_method_serialized("DPTC", 0);
+
+ /* TODO: The code assumes that if DPTC gets called the following object exists */
+ /* If (LEqual ("\_SB.PCI0.LPCB.EC0.TBMD", 1)) */
+ acpigen_write_if_lequal_namestr_int("\\_SB.PCI0.LPCB.EC0.TBMD", 1);
+
+ acpigen_dptc_call_alib("TABB", tablet_param, tablet_param_len);
+
+ /* Else */
+ acpigen_write_else();
+
+ acpigen_dptc_call_alib("DEFB", default_param, default_param_len);
+
+ acpigen_pop_len(); /* Else */
+
+ acpigen_pop_len(); /* Method DPTC */
+ acpigen_pop_len(); /* Scope \_SB */
+}