intelblocks/pep: Add display on/off notifications

Add display on and off notifications which call mainboard hooks if
present. This allows to handle some board specific functions in user
absence or presence (when display goes off from inactivity or on from
activity).

TEST=Use Display on/off notification on Clevo NV41 to tell EC about
laptop inactivity. It is necessary to properly handle S0ix entry (stop
the fans and start blinking the power led).

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Signed-off-by: Michał Kopeć <michal.kopec@3mdeb.com>
Change-Id: Ie80f631ecffa74467ab6d6162e552ba977f7e3f4
Reviewed-on: https://review.coreboot.org/c/coreboot/+/62494
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Krystian Hebel <krystian.hebel@3mdeb.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
diff --git a/src/soc/intel/common/block/acpi/pep.c b/src/soc/intel/common/block/acpi/pep.c
index b83b714..1399438 100644
--- a/src/soc/intel/common/block/acpi/pep.c
+++ b/src/soc/intel/common/block/acpi/pep.c
@@ -14,6 +14,7 @@
 #define SYSTEM_POWER_MANAGEMENT_CID	"PNP0D80"
 #define EC_S0IX_HOOK			"\\_SB.PCI0.LPCB.EC0.S0IX"
 #define MAINBOARD_HOOK			"\\_SB.MS0X"
+#define MAINBOARD_DISPLAY_HOOK		"\\_SB.MDSX"
 #define ENABLE_PM_BITS_HOOK		"\\_SB.PCI0.EGPM"
 #define RESTORE_PM_BITS_HOOK		"\\_SB.PCI0.RGPM"
 #define LPI_STATES_ALL			0xff
@@ -150,12 +151,30 @@
 	acpigen_write_if_end();
 }
 
+static void lpi_display_on(void *unused)
+{
+	/* Provide a board level S0ix hook */
+	acpigen_write_if_cond_ref_of(MAINBOARD_DISPLAY_HOOK);
+	acpigen_emit_namestring(MAINBOARD_DISPLAY_HOOK);
+	acpigen_write_integer(1);
+	acpigen_write_if_end();
+}
+
+static void lpi_display_off(void *unused)
+{
+	/* Provide a board level S0ix hook */
+	acpigen_write_if_cond_ref_of(MAINBOARD_DISPLAY_HOOK);
+	acpigen_emit_namestring(MAINBOARD_DISPLAY_HOOK);
+	acpigen_write_integer(0);
+	acpigen_write_if_end();
+}
+
 static void (*lpi_s0_helpers[])(void *) = {
 	NULL,			/* enumerate functions (autogenerated) */
 	lpi_get_constraints,	/* get device constraints */
 	NULL,			/* get crash dump device */
-	NULL,			/* display off notify */
-	NULL,			/* display on notify */
+	lpi_display_off,	/* display off notify */
+	lpi_display_on,		/* display on notify */
 	lpi_s0ix_entry,		/* s0ix entry */
 	lpi_s0ix_exit,		/* s0ix exit */
 };