aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/i2c/generic/chip.h
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/chip.h
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/chip.h')
-rw-r--r--src/drivers/i2c/generic/chip.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/drivers/i2c/generic/chip.h b/src/drivers/i2c/generic/chip.h
index e84fc38df9..736de51591 100644
--- a/src/drivers/i2c/generic/chip.h
+++ b/src/drivers/i2c/generic/chip.h
@@ -1,8 +1,27 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2016 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __I2C_GENERIC_CHIP_H__
+#define __I2C_GENERIC_CHIP_H__
+
#include <arch/acpi_device.h>
#include <device/i2c.h>
struct drivers_i2c_generic_config {
const char *hid; /* ACPI _HID (required) */
+ const char *cid; /* ACPI _CID */
const char *name; /* ACPI Device Name */
const char *desc; /* Device Description */
unsigned uid; /* ACPI _UID */
@@ -32,3 +51,17 @@ struct drivers_i2c_generic_config {
/* Delay to be inserted after device is enabled. */
unsigned enable_delay_ms;
};
+
+/*
+ * Fills in generic information about i2c device from device-tree
+ * properties. Callback can be provided to fill in any
+ * device-specific information in SSDT.
+ *
+ * Drivers calling into this function to generate should place
+ * drivers_i2c_generic_config structure at the beginning of their device config
+ * structure.
+ */
+void i2c_generic_fill_ssdt(struct device *dev,
+ void (*callback)(struct device *dev));
+
+#endif /* __I2C_GENERIC_CHIP_H__ */