i2c/generic: Allow GPIOs to be put in _CRS and PowerResource in ACPI

Linux kernel expects that power management with ACPI should always be
handled using PowerResource. However, some kernel drivers (e.g. ELAN
touchscreen) check to see if reset gpio is passed in by the BIOS to
decide whether the device loses power in suspend. Thus, until the kernel
has a better way for drivers to query if device lost power in suspend,
we need to allow passing in of GPIOs via _CRS as well as exporting
PowerResource to control power to the device.

Update mainboards to export reset GPIO as well as PowerResource for
ELAN touchscreen device.

BUG=chrome-os-partner:62311,chrome-os-partner:60194
BRANCH=reef
TEST=Verified that touchscreen works on power-on as well as after
suspend-resume.

Change-Id: I3409689cf56bfddd321402ad5dda3fc8762e6bc6
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://review.coreboot.org/18238
Tested-by: build bot (Jenkins)
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
diff --git a/src/drivers/i2c/generic/generic.c b/src/drivers/i2c/generic/generic.c
index 4cf3e9e..a90947f 100644
--- a/src/drivers/i2c/generic/generic.c
+++ b/src/drivers/i2c/generic/generic.c
@@ -32,7 +32,7 @@
 	unsigned reset_gpio = config->reset_gpio.pins[0];
 	unsigned enable_gpio = config->enable_gpio.pins[0];
 
-	if (config->pwr_mgmt_type != POWER_RESOURCE)
+	if (!config->has_power_resource)
 		return;
 
 	if (!reset_gpio && !enable_gpio)
@@ -72,10 +72,17 @@
 
 static bool i2c_generic_add_gpios_to_crs(struct drivers_i2c_generic_config *cfg)
 {
-	if (cfg->pwr_mgmt_type == GPIO_EXPORT)
-		return true;
+	/*
+	 * Return false if:
+	 * 1. Request to explicitly disable export of GPIOs in CRS, or
+	 * 2. Both reset and enable GPIOs are not provided.
+	 */
+	if (cfg->disable_gpio_export_in_crs ||
+	    ((cfg->reset_gpio.pin_count == 0) &&
+	     (cfg->enable_gpio.pin_count == 0)))
+		return false;
 
-	return false;
+	return true;
 }
 
 static int i2c_generic_write_gpio(struct acpi_gpio *gpio, int *curr_index)