summaryrefslogtreecommitdiff
path: root/drivers/i2c/i2c-uclass.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-09-22 21:45:01 +0300
committerBin Meng <bmeng.cn@gmail.com>2020-09-25 06:27:15 +0300
commitfd42f263cef9fd6bba9ded76a82d4ac66450e156 (patch)
tree64bc139fe69c2d50a6200ccda1f1c521e45643b4 /drivers/i2c/i2c-uclass.c
parentbddbaf5edf0e01817f2577295c3d682e4d5fed09 (diff)
downloadu-boot-fd42f263cef9fd6bba9ded76a82d4ac66450e156.tar.xz
i2c: Add a generic driver to generate ACPI info
Many I2C devices produce roughly the same ACPI data with just things like the GPIO/interrupt information being different. This can be handled by a generic driver along with some information in the device tree. Add a generic i2c driver for this purpose. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'drivers/i2c/i2c-uclass.c')
-rw-r--r--drivers/i2c/i2c-uclass.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
index 2373aa2ea4..5c4626b044 100644
--- a/drivers/i2c/i2c-uclass.c
+++ b/drivers/i2c/i2c-uclass.c
@@ -9,6 +9,8 @@
#include <i2c.h>
#include <log.h>
#include <malloc.h>
+#include <acpi/acpi_device.h>
+#include <dm/acpi.h>
#include <dm/device-internal.h>
#include <dm/lists.h>
#include <dm/pinctrl.h>
@@ -16,6 +18,7 @@
#include <asm/gpio.h>
#endif
#include <linux/delay.h>
+#include "acpi_i2c.h"
#define I2C_MAX_OFFSET_LEN 4
@@ -749,7 +752,21 @@ UCLASS_DRIVER(i2c_generic) = {
.name = "i2c_generic",
};
+static const struct udevice_id generic_chip_i2c_ids[] = {
+ { .compatible = "i2c-chip", .data = I2C_DEVICE_GENERIC },
+#if CONFIG_IS_ENABLED(ACPIGEN)
+ { .compatible = "hid-over-i2c", .data = I2C_DEVICE_HID_OVER_I2C },
+#endif
+ { }
+};
+
U_BOOT_DRIVER(i2c_generic_chip_drv) = {
.name = "i2c_generic_chip_drv",
.id = UCLASS_I2C_GENERIC,
+ .of_match = generic_chip_i2c_ids,
+#if CONFIG_IS_ENABLED(ACPIGEN)
+ .ofdata_to_platdata = acpi_i2c_ofdata_to_platdata,
+ .priv_auto_alloc_size = sizeof(struct acpi_i2c_priv),
+#endif
+ ACPI_OPS_PTR(&acpi_i2c_ops)
};