From a7e6788ea70ea74fb905ae70035b74ec2caf39fd Mon Sep 17 00:00:00 2001 From: Karthikeyan Ramasubramanian Date: Tue, 9 Feb 2021 10:07:47 -0700 Subject: drivers/i2c/hid: Enforce level triggered IRQ mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/50442 Tested-by: build bot (Jenkins) Reviewed-by: Tim Wawrzynczak Reviewed-by: Angel Pons Reviewed-by: Furquan Shaikh Reviewed-by: Michael Niewöhner --- src/drivers/i2c/hid/hid.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/drivers/i2c/hid/hid.c b/src/drivers/i2c/hid/hid.c index 2d213eb74e..8705c1e34a 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 +#include +#include #include #include #include "chip.h" @@ -68,6 +70,18 @@ static void i2c_hid_enable(struct device *dev) } } + /* + * 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) { -- cgit v1.2.3