HACK: CHROMIUM: cros_ec: Support MKBP sync IRQ defined via ACPI GpioInt{}

On some ChromeOS devices, the EC -> AP sync IRQ is registered using a
GpioInt{} ACPI command. This is done in order to allow routing via
the AMD GPIO controller.

Retrieving the IRQ number in this case requires a different code path that
goes via ACPI and a GPIO-to-IRQ conversion instead of using the platform
device to directly retrieve the IRQ number.

We are working with upstream to get
https://patchwork.kernel.org/patch/10801897/ merged, but until that
reaches consensus, this local hack enables us to make forward progress.

BUG=b:123750725
TEST=observe chromeos-ec interrupt in /proc/interrupts

Change-Id: Ic88d28c4c921a5520759640a9fb0c203ec05e2c8
Signed-off-by: Enrico Granata <egranata@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1455372
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
(cherry picked from commit 2c618b26abe06ff07cbb3f439132773f3943bc3e)
Reviewed-on: https://chromium-review.googlesource.com/c/1471272
diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
index 02e4217..36b2878f 100644
--- a/drivers/platform/chrome/cros_ec_lpc.c
+++ b/drivers/platform/chrome/cros_ec_lpc.c
@@ -24,6 +24,7 @@
 #include <linux/acpi.h>
 #include <linux/dmi.h>
 #include <linux/delay.h>
+#include <linux/gpio/consumer.h>
 #include <linux/io.h>
 #include <linux/interrupt.h>
 #include <linux/mfd/cros_ec.h>
@@ -251,7 +252,7 @@
 	acpi_status status;
 	struct cros_ec_device *ec_dev;
 	u8 buf[2];
-	int irq, ret;
+	int irq = 0, ret;
 
 	if (!devm_request_region(dev, EC_LPC_ADDR_MEMMAP, EC_MEMMAP_SIZE,
 				 dev_name(dev))) {
@@ -292,12 +293,16 @@
 
 	/*
 	 * Some boards do not have an IRQ allotted for cros_ec_lpc,
-	 * which makes ENXIO an expected (and safe) scenario.
+	 * which makes ENXIO or ENOENT an expected (and safe) scenario.
 	 */
-	irq = platform_get_irq(pdev, 0);
+	adev = ACPI_COMPANION(dev);
+	if (adev)
+		irq = acpi_dev_gpio_irq_get(adev, 0);
+	if (irq == 0 || irq == -ENOENT)
+		irq = platform_get_irq(pdev, 0);
 	if (irq > 0)
 		ec_dev->irq = irq;
-	else if (irq != -ENXIO) {
+	else if (irq != -ENXIO && irq != -ENOENT) {
 		dev_err(dev, "couldn't retrieve IRQ number (%d)\n", irq);
 		return irq;
 	}
@@ -317,7 +322,6 @@
 	 * and error-prone endeavor, so register the handler anyway, and trust
 	 * the EC to send the proper MKBP event signals.
 	 */
-	adev = ACPI_COMPANION(dev);
 	if (adev) {
 		status = acpi_install_notify_handler(adev->handle,
 						     ACPI_ALL_NOTIFY,