summaryrefslogtreecommitdiff
path: root/src/drivers/i2c/generic/generic.c
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@chromium.org>2016-10-21 16:24:07 -0700
committerFurquan Shaikh <furquan@google.com>2016-10-25 00:13:05 +0200
commit1d33488968573888ea1fc386b7ede0bc67e9b32c (patch)
tree35b910c2474512bdbec272ef645bd3b417bf45e6 /src/drivers/i2c/generic/generic.c
parent9b39adb4545bbfdddda333d23400599b7c061126 (diff)
drivers/i2c/generic: Re-factor SSDT generation code
1. Export i2c_generic_fill_ssdt to allow other device-specific i2c drivers to share and re-use the same code for generating AML code for SSDT. In order to achieve this, following changes are required: a. Add macro I2C_GENERIC_CONFIG that defines a structure with all generic i2c device-tree properties. This macro should be placed by the using driver at the start of its config structure. b. Accept a callback function to add any device specific information to SSDT. If generic driver is used directly by a device, callback would be NULL. Other devices using a separate i2c driver can provide a callback to add any properties to SSDT. 2. Allow device to provide _CID. BUG=chrome-os-partner:57846 Change-Id: I3a0054e22b81f9d6d407bef417eae5e9edc04ee4 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://review.coreboot.org/17089 Tested-by: build bot (Jenkins) Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Diffstat (limited to 'src/drivers/i2c/generic/generic.c')
-rw-r--r--src/drivers/i2c/generic/generic.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/drivers/i2c/generic/generic.c b/src/drivers/i2c/generic/generic.c
index 34fbf77a3e..b8e5d863f7 100644
--- a/src/drivers/i2c/generic/generic.c
+++ b/src/drivers/i2c/generic/generic.c
@@ -65,7 +65,8 @@ static void i2c_generic_add_power_res(struct drivers_i2c_generic_config *config)
acpigen_pop_len(); /* PowerResource PRIC */
}
-static void i2c_generic_fill_ssdt(struct device *dev)
+void i2c_generic_fill_ssdt(struct device *dev,
+ void (*callback)(struct device *dev))
{
struct drivers_i2c_generic_config *config = dev->chip_info;
const char *scope = acpi_device_scope(dev);
@@ -89,6 +90,8 @@ static void i2c_generic_fill_ssdt(struct device *dev)
acpigen_write_scope(scope);
acpigen_write_device(acpi_device_name(dev));
acpigen_write_name_string("_HID", config->hid);
+ if (config->cid)
+ acpigen_write_name_string("_CID", config->cid);
acpigen_write_name_integer("_UID", config->uid);
acpigen_write_name_string("_DDN", config->desc);
acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON);
@@ -115,6 +118,10 @@ static void i2c_generic_fill_ssdt(struct device *dev)
/* Power Resource */
i2c_generic_add_power_res(config);
+ /* Callback if any. */
+ if (callback)
+ callback(dev);
+
acpigen_pop_len(); /* Device */
acpigen_pop_len(); /* Scope */
@@ -122,6 +129,11 @@ static void i2c_generic_fill_ssdt(struct device *dev)
config->desc ? : dev->chip_ops->name, dev_path(dev));
}
+static void i2c_generic_fill_ssdt_generator(struct device *dev)
+{
+ i2c_generic_fill_ssdt(dev, NULL);
+}
+
/* Use name specified in config or build one from I2C address */
static const char *i2c_generic_acpi_name(struct device *dev)
{
@@ -143,7 +155,7 @@ static struct device_operations i2c_generic_ops = {
.enable_resources = DEVICE_NOOP,
#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
.acpi_name = &i2c_generic_acpi_name,
- .acpi_fill_ssdt_generator = &i2c_generic_fill_ssdt,
+ .acpi_fill_ssdt_generator = &i2c_generic_fill_ssdt_generator,
#endif
};