drivers/i2c/generic: Support additional device properties

Add support for providing additional free form device properties via
devicetree in order to make this driver suitable for kernel drivers
that need additional board-specific device properties.

This currently allows adding up to 10 additional properties to a device.

BUG=b:63413023
TEST=manual testing to ensure that newly added properties are in SSDT

Change-Id: I2b8ceb208f4aba01053746547def6d07c8f8f3a2
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: https://review.coreboot.org/21270
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Duncan Laurie 2017-08-29 08:28:58 -07:00 committed by Duncan Laurie
parent b3023b697a
commit 1533a3cae8
2 changed files with 11 additions and 1 deletions

View File

@ -19,6 +19,8 @@
#include <arch/acpi_device.h> #include <arch/acpi_device.h>
#include <device/i2c_simple.h> #include <device/i2c_simple.h>
#define MAX_GENERIC_PROPERTY_LIST 10
struct drivers_i2c_generic_config { struct drivers_i2c_generic_config {
const char *hid; /* ACPI _HID (required) */ const char *hid; /* ACPI _HID (required) */
const char *cid; /* ACPI _CID */ const char *cid; /* ACPI _CID */
@ -59,6 +61,10 @@ struct drivers_i2c_generic_config {
struct acpi_gpio enable_gpio; struct acpi_gpio enable_gpio;
/* Delay to be inserted after device is enabled. */ /* Delay to be inserted after device is enabled. */
unsigned enable_delay_ms; unsigned enable_delay_ms;
/* Generic properties for exporting device-specific data to the OS */
struct acpi_dp property_list[MAX_GENERIC_PROPERTY_LIST];
int property_count;
}; };
/* /*

View File

@ -116,7 +116,8 @@ void i2c_generic_fill_ssdt(struct device *dev,
} }
/* DSD */ /* DSD */
if (config->probed || (reset_gpio_index != -1) || if (config->probed || config->property_count ||
(reset_gpio_index != -1) ||
(enable_gpio_index != -1) || (irq_gpio_index != -1)) { (enable_gpio_index != -1) || (irq_gpio_index != -1)) {
dsd = acpi_dp_new_table("_DSD"); dsd = acpi_dp_new_table("_DSD");
if (config->probed) if (config->probed)
@ -134,6 +135,9 @@ void i2c_generic_fill_ssdt(struct device *dev,
acpi_dp_add_gpio(dsd, "enable-gpios", path, acpi_dp_add_gpio(dsd, "enable-gpios", path,
enable_gpio_index, 0, enable_gpio_index, 0,
config->enable_gpio.polarity); config->enable_gpio.polarity);
/* Add generic property list */
acpi_dp_add_property_list(dsd, config->property_list,
config->property_count);
acpi_dp_write(dsd); acpi_dp_write(dsd);
} }