soc/amd: Refactor DPTC Tablet Mode

Refactor AMD DPTC tablet mode in preparation for adding low/no battery
DPTC settings.

1. Refactor and simplify acpigen_write_alib_dptc() into the following
   functions:
   - acpigen_write_alib_dptc_default()
   - acpigen_write_alib_dptc_tablet()
2. Add device tree register value dptc_tablet_mode_enable to control
   whether DPTC tablet mode is enabled for a variant.
3. Add dptc.asl to perform the necessary ACPI checking before modifying
   the DPTC settings.

BRANCH=none
BUG=b:217911928
TEST=Build zork
TEST=Build nipperkin
TEST=Boot skyrim

Change-Id: I2518fdd526868c9d5668a6018fd3570392e809c0
Signed-off-by: Tim Van Patten <timvp@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/66994
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
diff --git a/src/soc/amd/common/block/acpi/alib.c b/src/soc/amd/common/block/acpi/alib.c
index 7dbb9b8..4f6eafb 100644
--- a/src/soc/amd/common/block/acpi/alib.c
+++ b/src/soc/amd/common/block/acpi/alib.c
@@ -16,28 +16,60 @@
 	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)
+void acpigen_write_alib_dptc_default(uint8_t *default_param, size_t default_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();
-
+	/* Default (Unthrottled) Mode */
+	/* Scope (\_SB)
+	 * {
+	 *     Method (DDEF, 0, Serialized)
+	 *     {
+	 *         Debug = "DPTC: Using normal SOC DPTC Settings."
+	 *         Name (DEFB, Buffer (0x25)
+	 *         {
+	 *             ...
+	 *         })
+	 *         \_SB.ALIB
+	 *         0x0C
+	 *         DEFB
+	 *     }
+	 * }
+	 */
+	acpigen_write_method_serialized("DDEF", 0);
+	acpigen_write_debug_string("DPTC: Using normal SOC DPTC Settings.");
 	acpigen_dptc_call_alib("DEFB", default_param, default_param_len);
+	acpigen_write_method_end();
 
-	acpigen_pop_len(); /* Else */
+	acpigen_write_scope_end();
+}
 
-	acpigen_pop_len(); /* Method DPTC */
-	acpigen_pop_len(); /* Scope \_SB */
+void acpigen_write_alib_dptc_tablet(uint8_t *tablet_param, size_t tablet_param_len)
+{
+	/* Scope (\_SB) */
+	acpigen_write_scope("\\_SB");
+
+	/* Tablet Mode */
+	/* Scope (\_SB)
+	 * {
+	 *     Method (DTAB, 0, Serialized)
+	 *     {
+	 *         Debug = "DPTC: Using tablet mode SOC DPTC Settings."
+	 *         Name (TABB, Buffer (0x25)
+	 *         {
+	 *             ...
+	 *         })
+	 *         \_SB.ALIB
+	 *         0x0C
+	 *         TABB
+	 *     }
+	 * }
+	 */
+	acpigen_write_method_serialized("DTAB", 0);
+	acpigen_write_debug_string("DPTC: Using tablet mode SOC DPTC Settings.");
+	acpigen_dptc_call_alib("TABB", tablet_param, tablet_param_len);
+	acpigen_write_method_end();
+
+	acpigen_write_scope_end();
 }