diff options
Diffstat (limited to 'src/drivers/i2c')
-rw-r--r-- | src/drivers/i2c/hid/hid.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/drivers/i2c/hid/hid.c b/src/drivers/i2c/hid/hid.c index d570892c1d..035e5633c6 100644 --- a/src/drivers/i2c/hid/hid.c +++ b/src/drivers/i2c/hid/hid.c @@ -18,6 +18,8 @@ #include <stdint.h> #include <string.h> #include "chip.h" +#include <gpio.h> +#include <console/console.h> #if CONFIG(HAVE_ACPI_TABLES) static void i2c_hid_fill_dsm(struct device *dev) @@ -60,6 +62,23 @@ static void i2c_hid_enable(struct device *dev) { struct drivers_i2c_hid_config *config = dev->chip_info; + if (!config) + return; + + /* Check if device is present by reading GPIO */ + if (config->generic.device_present_gpio) { + int present = gpio_get(config->generic.device_present_gpio); + present ^= config->generic.device_present_gpio_invert; + + printk(BIOS_INFO, "%s is %spresent\n", + dev->chip_ops->name, present ? "" : "not "); + + if (!present) { + dev->enabled = 0; + return; + } + } + dev->ops = &i2c_hid_ops; if (config && config->generic.desc) { |