ec/google: Add function ec_fill_dptf_helpers()

ec_fill_dptf_helpers() is used to generate all of the "helper" methods
that DPTF requires. A system with a Chrome EC is typically in charge
of fan PWM control as well as battery charging, so if DPTF needs to
manipulate those, then it requires Methods provided by the EC.

BUG=b:143539650
TEST=compiles

Change-Id: Ib30072d1d0748b31bcab240a0fd0e2f12d34aaa4
Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/41894
Reviewed-by: Nick Vaccaro <nvaccaro@google.com>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/src/ec/google/chromeec/ec_acpi.c b/src/ec/google/chromeec/ec_acpi.c
index dca5285..8a76805 100644
--- a/src/ec/google/chromeec/ec_acpi.c
+++ b/src/ec/google/chromeec/ec_acpi.c
@@ -7,6 +7,7 @@
 #include <acpi/acpigen_usb.h>
 #include <console/console.h>
 #include <drivers/usb/acpi/chip.h>
+#include <ec/google/common/dptf.h>
 
 #include "chip.h"
 #include "ec.h"
@@ -241,11 +242,32 @@
 				 !!(keybd.capabilities & KEYBD_CAP_SCRNLOCK_KEY));
 }
 
+static const char *ec_acpi_name(const struct device *dev)
+{
+	return "EC0";
+}
+
+static struct device_operations ec_ops = {
+	.acpi_name	= ec_acpi_name,
+};
+
 void google_chromeec_fill_ssdt_generator(const struct device *dev)
 {
+	struct device_path path;
+	struct device *ec;
+
 	if (!dev->enabled)
 		return;
 
+	/* Set up a minimal EC0 device to pass to the DPTF helpers */
+	path.type = DEVICE_PATH_GENERIC;
+	path.generic.id = 0;
+	ec = alloc_find_dev(dev->bus, &path);
+	ec->ops = &ec_ops;
+
+	if (CONFIG(DRIVERS_INTEL_DPTF))
+		ec_fill_dptf_helpers(ec);
+
 	fill_ssdt_typec_device(dev);
 	fill_ssdt_ps2_keyboard(dev);
 }