From 7a5e3dc1a0dbcd57057277397cbf5ea501a2d9d4 Mon Sep 17 00:00:00 2001 From: Duncan Laurie Date: Mon, 26 Sep 2016 10:31:22 -0700 Subject: [PATCH] UPSTREAM: drivers/i2c/generic: Add config for marking device as probed Add a config option to the generic I2C device driver to indicate to the OS that this device should be probed before being added. This can be used to provide ACPI device instantiations to devices that may not actually exist on the board. For example, if multiple trackpad vendors are supported on the same board they can both be described in ACPI and the OS will probe the address and load the driver only if the device responds to the probe at that address. BUG=chrome-os-partner:57686 BRANCH=None TEST=None Signed-off-by: Duncan Laurie Reviewed-on: https://review.coreboot.org/16742 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin Change-Id: I22cffb4b15f25d97dfd37dc58bca315f57bafc59 Reviewed-on: https://chromium-review.googlesource.com/390892 Commit-Ready: Furquan Shaikh Tested-by: Furquan Shaikh Reviewed-by: Aaron Durbin --- src/drivers/i2c/generic/chip.h | 9 +++++++++ src/drivers/i2c/generic/generic.c | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/src/drivers/i2c/generic/chip.h b/src/drivers/i2c/generic/chip.h index 84657d5241..d84097f6c6 100644 --- a/src/drivers/i2c/generic/chip.h +++ b/src/drivers/i2c/generic/chip.h @@ -10,6 +10,15 @@ struct drivers_i2c_generic_config { unsigned wake; /* Wake GPE */ struct acpi_irq irq; /* Interrupt */ + /* + * This flag will add a device propery which will indicate + * to the OS that it should probe this device before adding it. + * + * This can be used to declare a device that may not exist on + * the board, for example to support multiple trackpad vendors. + */ + int probed; + /* GPIO used to indicate if this device is present */ unsigned device_present_gpio; unsigned device_present_gpio_invert; diff --git a/src/drivers/i2c/generic/generic.c b/src/drivers/i2c/generic/generic.c index 62e2e9a813..30a280bcff 100644 --- a/src/drivers/i2c/generic/generic.c +++ b/src/drivers/i2c/generic/generic.c @@ -35,6 +35,7 @@ static void i2c_generic_fill_ssdt(struct device *dev) .speed = config->speed ? : I2C_SPEED_FAST, .resource = scope, }; + struct acpi_dp *dsd = NULL; if (!dev->enabled || !scope) return; @@ -65,6 +66,12 @@ static void i2c_generic_fill_ssdt(struct device *dev) acpigen_write_PRW(config->wake, 3); } + if (config->probed) { + dsd = acpi_dp_new_table("_DSD"); + acpi_dp_add_integer(dsd, "linux,probed", 1); + acpi_dp_write(dsd); + } + acpigen_pop_len(); /* Device */ acpigen_pop_len(); /* Scope */