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

Change-Id: I22cffb4b15f25d97dfd37dc58bca315f57bafc59
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://review.coreboot.org/16742
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Duncan Laurie 2016-09-26 10:31:22 -07:00 committed by Martin Roth
parent eeabb75e8c
commit fbf2c79b48
2 changed files with 16 additions and 0 deletions

View File

@ -10,6 +10,15 @@ struct drivers_i2c_generic_config {
unsigned wake; /* Wake GPE */ unsigned wake; /* Wake GPE */
struct acpi_irq irq; /* Interrupt */ 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 */ /* GPIO used to indicate if this device is present */
unsigned device_present_gpio; unsigned device_present_gpio;
unsigned device_present_gpio_invert; unsigned device_present_gpio_invert;

View File

@ -35,6 +35,7 @@ static void i2c_generic_fill_ssdt(struct device *dev)
.speed = config->speed ? : I2C_SPEED_FAST, .speed = config->speed ? : I2C_SPEED_FAST,
.resource = scope, .resource = scope,
}; };
struct acpi_dp *dsd = NULL;
if (!dev->enabled || !scope) if (!dev->enabled || !scope)
return; return;
@ -65,6 +66,12 @@ static void i2c_generic_fill_ssdt(struct device *dev)
acpigen_write_PRW(config->wake, 3); 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(); /* Device */
acpigen_pop_len(); /* Scope */ acpigen_pop_len(); /* Scope */