drivers/i2c/hid: Enforce level triggered IRQ mode
As per HID over I2C Protocol Specification[1] Version 1.00 Section 7.4,
the interrupt line used by the device is required to be level triggered.
This change ensures that the IRQ is appropriately configured.
References:
[1] http://download.microsoft.com/download/7/d/d/7dd44bb7-2a7a-4505-ac1c-7227d3d96d5b/hid-over-i2c-protocol-spec-v1-0.docx
BUG=b:172846122
TEST=./util/abuild/abuild. Build and boot to OS in Dedede.
Change-Id: I3245a9de6e88cd83528823251083e62288192f0d
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/50442
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Michael Niewöhner <foss@mniewoehner.de>
diff --git a/src/drivers/i2c/hid/hid.c b/src/drivers/i2c/hid/hid.c
index 2d213eb..8705c1e 100644
--- a/src/drivers/i2c/hid/hid.c
+++ b/src/drivers/i2c/hid/hid.c
@@ -1,6 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <acpi/acpigen_dsm.h>
+#include <acpi/acpi_device.h>
+#include <assert.h>
#include <device/device.h>
#include <string.h>
#include "chip.h"
@@ -68,6 +70,18 @@
}
}
+ /*
+ * Ensure that I2C HID devices use level triggered interrupts as per ACPI
+ * I2C HID requirement. Check interrupt and GPIO interrupt.
+ */
+ if ((!config->generic.irq_gpio.pin_count &&
+ config->generic.irq.mode != ACPI_IRQ_LEVEL_TRIGGERED) ||
+ (config->generic.irq_gpio.pin_count &&
+ config->generic.irq_gpio.irq.mode != ACPI_IRQ_LEVEL_TRIGGERED)) {
+ printk(BIOS_ERR, "%s IRQ is not level triggered.\n", config->generic.hid);
+ BUG();
+ }
+
dev->ops = &i2c_hid_ops;
if (config && config->generic.desc) {